Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Customizations required to make indent-based syntax work
Customizations required to make indent-based syntax work [message #1742973] Fri, 09 September 2016 00:56 Go to next message
Tatiana Fesenko is currently offline Tatiana FesenkoFriend
Messages: 62
Registered: July 2009
Member
Hello,

Xtext 2.8 introduced a great feature - support for indent-based syntax, or whitespace-aware languages. Thanks a lot for adding it to Xtext!

The documentation says that in order to support this feature one has to do these modifications:

  1. Add synthetic tokens to the grammar: a straightforward change;
  2. Adjust subclasses of the AbstractIndentationTokenSource to use the new synthetic tokens: really easy too;
  3. Customize the formatter: the RuleEngineFormatter from the suggested example project has 200+ line of code. So this change seems to be less obvious.


But the documentation does not say anything about any customizations for the following functionality:

  • Model serialization: save an in-memory model in the textual form;
  • Content-assist: if we allow different kinds of elements on different levels of indentation.


Do we need to add customizations to make serialization and content-assist work for indent-based grammar? Any special fragment in the MWE file? Or, maybe customizations in the code, e.g. extend a class which is tailored for this purpose?

Thanks in advance,
Tanya
Re: Customizations required to make indent-based syntax work [message #1743004 is a reply to message #1742973] Fri, 09 September 2016 10:27 Go to previous message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 557
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Tanya,

these are indeed interesting questions. I have extended the homeautomation example by a SerializerTest.

This shows that with enabled formatting during serialization the indentation is respected.

Different for content assist: Proposals for the XBlockExpression content are also proposed at the beginning of the line, although they would only be valid with proper indentation. Thus you have to customize the content assists for that.

If you feel that the customizations you do are more generic then please file a bug and we might have the chance to adopt it.

Thanks,
~Karsten
Previous Topic:Xsemantics: Tycho build issue with extended DSL
Next Topic:Xtend memory and speed issue
Goto Forum:
  


Current Time: Fri Dec 15 14:18:04 GMT 2017

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

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