|
|
|
Re: Indent block of statements [message #1721301 is a reply to message #1721286] |
Tue, 26 January 2016 12:37 |
Moritz Eysholdt Messages: 161 Registered: July 2009 Location: Kiel, Germany |
Senior Member |
|
|
hi Anakreontas,
there may be several misunderstandings here
about indentation: Indentation is only applied when the formatter decided to insert one or more newLines. Basically, whenever the formatter does a newLine it also checks what the current indentation level for that line is an applies the indentation. That's important to unterstand because "noSpace" does not do a newLine (as the name indicates). Also setNewLines(0, 1, 1) does not force the formatter to insert a newLine either, because the first parameter (0) tells the formatter that for the current HiddenRegion at least zero newLines are required.
Quote:My understanding is that the formatting rule above is applied on the region corresponding to the Statement (in the examples that would be 'line1'). The rule is not concerned with indentation spaces proceeding the statement region. Therefore the final result would be:
[indentation space because of format(StatementGroup)][remove any spaces][statement region][remove trailing spaces][at most one new line]
not quite. When you put multiple formatting instructions between two SemanticRegions (non-whitespace-text) they're being merged, not concatenated. See
org.eclipse.xtext.formatting2.internal.HiddenRegionFormatting.mergeValuesFrom(IHiddenRegionFormatting)
for how the merging works.
Also, the characters that are within the same IHiddenRegion are by default whitespace, tabs, *and* newLines.
Consequently, in your example { statement1 statement2 } there is only *one* IHiddenRegion between statement1 and statement2. Thus doing append() on statement1 affects the *same* hiddenRegion as doing prepend() on statement2.
To be on the safe side, you may try
s.append[setNewLines(1, 1, 1)]
|
|
|
|
|
|
Re: Indent block of statements [message #1809868 is a reply to message #1721448] |
Thu, 25 July 2019 05:47 |
|
Hi Anakreontas,
as you mentioned above, you successfully configured the Formatter to use spaces instead of tabs for indentation.
Could you please share the code snippet how to do that?
Thanks in advance,
Tamás
|
|
|
Powered by
FUDForum. Page generated in 0.03920 seconds