xtend , Assignment Operator (=) overloading in xtend

Assignment Operator (=) overloading in xtend


Tag: xtend

I'm considering the use of xtend for a project that would benefit from its operator overloading, as that would greatly enhance readability of the code.

However what I didn't seem to come accross is assignment operator overloading. Did I miss it or doesn't it exist?

I'm not an expert but wouldn't that be technically just as feasible as the solution used for other operators like + that is mapped to e1.operator_plus(e2)?

Is assignment overloading something that is foreseen (when?) or is there a good reason not to support it (even in the future)?


No, it's not possible to overload the plain assignment operator =. It may be considered in the future, but would require architectural and semantical refinements.


How to remove debug information in its .class file (using xtend 2.x)

I noticed that when I updated xtend from 1.20 to 2.0, the .class file is significantly larger. One difference I saw is that there are debug information in the .class files which I do not really care for. There is also an additional entry in the .class file called SMAP....

Making for loop in xtend template, to print in same line

So if I have «FOR number: numbers» «number» «ENDFOR» It will print every number in new line, how do I make it print numbers in the same line?...

How to simulate a user's input (only internally)?

I need to parse something during the runtime of my eclipse plugin (created with Xtext) which would then be treated as if the user has typed it in but without actually popping up and beeing visible for the user as an input of himself. For exmample I have this input:...

How to get full return type forwarding in Xtend's Active Annotations?

I'm trying out Xtend's Active Annotations by writing a simple "Logged" annotation for tracing when methods have been called. Basically I want to write this in Xtend: @Logged override onCreate() { sampleFuncCall() } and get something like this in Java: @Override void onCreate() { Log.d("TAG", "onCreate started"); sampleFuncCall(); Log.d("TAG", "onCreate...

How to use GWTs JSNI with Xtend

I'm creating a GWT application and using Xtend. It seems that when Xtend compiles to Java, it removes comments, so when I try to use JSNI, it turns this: def native void publish() /*-{ // do some javascript stuff through JSNI }-*/; into this: public native void publish(); How can...

How can I return a list based on a condition on the referencing elements of the list

I want to return a list of elements of 'ListOfObjects' that are being referenced by 'SomeOtherObject' with it's(SomeOtherObject's) attribute satisfying the condition. I'm trying this code: ParentObj.ListOfObjects.select(e|e.referencingContainers.typeSelect(SomOtherObject).attr.isValid()); 'ListOfObjects' extracts a list of particular objects from the 'ParentObj'.But the above code gives me nothing. Please help me out in figuring out...

Xtend: Is there a counterpart to the Scala singleton object in Xtend

I'm absolutely new to Xtend, but browsing the documentation and searching the Web unfortunately didn't bring up a clear answer. I really do like the way one can define a singleton object in Scala. Is there a counterpart to this in Xtend or do I have to fall back to...

XTEND/JAVA automatic eclipse project generation

I have a XText project within Eclipse, with my own grammar file implemented. Using the doGenerate function I generate several .java files. So far everything works like a charm. My problem is that every time I generate my files I need to do the following: Copy the generated files to...

Assignment Operator (=) overloading in xtend

I'm considering the use of xtend for a project that would benefit from its operator overloading, as that would greatly enhance readability of the code. However what I didn't seem to come accross is assignment operator overloading. Did I miss it or doesn't it exist? I'm not an expert but...

How to get the error marker on a specific array element

I have written a validation which works fine but I want to know how I can set the error marker(the red line drawn underneath the input) at the proper position. The Problem is that the part of my grammar looks like that: Declaration: name = ID "=" singleContent=VarContent (OPERATOR nextCon+=VarContent)*...

Why does this warning testCase return an error?

I have written the following validation Rule: @Check def checkDeclarationIsNotReferenceToItself(Declaration dec) { if(dec.decCon.singleContent.reference == null && !dec.decCon.nextCon.isEmpty) { //only proceed if it is a reference return } var name = dec.name if(dec.decCon.singleContent.reference.name == name) { //only if the declaration is a self-reference without further actions var warningMsg = "The declaration...

How to initialize a variable dynamically in Xtend 2

This is what I've written in a Xtend class: def getEntityList(String indct, String criterion) { var entities Switch(indct){ case "PAR": entities = obj.getParamList.filter[definition.contains(criterion)] case "REF": entities = obj.getRefList.filter[definition.contains(criterion)] default: entities = null } return entities } As in the above code, entities is a raw list type the initialization of...

How to refer to an underlying element for the error method

I am looking for a possibitlity to refer to an element which is a bit deeper in the grammar in the error function. My grammar snippet looks like that: Declaration: name = ID "=" decCon=DecContent ; DecContent: singleContent=VarContent (op+=OPERATOR nextCon+=VarContent)* ; VarContent: (unOP=("+"|"-"))? num = NUMBER | string = STRING...

How to access the methods for a higher rule?

During writing validation rules a came across the problem that I need some content from a rule in my grammar which is hierarchically higher than the one I pass to my validationMethod. I know that I can refer to a "higher" rule with .eContainer but then I don't have a...

quickfix format using xtext

I am reading from the book "Implementing DSL with xtext and xtend" it says that formatter is invoked when of course the Format from the context menu is used or the shortcut for it "Ctrl + Shift + F" is used. It also says that "If you provide a custom...