Questions tagged [xtend]

Xtend is a statically typed programming language that transcompiles to Java. It aims to produce more readable code than traditional Java.

Xtend is a programming language that transcompiles to Java. It aims to produce more readable code than traditional Java by reducing the amount of boilerplate code. It is developed by the Eclipse foundation.

415 questions
2
votes
2 answers

Example for xtend toEnumerateType / generate Java enum via xtend?

I need to generate Java enums via DSL, using xtend 2.5. My grammar looks something like this: grammar de.mytest.xtext.enumdsl.EnumDsl with org.eclipse.xtext.xbase.annotations.XbaseWithAnnotations import "http://www.eclipse.org/emf/2002/Ecore" as…
mimo
  • 23
  • 7
2
votes
0 answers

Xtend compilation issue (bug?): Type mismatch: cannot convert from AppController to AppController

I have an Eclipse project which is set up to work with EMF and Xtend. I does work, however, I am experiencing some weird compilation issues that I am unable to resolve. Again I want to stress, that the code I am using does in fact work, but I have…
Fhl
  • 1,079
  • 1
  • 12
  • 26
2
votes
0 answers

JUnit error: com.google.inject.CreationException: Guice creation errors

I'm getting an error when trying to do unit testing of a DSL parser with Xtext and Xtend. I'm using com.google.inject.Inject and then I do a @Inject extension ParseHelper. This is basically the error: at…
imendoza03
  • 21
  • 1
2
votes
1 answer

XText w/ XBase - Initialize generated variable

I'm using Xtext with XBase grammar. In every generated java class I need to initialize class variable in my model inferer. This variable isn't defined in my model, but that makes no difference. I already can generate this variable via…
borism
  • 119
  • 2
  • 15
2
votes
1 answer

Xtend: Create string list

How do I create a variable with type List in Xtend? var list = Lists::newArrayList() list.add( "xxx" ) doesn't work; the type in the add() isn't propagated back. var list = Lists::newArrayList() as List gives an exception at…
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
2
votes
2 answers

java expressions with binary operators in xbase not working

I'm using xbase grammar xolang.Xolang with org.eclipse.xtext.xbase.Xbase and an XBlockExpression where I expect to write my code When write an expression like val c = 1 + 1 Then I get the following error The method +(int) is undefined The same…
tgoossens
  • 9,676
  • 2
  • 18
  • 23
2
votes
1 answer

sprintf equivalent for xtend

Is it possible to format strings in xtend? I am looking for something just like sprintf in C. I tried using the String.format in java but I don't know why it is not available in xtend. Maybe, they have something similar?
chris yo
  • 1,187
  • 4
  • 13
  • 30
2
votes
1 answer

xtend2 code generation with ecore meta-model

I created an ecore-Metamodel, a genmodel and a corresponding model. Now I want to generate Code from this. I found this post and wanted to implement it. I get no errors and so on, but how do I bring the CodeGenerator to generate the wanted output in…
Iron
  • 477
  • 4
  • 19
2
votes
1 answer

How to implement the generation gap pattern for xText?

Currently I'm modifying a project that uses xText to parse a custom DSL. I want to add functionality to the generated classes but unfortunately I failed implementing the generation gap pattern. I used this article as a…
Lichtblitz
  • 213
  • 2
  • 10
2
votes
1 answer

Xtend Elvis ?: operator doesn't work as expected

I'm using Xtend to write an Android app, and I wanted to use the elvis operator to simplify the following (which works): val c = if (projection != null) new MatrixCursor(projection) else new MatrixCursor(#[MediaStore$MediaColumns::DISPLAY_NAME,…
Randy Sugianto 'Yuku'
  • 71,383
  • 57
  • 178
  • 228
2
votes
3 answers

how to use the script xtext name in generator

I want to use the script-name in the generator to create the corresponding java file. For example if my script file would be "WordCount.script" I want to create a "WordCount.java" file. I found out the previous versions exposed this via…
moin moin
  • 2,263
  • 5
  • 32
  • 51
2
votes
2 answers

Xtend and Arrays

Does xtend support two-or more dimensional arrays? If yes: How can i create one and use it later on? I want to store Strings in these arrays and pass it to the files.
user1104033
2
votes
1 answer

How to use Xtext(M2M with Xtend) and GMF to create diagramm? (Beginner)

I have started to work with Eclipse and I'm still a beginner. So I want to get some help from here. I use Xtext to read my DSL. And then I want to show the instance with a diagram, which I have already defined with GMF. But the ecore(MFilesystem)…
JSommer
  • 21
  • 1
2
votes
1 answer

Call a template expression from another in XTend

i have a question about calling template expression methods from another template expression. The example below didn't work, ie. it doesn't expand and 'prints' the code on the spot it was called. How can I modify this code to print the result of…
Marten Sytema
  • 1,906
  • 3
  • 21
  • 29
2
votes
2 answers

Xtend tip: how do I access a static method within a Java interface inner class?

// java interface MyInterface { class MyInnerClass { public static final String myInnerStaticMethod() { return "myInnerStaticMethod"; } } } How can I call this from an Xtend method?
Ghiro
  • 500
  • 1
  • 4
  • 11