Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » "Partial" Formatting
"Partial" Formatting [message #629509] Tue, 28 September 2010 14:22
Christoph ZwickerFriend
Messages: 16
Registered: April 2010
Junior Member
Hi,

I have a problem with the way the formatting of a region is handled in org.eclipse.xtext.formatting.impl.NodeModelStreamer. When I try to format a part of the source which should be indented, it is not. Naturally, I thought this was due to my implementation of the ITokenStream written to, but reading the code in NodeModelStreamer, I just can't figure out how this might actually work.

What I figure is the following: when searching for the correct leaf nodes to base the formatting on in getLeafs, the first leaf found will be the first one formatted and also the first one to be passed to the ITokenStream doing the actual formatting. And as this is the place where the information necessary to calculate the necessary indentation, I don't see how this information might be deduced.

Imho, the easiest way to do "region" formatting would be to format the source from the beginning, reset the buffer in ITokenStream (introduce e.g. a reset method) when the offset of the first "semantic" node to be written is reached and then just continuing until the length to be formatting is covered. Wouldn't that work?

Still better, the whitespace between the last "semantic" node not written and the first one written could be formatted according to the rules, so that the "maximum" rule for linewrap locators is preserved (imagine we have a rule saying we need two linewraps before the first "semantic" node formatted, there are already two empty lines before the region to format, but none of this whitespace is selected, two lines are still inserted)...

Thanks,
Chris
Previous Topic:xbase
Next Topic:How invoke .chk / CheckComponent from MWE2
Goto Forum:
  


Current Time: Fri Apr 26 09:10:44 GMT 2024

Powered by FUDForum. Page generated in 0.03244 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top