mdenet / platformtools

Education platform tool functions.
Eclipse Public License 2.0
0 stars 3 forks source link

Xtext tool incorrectly generates project structure #70

Open szschaler opened 1 month ago

szschaler commented 1 month ago

The Xtext tool still makes wrong assumptions about how Xtext actually generates project structures. Specifically:

https://github.com/mdenet/platformtools/blob/6b1cb41c1d8a62ad51d379cd1288e126c9d4bea5/services/com.mde-network.ep.toolfunctions.xtext/src/main/java/com/mdenetnetwork/ep/toolfunctions/xtext/XtextTool.java#L73-L75

assumes that the baseName includes the name of the language (a Java classname) and, consequently, removes the last item of this qualified name. This is wrong and leads to deriving the wrong package names. Looking at https://github.com/eclipse/xtext/blob/main/org.eclipse.xtext.xtext.wizard/src/org/eclipse/xtext/xtext/wizard/RuntimeProjectDescriptor.xtend, baseName and languageName are used differently:

  1. baseName is the name of the Eclipse Xtext runtime project. Other projects then add additional sub-names to this name. As far as I can tell, it's not used for anything else. We could probably actually simply omit it and make the Xtext tool generate a generic baseName...
  2. languageName is the fully qualified name of the .xtext file (pretending for the moment that it was a class). In other words, its last element is a Java class name and everything before that is the so-called basePackage (defined in https://github.com/eclipse/xtext/blob/a189bea4cf97327ef221fa70d115ba8119e1b275/org.eclipse.xtext.xtext.wizard/src/org/eclipse/xtext/xtext/wizard/LanguageDescriptor.java#L48-L57). This is what's used to generate all the extra source files and to place the .xtext file inside the project structure. It's the only thing that matters...

Our code currently makes too much of baseName and uses languageName too little. This is wrong.

While this is getting fixed, there is a reasonable workaround for activities: given that the baseName really doesn't matter, as long as it's a Java qualified package name, one can simply add an artificial .foo to the end and make sure that the rest is the prefix of the languageName except the final segment.