Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

114: EMF generator generations fails #118

Merged
merged 3 commits into from
Jan 18, 2022
Merged

Conversation

CamilleLetavernier
Copy link
Member

  • Fix the backend product configuration

There is still an issue with the code generator: it only works once. There are several causes (yet to be investigated):

  • EMF Code is generated as an Eclipse Project, with associated metadata (.metadata/, .project). If the .project is removed, the project becomes invalid and the generation will fail (Workaround: also delete .metadata/ to start on a clean Eclipse Workspace)
  • If the .metadata/.project are still present, the generator fails with a NPE

This is mostly related to this old issue from the archived repo: #117

It would make it easier to separate the Backend/EMF Workspace from the Theia Workspace, and that would cause less interferences

@CamilleLetavernier
Copy link
Member Author

The new commit fixes the instabilities with Codegen, and improves the UI (added a context menu on *.genmodel files to trigger the generation, clarified some parameters, ...)

Copy link
Contributor

@ndoschek ndoschek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Camille! The genmodel generation works great for me, also the additional descriptions in the quick input field are a good improvement.

Regarding the code generation:

  • If I trigger the the code generation on a newly created genmodel, the src folder is created outside the model folder in my case (pls see the attached screenshot). I assume this should be located inside the model folder, right?

image

  • Also, the files in the generated src folder are not listed in .gitignore - should we add the generated sources folder here?

One other question regarding the codegen backend app:
I tried to start the org.eclipse.emfcloud.ecore.codegen.product but I get the following error. Did I miss something here or are there additional settings needed? If so, it would be great if we could offer a launch config as for the Ecore-GLSP App.

!ENTRY org.eclipse.osgi 4 0 2021-12-07 17:33:22.988
!MESSAGE Application error
!STACK 1
java.lang.IllegalArgumentException: Expected argument: genmodel path; got []
	at org.eclipse.emfcloud.ecore.backend.app.CodegenApplication.start(CodegenApplication.java:38)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:654)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1462)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1435)

@ndoschek ndoschek linked an issue Dec 7, 2021 that may be closed by this pull request
@CamilleLetavernier
Copy link
Member Author

If I trigger the the code generation on a newly created genmodel, the src folder is created outside the model folder in my case (pls see the attached screenshot). I assume this should be located inside the model folder, right?

I changed it to a path relative to the Theia workspace; so it's now more consistent with how it works in Eclipse. The expected genmodel path is //. We need to include the project, because GenModel can generate 4 different projects/plug-ins (Although we only support one at the moment): Java, Edit/Editor, and Tests. Each project uses its own path.

