Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsDon't create Xtend classes with the same name as data rules
https://www.eclipse.org/forums/index.php/mv/msg/1016195/1639194/#msg_1639194
I have created a bunch of data rules, and since my main code generator Xtend was getting quite huge, I created a bunch of new Xtend classes that handled the various code generation tasks for those specific data rules.
Somewhere along the line I got confused and gave the class the same name as my data rule. Eclipse did not complain about this, so I didn't realize I'd made a mistake until my program started acting very bizarre. The class name checking for Xtend in Eclipse doesn't seem as thorough as when writing just in Java.
For example, I have a data type rule called:
SpinComboBox
in my Xtext grammar definition.
Down in code generation Xtend, I created a SpinComboBox.xtend and within this, a class SpinComboBox. BIG MISTAKE!
I also noticed that in Xtend, I can create a file such as spcbComboBox.xtend, and within it create a class zorpComboBox and it doesn't seem to matter. In Java I'm used to file names and class names wanting to be the same, but I'm not sure if this is just a convention to reduce confusion or actually required.
I don't have a question here... just some observations. Xtext and Xtend solved a really difficult problem I had in a really great way, but it was not easy getting there. Most problems I see raised on this forum are way past anything I ever did.
Cheers!]]>Gary Worsham2015-02-27T14:06:09-00:00Re: Don't create Xtend classes with the same name as data rules
https://www.eclipse.org/forums/index.php/mv/msg/1016195/1663911/#msg_1663911
I have good news: Duplicate name validation is there in Xtend 2.8 =)
Regarding the naming convention: You are right, Xtend does not enforce typeName==fileName. We could add some optional validation to make it as strict as Java. Feel free to file an enhancement request for that.