Closed lucaswerkmeister closed 9 years ago
Hm, perhaps the current line break model isn’t expressive enough… if the original line breaks are available, we do want to permit 0..3 line breaks between bodies / statements (trailing comments), but we can currently only influence what happens without tokens by changing the order of that range (first element is picked), and while 0 is not enough, 3 is too much :/
EDIT: The same goes for statements. Range 0..2, but a blank line between all statements is too much as well.
One hacky fix would be to use
lineBreaksAfter = tokens exists then 0..3 else 1..0;
for the line breaks
{
,}
,}
(using 2..0
here perhaps), and;
.I don’t like how this undermines the abstraction from FormattingWriter
, but since it’s restricted only two functions (visitBody
, writeSemicolon
), I could probably live with it.
Done, good enough for 1.1.0 at least.
In absence of a token stream, toplevel declarations are formatted without any line breaks between them, like this:
(from
ceylon.ast
’scompleteCompilationUnit
).