Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » new formatting API and Xbase inherited grammar
new formatting API and Xbase inherited grammar [message #1707681] Tue, 08 September 2015 13:30 Go to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

in my DSL inheriting from Xbase I redefine the XCatchClause rule nothing
special:

XCatchClause :
=>'catch' '(' declaredParam=FullJvmFormalParameter ')'
expression=XBlockExpression;

instead of

XCatchClause :
=>'catch' '(' declaredParam=FullJvmFormalParameter ')'
expression=XExpression;

The new formatting API does not seem to work with catch clause: if you
consider this method in the XbaseFormatter

def dispatch void format(XCatchClause expr, extension
IFormattableDocument format) {

expr.regionForKeyword("catch").append(whitespaceBetweenKeywordAndParenthesisML)

regionForKeyword is not applied since this method returns null

@Override
public ISemanticRegion regionForKeyword(EObject owner, String keyword) {
AbstractEObjectTokens tokens = eObjectToTokens.get(owner);
if (tokens == null)
return null;
for (ISemanticRegion token : tokens.getTokens()) {
AbstractElement element = token.getGrammarElement();
if (element instanceof Keyword) {
Keyword kw = (Keyword) element;
if (kw.getValue().equals(keyword))
return token;
}
}
return null;
}

indeed there seem to be no token in the map associated to the
XCatchClause object...

am I missing something?

thanks in advance
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: new formatting API and Xbase inherited grammar [message #1707731 is a reply to message #1707681] Tue, 08 September 2015 20:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi the formatter is still buggy. Can you check if this one helps https://www.eclipse.org/forums/index.php/t/1068949/

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: new formatting API and Xbase inherited grammar [message #1707856 is a reply to message #1707731] Wed, 09 September 2015 18:39 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 08/09/2015 22:27, Christian Dietrich wrote:
> Hi the formatter is still buggy. Can you check if this one helps
> https://www.eclipse.org/forums/index.php/t/1068949/

Hi

Yes, this fixes the problem:

XCatchClause :
{XCatchClause} =>'catch' '(' declaredParam=FullJvmFormalParameter ')'
expression=XBlockExpression;


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: new formatting API and Xbase inherited grammar [message #1707866 is a reply to message #1707856] Thu, 10 September 2015 05:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
@lorenzo can you file a ticket as well to make sure it gets fixed

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: new formatting API and Xbase inherited grammar [message #1708069 is a reply to message #1707866] Sat, 12 September 2015 07:43 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 10/09/2015 07:19, Christian Dietrich wrote:
> @lorenzo can you file a ticket as well to make sure it gets fixed

done: https://bugs.eclipse.org/bugs/show_bug.cgi?id=477254

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Previous Topic:[Xtext] Embedding ANTLR code into XText?
Next Topic:[2.7.0] Guice errors when unit-testing the generator
Goto Forum:
  


Current Time: Thu Apr 25 15:04:03 GMT 2024

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

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

Back to the top