Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Regression in Xtend 2.3.0M6
Regression in Xtend 2.3.0M6 [message #825909] Wed, 21 March 2012 12:10 Go to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6539
Registered: July 2009
Senior Member
Hi,

Just updated to M6 and it looks like the Xtend => Java translation is wrong.

I have a Java-Class like this:

LanguageManager {
public void addLanguage(String lang) {
//....
}
}

And call it in Xtend like this:


LanguageManager {
public void addLanguage(String lang) {
//....
}
}

def componentDefinition() '''
«FOR script : definition.scripts»
«languageManager.addLanguage(script.language)»

«ENDFOR»
'''


Now the generated code looks like this:

> for(final Script script : _scripts) {
> _builder.append("\t");
> String _language = script.getLanguage();
> void _addLanguage = languageManager.addLanguage(_language);

which is obviously wrong!

It looks like you are not checking the return-type of the call function
but blindly assign it to a variable ;-) I fixed the problem for me now
by return a boolean from addLanguage() but it is quite likely that you
others have such problems too!

Tom
Re: Regression in Xtend 2.3.0M6 [message #826282 is a reply to message #825909] Wed, 21 March 2012 22:21 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Thanks for the bug report. We'll fix this ASAP.

Am 3/21/12 8:10 AM, schrieb Tom Schindl:
> Hi,
>
> Just updated to M6 and it looks like the Xtend => Java translation is wrong.
>
> I have a Java-Class like this:
>
> LanguageManager {
> public void addLanguage(String lang) {
> //....
> }
> }
>
> And call it in Xtend like this:
>
>
> LanguageManager {
> public void addLanguage(String lang) {
> //....
> }
> }
>
> def componentDefinition() '''
> «FOR script : definition.scripts»
> «languageManager.addLanguage(script.language)»
>
> «ENDFOR»
> '''
>
>
> Now the generated code looks like this:
>
>> for(final Script script : _scripts) {
>> _builder.append("\t");
>> String _language = script.getLanguage();
>> void _addLanguage = languageManager.addLanguage(_language);
>
> which is obviously wrong!
>
> It looks like you are not checking the return-type of the call function
> but blindly assign it to a variable ;-) I fixed the problem for me now
> by return a boolean from addLanguage() but it is quite likely that you
> others have such problems too!
>
> Tom


--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Previous Topic:How to reuse base language formatter in extension language?
Next Topic:Using Xtend without Xtext
Goto Forum:
  


Current Time: Wed Apr 01 18:59:46 GMT 2020

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

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

Back to the top