So, if you only specify src, it assumes that "src" is the target project, and will create it at the root of the workspace (That's why I clarified the descriptions of the parameters :D )

Also, the files in the generated src folder are not listed in .gitignore - should we add the generated sources folder here?

For the example workspace, yes; it would make sense. However... I'm not sure what to add in the .gitignore. I usually don't commit anything from the workspace. Excluding src/ might be too much (why src/ and not src-gen/ ?). And if a users want to play with the tool a bit, it could be confusing to see some changes (ecore, genmodel) and not others (generated java code). So I'm not really sure I want to change anything in the gitignore.

One other question regarding the codegen backend app:
I tried to start the org.eclipse.emfcloud.ecore.codegen.product but I get the following error. Did I miss something here or are there additional settings needed?

We don't use this product like the other ones. It is copied to the Theia backend during build (theia-ecore/build), and Theia can start it directly when Codegen is triggered (With the appropriate arguments). We want to merge it with the Modelserver at some point (Add 3 new endpoints there, for Ecore/GenModel/Codegen), but that will be covered in #117 (Sometime :) )

Until then, this application is not meant to be manually started; it's started via EcoreFileGenServer in ecore-file-generation.ts. It starts, executes codegen (or file creation), and then stops again.

@CamilleLetavernier
Copy link
Member Author

fixes #13 fixes #12

@ndoschek
Copy link
Contributor

ndoschek commented Dec 9, 2021

If I trigger the the code generation on a newly created genmodel, the src folder is created outside the model folder in my case (pls see the attached screenshot). I assume this should be located inside the model folder, right?

I changed it to a path relative to the Theia workspace; so it's now more consistent with how it works in Eclipse. The expected genmodel path is //. We need to include the project, because GenModel can generate 4 different projects/plug-ins (Although we only support one at the moment): Java, Edit/Editor, and Tests. Each project uses its own path.

So, if you only specify src, it assumes that "src" is the target project, and will create it at the root of the workspace (That's why I clarified the descriptions of the parameters :D )

Oh I see, if using the entry Generate EMF Generator Model... everything is described very well and behaves accordingly 👍
I still think if the genmodel is generated via the entry Generate EMF Generator Model without user options, it would be great if the default code gen path would be set to statemachine/model/src for example, instead of only src. I checked how it is done in Eclipse, and there they use the genmodel path and add the src directory to that path by default in my case.

For the example workspace, yes; it would make sense. However... I'm not sure what to add in the .gitignore. I usually don't commit anything from the workspace. Excluding src/ might be too much (why src/ and not src-gen/ ?). And if a users want to play with the tool a bit, it could be confusing to see some changes (ecore, genmodel) and not others (generated java code). So I'm not really sure I want to change anything in the gitignore.

Ah you're right, thats true of course - then I'll agree to leave it like that.

We don't use this product like the other ones. It is copied to the Theia backend during build (theia-ecore/build), and Theia can start it directly when Codegen is triggered (With the appropriate arguments). We want to merge it with the Modelserver at some point (Add 3 new endpoints there, for Ecore/GenModel/Codegen), but that will be covered in #117 (Sometime :) )

Until then, this application is not meant to be manually started; it's started via EcoreFileGenServer in ecore-file-generation.ts. It starts, executes codegen (or file creation), and then stops again.

Alright, that's fine then for me then :)

@CamilleLetavernier
Copy link
Member Author

I still think if the genmodel is generated via the entry Generate EMF Generator Model without user options, it would be great if the default code gen path would be set to statemachine/model/src for example, instead of only src. I checked how it is done in Eclipse, and there they use the genmodel path and add the src directory to that path by default in my case.

Ah! I knew I was missing something, but I couldn't figure out what :) Indeed, the parameter-less version needs to be updated with a more appropriate value. I'll push an update.

- Add a context menu on Genmodel files to make sure we have the correct
input
- Clarify the arguments for Genmodel and Codegen
- Reconcile the genmodel before re-generation
- Compute a valid value for the java source folder, when creating a
default GenModel (without explicit parameters)
@CamilleLetavernier
Copy link
Member Author

I've updated the PR to use a better default value for the Java source folder. It currently takes the root project, and appends src-gen/

So if your model is located in:

~/myproject/models/myModel/example.ecore

The java source folder will be

~/myproject/src-gen/

Copy link
Contributor

@ndoschek ndoschek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update Camille, looks great to me! 🎉

@CamilleLetavernier CamilleLetavernier merged commit f0be1ae into master Jan 18, 2022
@@ -32,6 +32,7 @@
</features>

<configurations>
<plugin id="org.apache.felix.scr" autoStart="true" startLevel="2" />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is relevant to solve the NPE described in #114

Caused by: java.lang.NullPointerException
at org.eclipse.core.internal.resources.CharsetDeltaJob.startup(CharsetDeltaJob.java:212)
at org.eclipse.core.internal.resources.CharsetManager.startup(CharsetManager.java:505)
at org.eclipse.core.internal.resources.Workspace.startup(Workspace.java:2484)
at org.eclipse.core.internal.resources.Workspace.open(Workspace.java:2231)

@ndoschek ndoschek deleted the issues/114-codeGen branch December 1, 2022 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants