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
0
votes
2 answers

How to specify target type for collection literals?

I'm trying to use a target type to specify a collection literal's type: val java.util.HashMap map = #{ 'a' -> 'b' } But I get: HelloWorld.java:212: error: incompatible types: Set cannot be converted to…
Kelvin
  • 20,119
  • 3
  • 60
  • 68
0
votes
1 answer

Xtend Syntax Content Assist

I'm trying to make a content assist in my RCP application. For that, I'm using Xtend and AbstractJavaBasedContentProposalProvider. So, I made my AbstratMyDSLProposalProvider and now I'm writting the MyDSLProposalProvider class. Below, the xtend file…
alexmouth
  • 11
  • 3
0
votes
2 answers

Escape single quote in Xtend template expression

I have a very simple question, but could not figure it out by Google search, please help. I want to produce this string '\u0000' (note the simple quote marks surrounding it!) using the following simple Xtend method containing a template…
Software Craftsman
  • 2,999
  • 2
  • 31
  • 47
0
votes
1 answer

Xtext. Get object by string name

Has some lang like this. language sample.linking.SampleLang; generate SampleLang "http://sample/linking/samplelang/v1" Model: entity_node = Entity ; Entity: type = ('blabla1' | 'blabla2') ':' name = ID (annotation = Annotation)? '{' …
ArchCC
  • 83
  • 9
0
votes
1 answer

Cannot compile XTend classes in Intellij

I am trying to make a basic program using XTend for Intellij 15.0.5 (Ultimate) but for some reason I cannot run/compile any ".xtend" files. Writing the following code is no problem and the ide checks for syntax errors as expected: package…
0
votes
1 answer

How can I ensure that required imports are included in java output generated by Xtend active Annotation Processor?

I am building an active annotation to get rid of some boilerplate from my Xtend source files. The following is the snippet of the source code of my AbstractFieldProcessor. package dynamic import java.lang.annotation.ElementType import…
KennyBartMan
  • 940
  • 9
  • 21
0
votes
1 answer

Xtext 2.9 RuntimeModule

I am trying to implement implicit import mechanism in my dsl (named ADSL). To do this I am following the approach applied to SmallJava example some 3 years ago, which is available here: SmallJava source folder. My dsl is very similar to SmallJava,…
Marina
  • 15
  • 4
0
votes
1 answer

Resolving variables in my DSL from an external source

I'm new to working with Xtext and Xtend and I have stumbled upon a problem which I hope someone can help me solve. What I'm trying to achieve is to resolve variables from an external source rather than declaring them explicitly in the DSL. I got the…
Matt Immer
  • 327
  • 1
  • 13
0
votes
1 answer

Xtext 2.8+ formatter, formatting HiddenRegion with comment

I am using Xtext 2.9 formatter and I am trying to format hiddenRegion which contains comment. Here is part of my document region i am trying to format: Columns: 1:offset 2:length 3:kind 4: text 5:grammarElement Kind: H=IHiddenRegion…
Smarty77
  • 1,208
  • 3
  • 15
  • 30
0
votes
1 answer

Xtend creating variable of explicit type

I want to go over list of objects of type Expression and pick last of them, however I am unable to do this, because Xtend has implicit type inference. var myexp= null for (statement : statements) { if (statement instanceof something) …
Smarty77
  • 1,208
  • 3
  • 15
  • 30
0
votes
1 answer

Xtext 2.8+ formatter, formatting simple rule

I am Xtend/Xtext newbie. Currently I am working with new formatter API, and i am trying to format rule, which looks like this: Expression: Error|Warning|Enum|Text ; with xtend dispatch method like this def dispatch void format(Expression e){ …
Smarty77
  • 1,208
  • 3
  • 15
  • 30
0
votes
1 answer

Retrieve Annotation from AnnotationReference and create dispatch methods

Is it possible to create dispatch methods over Annotations. I'm trying to create the following scenario: def generateField(FieldDeclaration field, ClassDeclaration clazz) { ''' «field.annotations.map[it.generateAnnotation(field)].join» …
aphex
  • 3,372
  • 2
  • 28
  • 56
0
votes
1 answer

Xtext: cannot be resolved to a type

I have strange error in my code: import dsltest.models.Plant import dsltest.controllers.PlantController.create package dsltest.assemblers { assembler PlantAssembler : Plant { state CREATES create => PENDING end state…
0
votes
2 answers

Xtend: Generators produce comma instead of point

I am using template expressions for generating files. For example: def generateStuff(MyObject in) { ''' This is the wrong value: «calculatedoubleValue(in.doubleValue)» ''' } The value of doubleValue is an double. But the generator…
John
  • 795
  • 3
  • 15
  • 38
0
votes
0 answers

Xtend: Generate Switch Case

I need to generate switch case inside a method. Something like this: switch(phr){ case PENDING_CONFIRMATION: phrResource.add(new ExtendedLink(linkTo( methodOn(PHRController.class).rejectPhr(phr.getId())) …