#2346 redone: a formatter for Rascal itself, plus the necessary improvements and stabilization in the Box formatter framework code.#2738
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2738 +/- ##
=======================================
Coverage 46% 46%
- Complexity 6725 6732 +7
=======================================
Files 794 794
Lines 65923 65936 +13
Branches 9888 9888
=======================================
+ Hits 30837 30853 +16
+ Misses 32696 32693 -3
Partials 2390 2390 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…igate the loss of the automatic assert
|
thanks for the review @toinehartman . Before we merge, some of the TODOs @toinehartman highlighted should be checked. See the conversation above. |
|
|
@DavyLandman this seems ready. lots of fixes in Box-related code, fixed in layoutDif, and new features for Rascal formatting. |
toinehartman
left a comment
There was a problem hiding this comment.
Nice to see the declarative formatting nearing completion! I just have some small remarks.
| // first add required locations to layout nodes | ||
| original = reposition(original, markLit=true, markLayout=true, markSubLayout=true); | ||
| // TODO: check if indeed repositioning is never needed | ||
| // original = reposition(original, markLit=true, markLayout=true, markSubLayout=true); |
There was a problem hiding this comment.
Can we do an remove this TODO?
| data Row = R(list[Box] cells); | ||
|
|
||
| // Row R(Box cells...) = _R(cells); | ||
|
|
| @pitfalls{ | ||
| * only useful for debugging purposes, because it becomes a pipeline bottleneck otherwise. | ||
| } | ||
| Box debUG(Box b) { |
There was a problem hiding this comment.
Is the name a funny play on the fact that this is used mostly with U and G boxes?
| bool trimTrailingWhitespace = true, | ||
| bool insertFinalNewline = true, | ||
| bool trimFinalNewlines = true | ||
| ) = formattingOptions(); |
There was a problem hiding this comment.
I really like this! Looking forward to plugging this into LSP as well.
| } | ||
|
|
||
| Box toClusterBox(&T* lst, FO opts=fo()) = toClusterBox([e | e <- lst], opts=opts); | ||
| Box toClusterBox(&T+ lst, FO opts=fo()) = toClusterBox([e | e <- lst], opts=opts); |
There was a problem hiding this comment.
Star and plus patterns? I learn something new every day...
| @synopsis{Convert the Rascal internal grammar representation format (Grammar) to | ||
| a syntax definition in Rascal source code.} | ||
| @pitfalls{ | ||
| This function does not use advanced formatting feature because it is a part of |
There was a problem hiding this comment.
| This function does not use advanced formatting feature because it is a part of | |
| This function does not use advanced formatting features because it is a part of |
| // Box toBox((Expression) `<Expression a> in <Expression b>`) | ||
| // = H1(HOV(toBox(a)), L("in"), HOV(toBox(b))); | ||
|
|
||
| // Box toBox((Expression) `<Expression a> \<= <Expression b>`) | ||
| // = H1(HOV(toBox(a)), L("\<="), HOV(toBox(b))); | ||
|
|
||
| // Box toBox((Expression) `<Expression a> \< <Expression b>`) | ||
| // = H1(HOV(toBox(a)), L("\<"), HOV(toBox(b))); | ||
|
|
||
| // Box toBox((Expression) `<Expression a> == <Expression b>`) | ||
| // = H1(HOV(toBox(a)), L("=="), HOV(toBox(b))); | ||
|
|
||
| // Box toBox((Expression) `<Expression a> \>= <Expression b>`) | ||
| // = H1(HOV(toBox(a)), L("\>="), HOV(toBox(b))); | ||
|
|
||
| // Box toBox((Expression) `<Expression a> \> <Expression b>`) | ||
| // = H1(HOV(toBox(a)), L("\>"), HOV(toBox(b))); |
There was a problem hiding this comment.
Commented code; should we keep this?
There was a problem hiding this comment.
Does this PR contain a bootstrap of the parser? If so, why?
| * will do nothing if the formatter breaks syntax rules or introduces ambiguity. | ||
| * will never lose any comments. |
| import IO; | ||
|
|
||
| @synopsis{Styles for span classes generated by ((ToHTML))} | ||
| public str ToHTMLStyle() = |
There was a problem hiding this comment.
Can we align this with the other names in this module?
| public str ToHTMLStyle() = | |
| public str toHTMLStyle() = |



This is a redo of #2346 which was mangled due to a wrong use of git-filter-repo.
Rascal is a pretty big language so this pushes the new
toBoxandformatandlayoutDifffunctions to the max.toBoxrules such that the formatter produces beautiful layout, andtoBox,formatandlayoutDiffand fix them immediately.