Bug 492303

Summary: Activator in ui project isn't generated properly with customized project names
Product: [Modeling] TMF Reporter: Niek Hulsman <niek.hulsman>
Component: XtextAssignee: Karsten Thoms <karsten.thoms>
Status: ASSIGNED --- QA Contact:
Severity: normal    
Priority: P3 CC: christian.dietrich.opensource, karsten.thoms, m1imueller, tmf.xtext-inbox
Version: 2.9.0Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Windows 8   
Whiteboard:
Attachments:
Description Flags
Sample project
none
Screenshot none

Description Niek Hulsman CLA 2016-04-23 09:52:23 EDT
Created attachment 261192 [details]
Sample project

The Activator package and class name are wrongly generated, when i change the project names from the standard org.company.mydsl to for example company-dsl and change the plugin project names accordingly.

The name of the Activator becomes: Company-lang-uiActivator instead of LangActivator. I've included a sample project as attachment.

The configuration looks like this:

configuration = {
			project = StandardProjectConfig {
				baseName = "company-lang"
				rootPath = rootPath
				genericIde = {
					name = "company-lang-ide"
				}
				eclipsePlugin = {
					enabled = true
					 name = "company-lang-ui"
				}
				createEclipseMetaData = true
			}
			code = {
				encoding = "UTF-8"
				fileHeader = "/*\n * generated by Xtext \${version}\n */"
			}
		}
Comment 1 Karsten Thoms CLA 2016-09-21 03:39:39 EDT
Created attachment 264299 [details]
Screenshot

This shows what is generated.
Comment 2 Karsten Thoms CLA 2016-09-21 04:07:59 EDT
A basic problem is here that the UI Activator is generated only once and there could be multiple languages defined in the workflow.

The method that computes the activator name is org.eclipse.xtext.xtext.generator.XtextGeneratorNaming.getEclipsePluginActivator()

It is the only naming method that is not grammar dependent.

One possible solution is to provide a grammar specific version of the method and use always the grammar of the first language defined.
Comment 3 Christian Dietrich CLA 2017-07-27 06:40:25 EDT
@Karsten what do you think about

new TypeReference(pluginName.replaceAll("-","_") + '.internal', activatorName.replaceAll("-","_"))

as proposed here:

https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html