ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 ·...
Transcript of ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 ·...
![Page 1: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/1.jpg)
redefine.digital.design: Helping you deal with complexity in VHDL and Verilog.
Xtending our VHDL Xtextformatter with the formatter2 APIir. Titouan Vervack
EclipseCon France2017-06-21
![Page 2: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/2.jpg)
redefine.digital.design: Helping you deal with complexity in VHDL and Verilog.
Xtending our VHDL Xtextformatter with the formatter2 APIir. Titouan Vervack
EclipseCon France, Toulouse2017-06-21
![Page 3: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/3.jpg)
Ghent
2
![Page 4: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/4.jpg)
What do we do?
VHDL & SV IDE
3
![Page 5: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/5.jpg)
What do we do?
Advanced analysis and linting
4
![Page 6: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/6.jpg)
What do we do?
Visualisation
5
![Page 7: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/7.jpg)
What do we do?
Visualisation
6
![Page 8: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/8.jpg)
What do we do?
Eat cake
7
![Page 9: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/9.jpg)
What do we do?
And cookies...
8
![Page 10: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/10.jpg)
What do we do?
And occasionally… formatting
9
![Page 11: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/11.jpg)
What do we do?
And occasionally… formatting
9
![Page 12: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/12.jpg)
Our formatter problems
10
![Page 13: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/13.jpg)
Our formatter problems
● Big grammar○ ~1.2k LoC○ ~200 rules
10
![Page 14: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/14.jpg)
Our formatter problems
● Big grammar○ ~1.2k LoC○ ~200 rules
● Hard to fix bugs
10
![Page 15: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/15.jpg)
Our formatter problems
● Big grammar○ ~1.2k LoC○ ~200 rules
● Hard to fix bugs
● Near impossible to add new features
10
![Page 16: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/16.jpg)
Formatter 1.0 vs Formatter 2.0
11
Formatter 1.0 Formatter 2.0
● No access to○ Node model○ AST○ Text
● => Specify everything purely on the grammar
● => Lots of hacks
● Access to○ Node model○ AST○ Grammar
● Can’t take context into account○ Can’t adjust to the user
● Context aware formatting○ Conditional formatting○ Table formatting
● Not customizable ● Very customizable
![Page 17: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/17.jpg)
Formatter 2.0 region example
variable _ foo _ : _ bit _ ; _-- bar\n
variable foo : bit; -- bar
= ISemanticRegion
= IHiddenRegion
_ -- bar \n
= IHiddenRegionPart
12https://de.slideshare.net/meysholdt/xtexts-new-formatter-api
![Page 18: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/18.jpg)
Formatting 2.0 usage example
https://de.slideshare.net/meysholdt/xtexts-new-formatter-api13
![Page 19: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/19.jpg)
Formatting 2.0 usage example
https://de.slideshare.net/meysholdt/xtexts-new-formatter-api
class AwesomO4000 extends AbstractFormatter2 {
}
13
![Page 20: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/20.jpg)
Formatting 2.0 usage example
https://de.slideshare.net/meysholdt/xtexts-new-formatter-api
class AwesomO4000 extends AbstractFormatter2 {
def dispatch void format(FunctionDecl fd, extension IFormattableDocument d) {
}}
13
![Page 21: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/21.jpg)
Formatting 2.0 usage example
https://de.slideshare.net/meysholdt/xtexts-new-formatter-api
class AwesomO4000 extends AbstractFormatter2 {
def dispatch void format(FunctionDecl fd, extension IFormattableDocument d) { interior(fd.regionFor.keyword(“{”), fd.regionFor.keyword(“}”))[indent]
}}
13
![Page 22: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/22.jpg)
Formatting 2.0 usage example
https://de.slideshare.net/meysholdt/xtexts-new-formatter-api
class AwesomO4000 extends AbstractFormatter2 {
def dispatch void format(FunctionDecl fd, extension IFormattableDocument d) { interior(fd.regionFor.keyword(“{”), fd.regionFor.keyword(“}”))[indent]
fd.declarations.forEach[format]
}}
13
![Page 23: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/23.jpg)
Formatting 2.0 usage example
https://de.slideshare.net/meysholdt/xtexts-new-formatter-api
class AwesomO4000 extends AbstractFormatter2 {
def dispatch void format(FunctionDecl fd, extension IFormattableDocument d) { interior(fd.regionFor.keyword(“{”), fd.regionFor.keyword(“}”))[indent]
fd.declarations.forEach[format]
fd.regionFor.keyword(“;”)
}}
13
![Page 24: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/24.jpg)
Formatting 2.0 usage example
https://de.slideshare.net/meysholdt/xtexts-new-formatter-api
class AwesomO4000 extends AbstractFormatter2 {
def dispatch void format(FunctionDecl fd, extension IFormattableDocument d) { interior(fd.regionFor.keyword(“{”), fd.regionFor.keyword(“}”))[indent]
fd.declarations.forEach[format]
fd.regionFor.keyword(“;”) .prepend[noSpace highPriority]
}}
13
![Page 25: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/25.jpg)
Formatting 2.0 usage example
https://de.slideshare.net/meysholdt/xtexts-new-formatter-api
class AwesomO4000 extends AbstractFormatter2 {
def dispatch void format(FunctionDecl fd, extension IFormattableDocument d) { interior(fd.regionFor.keyword(“{”), fd.regionFor.keyword(“}”))[indent]
fd.declarations.forEach[format]
fd.regionFor.keyword(“;”) .prepend[noSpace highPriority] .append[setNewlines(1, 1, 2)] }}
13
![Page 26: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/26.jpg)
Time for a plan
14
![Page 27: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/27.jpg)
Time for a plan
1. Make tests compatible
14
![Page 28: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/28.jpg)
Time for a plan
1. Make tests compatible2. Start out easy: only indentation
14
![Page 29: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/29.jpg)
Time for a plan
1. Make tests compatible2. Start out easy: only indentation3. Fix tests one by one
14
![Page 30: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/30.jpg)
Time for a plan
1. Make tests compatible2. Start out easy: only indentation3. Fix tests one by one4. Fix old bugs
14
![Page 31: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/31.jpg)
Time for a plan
1. Make tests compatible2. Start out easy: only indentation3. Fix tests one by one4. Fix old bugs5. Do not introduce new bugs
14
![Page 32: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/32.jpg)
Time for a plan
1. Make tests compatible2. Start out easy: only indentation3. Fix tests one by one4. Fix old bugs5. Do not introduce new bugs6. Feature parity & extend with new features
14
![Page 33: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/33.jpg)
Time for a plan
1. Make tests compatible2. Start out easy: only indentation3. Fix tests one by one4. Fix old bugs5. Do not introduce new bugs6. Feature parity & extend with new features7. Performance tweaking to same or better level than old
14
![Page 34: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/34.jpg)
Actual timeline
formatter.format(node, node.offset, node.length).formattedText
1. Make tests compatible
15
![Page 35: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/35.jpg)
Actual timeline
formatter.format(node, node.offset, node.length).formattedText
1. Make tests compatible
15
![Page 36: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/36.jpg)
Actual timeline
formatter.format(node, node.offset, node.length).formattedText
1. Make tests compatible
val request = new FormatterRequest()
val parsed = new XtextResource()
parsed.contents.add(parseResult.rootASTElement)
parsed.setParseResult(parseResult)
val access = builder.forNodeModel(resource).create()
request.setTextRegionAccess(access)
val replacements = formatter.format(request) access.rewriter.renderToString(replacements)
15
![Page 37: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/37.jpg)
interior(entity.regionFor.keyword(“is”), entity.regionFor.keyword(“end”))[indent]
Actual timeline
2. Start out easy: only indentation
16
![Page 38: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/38.jpg)
interior(entity.regionFor.keyword(“is”), entity.regionFor.keyword(“end”))[indent]
Actual timeline
2. Start out easy: only indentation
● Indentation requires newline definitions
16
![Page 39: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/39.jpg)
interior(entity.regionFor.keyword(“is”), entity.regionFor.keyword(“end”))[indent]
Actual timeline
2. Start out easy: only indentation
● Indentation requires newline definitions
● => replace all newlines with… the same amount of newlines
16
![Page 40: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/40.jpg)
Actual timeline
3. Fix tests one by one4. Fix old bugs
17
![Page 41: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/41.jpg)
Actual timeline
3. Fix tests one by one4. Fix old bugs
17
![Page 42: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/42.jpg)
Actual timeline
5. Do not introduce new bugs
18
![Page 43: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/43.jpg)
Actual timeline
5. Do not introduce new bugs
18
![Page 44: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/44.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
19
![Page 45: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/45.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
● Parity:
19
![Page 46: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/46.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
● Parity:○ Keyword casing
19
![Page 47: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/47.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
● Parity:○ Keyword casing○ Comment alignment to columns
19
![Page 48: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/48.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
● Parity:○ Keyword casing○ Comment alignment to columns○ Vertical alignment on keywords “:”, “:=”,...
19
![Page 49: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/49.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
● Parity:○ Keyword casing○ Comment alignment to columns○ Vertical alignment on keywords “:”, “:=”,...○ Preserve newline
19
![Page 50: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/50.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
● Parity:○ Keyword casing○ Comment alignment to columns○ Vertical alignment on keywords “:”, “:=”,...○ Preserve newline
● New features:
19
![Page 51: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/51.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
● Parity:○ Keyword casing○ Comment alignment to columns○ Vertical alignment on keywords “:”, “:=”,...○ Preserve newline
● New features:○ Correct indentation
19
![Page 52: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/52.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
● Parity:○ Keyword casing○ Comment alignment to columns○ Vertical alignment on keywords “:”, “:=”,...○ Preserve newline
● New features:○ Correct indentation○ Formatter tags
19
![Page 53: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/53.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
● Parity:○ Keyword casing○ Comment alignment to columns○ Vertical alignment on keywords “:”, “:=”,...○ Preserve newline
● New features:○ Correct indentation○ Formatter tags
Easy once we have alignment19
![Page 54: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/54.jpg)
Alignment?
20
![Page 55: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/55.jpg)
Alignment?
20
![Page 56: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/56.jpg)
Alignment?
● Replacements are added in random order, applied in correct order
21
![Page 57: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/57.jpg)
Alignment?
● Replacements are added in random order, applied in correct order
● Alignment needs to be done on post-formatted input
21
![Page 58: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/58.jpg)
Alignment?
● Replacements are added in random order, applied in correct order
● Alignment needs to be done on post-formatted input
● How do I know which region to format?
21
![Page 59: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/59.jpg)
Alignment!
22
![Page 60: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/60.jpg)
Alignment!
22
![Page 61: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/61.jpg)
Alignment!
22
![Page 62: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/62.jpg)
Alignment!
22
![Page 63: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/63.jpg)
Alignment!
start end
22
![Page 64: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/64.jpg)
Alignment!
start end
22
![Page 65: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/65.jpg)
Alignment!
Find smallest encapsulating object that formats region between start and end
start end
22
![Page 66: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/66.jpg)
Alignment!
Find smallest encapsulating object that formats region between start and end
start end
22
![Page 67: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/67.jpg)
Alignment!
clk : in std_logic := ‘X’;
23
![Page 68: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/68.jpg)
Alignment!
clk : in std_logic := ‘X’;
start end
23
![Page 69: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/69.jpg)
PortDeclaration
Alignment!
clk : in std_logic := ‘X’;
start end
name direction type value
end.getSemanticElement()
PortDeclaration
PortList
23
![Page 70: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/70.jpg)
PortDeclaration
Alignment!
clk : in std_logic := ‘X’;
start end
name direction type value
offset x
x + 4
end.getSemanticElement()
PortDeclaration
PortList
23
![Page 71: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/71.jpg)
val rule = portDecl.getParserRule()val oldAccess = createTextRegionAccess(rule, portDecl.text)
val formatted = portDecl.format()
Alignment!
Format smallest encapsulating object
24
![Page 72: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/72.jpg)
val rule = portDecl.getParserRule()val oldAccess = createTextRegionAccess(rule, portDecl.text)
val formatted = portDecl.format()
Alignment!
val newAccess = createTextRegionAccess(rule, formatted.text)val oldIndices = oldAccess.getIndices(start, end)val length = newAccess.countBetween(oldIndices)
Format smallest encapsulating object
Map unformatted string to formatted string
24
![Page 73: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/73.jpg)
Align on first parameter?
→return (→→foo((5,→→·····6),→→····3));
25
![Page 74: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/74.jpg)
Align on first parameter?
→return (→→foo((5,→→·····6),→→····3));
25
![Page 75: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/75.jpg)
Align on first parameter?
→return (→→foo((5,→→·····6),→→····3));
→return (5,→········foo((5,→·············6),→············3));
25
![Page 76: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/76.jpg)
Align on first parameter?
→return (→→foo((5,→→·····6),→→····3));
→return (5,→········foo((5,→·············6),→············3));
25
![Page 77: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/77.jpg)
Align on first parameter?
→return (→→foo((5,→→·····6),→→····3));
→return (5,→········foo((5,→·············6),→············3));
→return foo((5,→············6),→···········3));
25
![Page 78: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/78.jpg)
Align on first parameter?
→return (→→foo((5,→→·····6),→→····3));
→return (5,→········foo((5,→·············6),→············3));
→return foo((5,→············6),→···········3));
25
![Page 79: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/79.jpg)
Align on first parameter?
→return (→→foo((5,→→·····6),→→····3));
→return (5,→········foo((5,→·············6),→············3));
→return foo((5,→············6),→···········3));
→return foo(→→(5,→→·6),→→3));
25
![Page 80: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/80.jpg)
Align on first parameter?
→return (→→foo((5,→→·····6),→→····3));
→return (5,→········foo((5,→·············6),→············3));
→return foo((5,→············6),→···········3));
→return foo(→→(5,→→·6),→→3));
25
![Page 81: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/81.jpg)
Align on first parameter?
→return (→→foo((5,→→·····6),→→····3));
→return (5,→········foo((5,→·············6),→············3));
→return foo((5,→············6),→···········3));
→return foo(→→(5,→→·6),→→3));
Find largest encapsulating element on same line
25
![Page 82: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/82.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
Correct indentation
26
![Page 83: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/83.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
Correct indentation
val replacements = formatter.format(request)
26
![Page 84: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/84.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
Correct indentation
val replacements = formatter.format(request)replacements .filter[ r|
]
26
![Page 85: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/85.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
Correct indentation
val replacements = formatter.format(request)replacements .filter[ r| r.lineCount > 1
]
26
![Page 86: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/86.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
Correct indentation
val replacements = formatter.format(request)replacements .filter[ r| r.lineCount > 1 && r.replacementText.newlines + 1 == r.lineCount ]
26
![Page 87: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/87.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
Formatter tags
27
![Page 88: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/88.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
Formatter tags
-- @formatter:off Turns formatter off-- @formatter:on Turns formatter on
27
![Page 89: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/89.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
Formatter tags
-- @formatter:off Turns formatter off-- @formatter:on Turns formatter on
val originalRegions = request.getRegions() ?: document.region
27
![Page 90: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/90.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
Formatter tags
-- @formatter:off Turns formatter off-- @formatter:on Turns formatter on
val originalRegions = request.getRegions() ?: document.regionval betweenRegions = document.findRegionsBetween(off, on)
27
![Page 91: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/91.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
Formatter tags
-- @formatter:off Turns formatter off-- @formatter:on Turns formatter on
val originalRegions = request.getRegions() ?: document.regionval betweenRegions = document.findRegionsBetween(off, on) .addAll(document.findRegionsBetween(off, EOF))
27
![Page 92: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/92.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
Formatter tags
-- @formatter:off Turns formatter off-- @formatter:on Turns formatter on
val originalRegions = request.getRegions() ?: document.regionval betweenRegions = document.findRegionsBetween(off, on) .addAll(document.findRegionsBetween(off, EOF))val newRegions = originalRegions.removeRegions(betweenRegions)
27
![Page 93: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/93.jpg)
Actual timeline
6. Feature parity & extend formatter with new features
Formatter tags
-- @formatter:off Turns formatter off-- @formatter:on Turns formatter on
val originalRegions = request.getRegions() ?: document.regionval betweenRegions = document.findRegionsBetween(off, on) .addAll(document.findRegionsBetween(off, EOF))val newRegions = originalRegions.removeRegions(betweenRegions)request.setRegions(newRegions)
27
![Page 94: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/94.jpg)
Performance
7. Performance tweaking to same or better level than old
28
![Page 95: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/95.jpg)
Performance
7. Performance tweaking to same or better level than old
● Cache ITextRegionAccess in subformats
28
![Page 96: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/96.jpg)
Performance
7. Performance tweaking to same or better level than old
● Cache ITextRegionAccess in subformats
● Cache IParser.createAllRules(Grammar)
28
![Page 97: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/97.jpg)
Performance
7. Performance tweaking to same or better level than old
● Cache ITextRegionAccess in subformats
● Cache IParser.createAllRules(Grammar)
● Merge all replacements into one big replacement
28
![Page 98: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/98.jpg)
Performance
7. Performance tweaking to same or better level than old
emacs/xtend > 25m
29
![Page 99: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/99.jpg)
Performance
7. Performance tweaking to same or better level than old
emacs/xtend > 25m
30
![Page 100: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/100.jpg)
Biggest problems in hindsight
31
![Page 101: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/101.jpg)
Biggest problems in hindsight
● Tests pass, close enough?
31
![Page 102: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/102.jpg)
Biggest problems in hindsight
● Tests pass, close enough?○ Nope, old testset isn’t nearly enough
31
![Page 103: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/103.jpg)
Biggest problems in hindsight
● Tests pass, close enough?○ Nope, old testset isn’t nearly enough
● Comments are an enormous pain: eat newlines, add spaces, eat spaces, fake empty lines
31
![Page 104: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/104.jpg)
Biggest problems in hindsight
● Tests pass, close enough?○ Nope, old testset isn’t nearly enough
● Comments are an enormous pain: eat newlines, add spaces, eat spaces, fake empty lines
● Alignment interactions with normal and first param alignments and comments
31
![Page 105: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/105.jpg)
Biggest problems in hindsight
● Tests pass, close enough?○ Nope, old testset isn’t nearly enough
● Comments are an enormous pain: eat newlines, add spaces, eat spaces, fake empty lines
● Alignment interactions with normal and first param alignments and comments
31
![Page 106: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/106.jpg)
Biggest problems in hindsight
● Tests pass, close enough?○ Nope, old testset isn’t nearly enough
● Comments are an enormous pain: eat newlines, add spaces, eat spaces, fake empty lines
● Alignment interactions with normal and first param alignments and comments
31
![Page 107: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/107.jpg)
Biggest problems in hindsight
● Tests pass, close enough?○ Nope, old testset isn’t nearly enough
● Comments are an enormous pain: eat newlines, add spaces, eat spaces, fake empty lines
● Alignment interactions with normal and first param alignments and comments
31
![Page 108: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/108.jpg)
Biggest problems in hindsight
● Tests pass, close enough?○ Nope, old testset isn’t nearly enough
● Comments are an enormous pain: eat newlines, add spaces, eat spaces, fake empty lines
● Alignment interactions with normal and first param alignments and comments
3031
![Page 109: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/109.jpg)
Biggest problems in hindsight
● Tests pass, close enough?○ Nope, old testset isn’t nearly enough
● Comments are an enormous pain: eat newlines, add spaces, eat spaces, fake empty lines
● Alignment interactions with normal and first param alignments and comments
3031
![Page 110: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/110.jpg)
Biggest problems in hindsight
● Tests pass, close enough?○ Nope, old testset isn’t nearly enough
● Comments are an enormous pain: eat newlines, add spaces, eat spaces, fake empty lines
● Alignment interactions with normal and first param alignments and comments
3031
![Page 111: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/111.jpg)
Warning to Xtext users
Default ExceptionHandler logs DSL source code to stderr
32
![Page 112: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/112.jpg)
Sigasi future work
33
![Page 113: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/113.jpg)
Sigasi future work
● Smooth out remaining bugs
33
![Page 114: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/114.jpg)
Sigasi future work
● Smooth out remaining bugs● Some more context awareness
33
![Page 115: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/115.jpg)
Sigasi future work
● Smooth out remaining bugs● Some more context awareness● Autowrap
33
![Page 116: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/116.jpg)
Sigasi future work
● Smooth out remaining bugs● Some more context awareness● Autowrap● Performance
33
![Page 117: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/117.jpg)
Sigasi future work
● Smooth out remaining bugs● Some more context awareness● Autowrap● Performance● Upstream features
33
![Page 118: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/118.jpg)
Sigasi future work
● Smooth out remaining bugs● Some more context awareness● Autowrap● Performance● Upstream features
○ Formatter tags
33
![Page 119: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/119.jpg)
Sigasi future work
● Smooth out remaining bugs● Some more context awareness● Autowrap● Performance● Upstream features
○ Formatter tags○ Correct indentation
33
![Page 120: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/120.jpg)
Sigasi future work
● Smooth out remaining bugs● Some more context awareness● Autowrap● Performance● Upstream features
○ Formatter tags○ Correct indentation○ Performance optimizations
33
![Page 121: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/121.jpg)
Xtext wish list
34
![Page 122: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/122.jpg)
Xtext wish list
● Accept my PRs (tags, correct indent, performance)
34
![Page 123: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/123.jpg)
Xtext wish list
● Accept my PRs (tags, correct indent, performance)● Fix/discuss my issues
34
![Page 124: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/124.jpg)
Xtext wish list
● Accept my PRs (tags, correct indent, performance)● Fix/discuss my issues● Fix Xtend formatter issues
34
![Page 125: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/125.jpg)
Xtext wish list
● Accept my PRs (tags, correct indent, performance)● Fix/discuss my issues● Fix Xtend formatter issues● Very slow Xtend formatter source file
34
![Page 126: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/126.jpg)
Xtext wish list
● Accept my PRs (tags, correct indent, performance)● Fix/discuss my issues● Fix Xtend formatter issues● Very slow Xtend formatter source file● Add pre- and post format hooks in format(FormatterRequest)
34
![Page 127: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/127.jpg)
Conclusion
35
![Page 128: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/128.jpg)
Conclusion
● Context aware
35
![Page 129: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/129.jpg)
Conclusion
● Context aware● Debugable
35
![Page 130: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/130.jpg)
Conclusion
● Context aware● Debugable● Good performance
35
![Page 131: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/131.jpg)
Conclusion
● Context aware● Debugable● Good performance● Very customizable
35
![Page 132: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/132.jpg)
Conclusion
● Context aware● Debugable● Good performance● Very customizable● User friendly
35
![Page 133: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/133.jpg)
Conclusion
● Context aware● Debugable● Good performance● Very customizable● User friendly
○ Done in 2 months (base in 2 weeks) while first task and not used to Xtend
35
![Page 134: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/134.jpg)
Conclusion
● Context aware● Debugable● Good performance● Very customizable● User friendly
○ Done in 2 months (base in 2 weeks) while first task and not used to Xtend
● Happy with the switch
35
![Page 135: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/135.jpg)
Conclusion
● Context aware● Debugable● Good performance● Very customizable● User friendly
○ Done in 2 months (base in 2 weeks) while first task and not used to Xtend
● Happy with the switch○ New features
35
![Page 136: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/136.jpg)
Conclusion
● Context aware● Debugable● Good performance● Very customizable● User friendly
○ Done in 2 months (base in 2 weeks) while first task and not used to Xtend
● Happy with the switch○ New features○ Very readable
35
![Page 137: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/137.jpg)
Conclusion
● Context aware● Debugable● Good performance● Very customizable● User friendly
○ Done in 2 months (base in 2 weeks) while first task and not used to Xtend
● Happy with the switch○ New features○ Very readable○ Conditional formatting
35
![Page 138: ir. Titouan Vervack formatter with the formatter2 API Xtending our … · 2017-06-19 · .prepend[noSpace highPriority].append[setNewlines(1, 1, 2)]}} 13. Time for a plan 14. Time](https://reader034.fdocuments.net/reader034/viewer/2022042416/5f3242fc35e3ee4a7b2be7e5/html5/thumbnails/138.jpg)
Evaluate the Sessions
-1 0 +1Sign in and vote at eclipsecon.org