[Xtend2] Problems with method modifiers [message #665590] |
Fri, 15 April 2011 04:02  |
Eclipse User |
|
|
|
2 questions, one about method visibility and the other about generating
static methods
1)I have problems when adding visibility modifiers in xtend2 files.
public generate(){''''''} reports:
Couldn't resolve reference to JvmType 'public'.
Incompatible implicit return type. Expected void but was
org.eclipse.xtext.xtend2.lib.StringConcatenation
public StringConcatenation generate(){''''''} reports:
Couldn't resolve reference to JvmType 'public'.
Incompatible implicit return type. Expected void but was
org.eclipse.xtext.xtend2.lib.StringConcatenation
extraneous input 'generate' expecting '('
Also tried with the '^' character but without success
According to online help, I could declare a method as protected or
private, but neither works (same errors)
2)In the specifications it is not mentioned the possibility to generate
in xtend2 static method (although you can import static). The reason I'm
asking is that I have a really big xtend file (little more than 1000
rows) and template validation/compilation/linking is awfully slow.
I noticed that things really speed up if I work by splitting the big
template in "modules" and import them statically in a sort of 'master
template'. the only thing making this impossible is that 'static'
keyword is not recognized. Is there a reason for this?
many thanks
Alex
|
|
|
|
|
|
|
Re: [Xtend2] Problems with method modifiers [message #728052 is a reply to message #727721] |
Thu, 22 September 2011 09:09  |
Eclipse User |
|
|
|
Hallvard Traetteberg wrote on Wed, 21 September 2011 23:16You can combine @Inject with extension and get the effect you want:
@Inject extension SomeClass
Since you don't need the field name in the call, you can omit it in the
declaration.
Hallvard
Thanks, I didn't see this option. BTW, there seem to be different versions of Xtend2 syntax, neither the "as" syntax mentioned before, nor omitting the field name worked for me, but that's a minor issue.
Oliver L wrote on Thu, 22 September 2011 14:55
Sometimes it's not possible to impact the creation of an instance of an Xtend class. As the class is not instantiated by Guice MyXtendClass is not injected. Defining static methods in Xtend would bypass this problem, I think.
I agree. So far my experience with Guice in Xtext isn't all sunshine and roses so I'd prefer using less injection rather then more.
thanks for your replies,
Stephan
[Updated on: Thu, 22 September 2011 09:11] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.05384 seconds