Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Don't create Xtend classes with the same name as data rules
Don't create Xtend classes with the same name as data rules [message #1639194] Fri, 27 February 2015 14:06 Go to next message
Gary Worsham is currently offline Gary WorshamFriend
Messages: 176
Registered: September 2013
Senior Member
I first got my DSL working, with no small amount of help from folks on this forum, about 18 months ago. Since that time I've spent only a small amount of time updating and maintaining the DSL, so naturally I've forgotten quite a bit about how it all works.

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!

[Updated on: Fri, 27 February 2015 14:06]

Report message to a moderator

Re: Don't create Xtend classes with the same name as data rules [message #1663911 is a reply to message #1639194] Tue, 10 March 2015 16:56 Go to previous message
Stefan Oehme is currently offline Stefan OehmeFriend
Messages: 159
Registered: April 2010
Location: Kiel
Senior Member

Hey Gary,

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.

Cheers,
Stefan
Previous Topic:Access members of JvmTypeReference
Next Topic:Cross-referencing overloaded methods of a DSL program
Goto Forum:
  


Current Time: Fri Apr 23 09:23:08 GMT 2021

Powered by FUDForum. Page generated in 0.01751 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top