xpand extension with xpand doesnt work as expected? [message #757653] |
Mon, 21 November 2011 01:44  |
Eclipse User |
|
|
|
Following the docs I created a file EntityExtensions.xtend:
package com.emsgmbh.appgen.generator
import com.emsgmbh.appgen.persistence.persistence.Entity
public class EntityExtensions {
def tablename(Entity e) {
return "abc";
}
}
Then I added to my Generator.xtend:
...
import static extension com.emsgmbh.appgen.generator.EntityExtensions.*
...
but the new method tablename() couldn't be seen for an Entity object. Looking at the generated Java code showed me that the method tablename(Entity e) is not a static method, which is a plausible reason.
After my first approach failed, I tried to inject - in my generator I wrote:
...
import com.google.inject.Inject
class PersistenceOracleGenerator implements IGenerator2 {
@Inject EntityExtensions
which ended in a syntax error, as he expected an alias after the extension class.
After changing to
@Inject EntityExtensions eext
I was able to write
... Entity e ...
eext.tablename(e)
but not
... Entity e ...
e.tablename()
what I expected. Isn't it possible to write such an xtend extension in xtend?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: xpand extension with xpand doesnt work as expected? [message #758201 is a reply to message #757678] |
Tue, 22 November 2011 05:19  |
Eclipse User |
|
|
|
Please make sure that you use the latest version (2.1.1) of Xtend.
Regards,
Sebastian
--
Need professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
On Mon, 21 Nov 2011 10:02:32 +0100, Tilo Thiele
<forums-noreply@eclipse.org> wrote:
> Christian Dietrich wrote on Mon, 21 November 2011 03:58
>> @Inject extension EntityExtensions !!!!
>
>
> This ends up in an syntax error:
>
>
> Description Resource Path Location Type
> no viable alternative at input
> 'override' PersistenceOracleGenerator.xtend /com.emsgmbh.appgen.persistence/src/com/emsgmbh/appgen/generator line:
> 16
> /com.emsgmbh.appgen.persistence/src/com/emsgmbh/appgen/generator/PersistenceOracleGenerator.xtend Xtext
> Check (fast)
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.07668 seconds