Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Default behaviour changed from AbstractDeclarativeFormatter to AbstractFormatter2?
Default behaviour changed from AbstractDeclarativeFormatter to AbstractFormatter2? [message #1756075] Fri, 10 March 2017 16:05 Go to next message
Florian Schwarz is currently offline Florian SchwarzFriend
Messages: 4
Registered: March 2017
Junior Member
Hi,

I have a very simple DSL file to set various simple settings for code generation. E.g.
generatorSettings: Ecf1LfExtractionGenSettings {
	componentSettings: Ecf1LfExtractionGenComponentSettings {
		generateMetaInfo: true;
		generateProcess: false;
		generateServices: false;
		generateWsdl: false;
		generateTraverser: notSet&;
		initObjectsInFactory: true;
		prefix: "PREFIX_";
		...
	}
}

With the old formatting API I just had to take care of the indentation after the brackets and the AbstractDeclarativeFormatter inserted automatically one space after each of my keywords. E.g.
generateWsdl:false;

was formatted as
generateWsdl: false;

With the new AbstractFormatter2 it seems to me that I have to append the spaces after each keyword by myself. Since I have many keywords, is there any possibility to implement the formating in a generic way by iterating over all keywords? I couldn't find any method which returns all keywords from my grammar (of course I could use reflection to extract all keywords from my GrammarAccess object, but I would prefer a cleaner solution).

Best regards
Florian
Re: Default behaviour changed from AbstractDeclarativeFormatter to AbstractFormatter2? [message #1756076 is a reply to message #1756075] Fri, 10 March 2017 16:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 10319
Registered: July 2009
Senior Member
Hi, have a look at org.eclipse.xtext.GrammarUtil.getAllKeywords(Grammar)
(the grammar you get via org.eclipse.xtext.IGrammarAccess.getGrammar())
Re: Default behaviour changed from AbstractDeclarativeFormatter to AbstractFormatter2? [message #1756159 is a reply to message #1756076] Mon, 13 March 2017 09:43 Go to previous message
Florian Schwarz is currently offline Florian SchwarzFriend
Messages: 4
Registered: March 2017
Junior Member
Hi Christian,

thank you very much, that was exactly what I was looking for.

Best regards
Florian
Previous Topic:Formatting Expressions
Next Topic:Method not found in enclosing type
Goto Forum:
  


Current Time: Fri Mar 24 22:10:10 GMT 2017

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

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