XText File Relying on outside EMF Models [message #1795523] |
Mon, 24 September 2018 16:32 |
Mehmetcan Sinir Messages: 55 Registered: September 2018 |
Member |
|
|
I am developing an Xtext Grammar, which I am going to then build into a language server, with which I will build an extension for VS Code, NOT ECLIPSE.
1) Can my grammar depend on outside EMF Models (which are not generated by Xtext, they are created manually by me), and their generated code?
Let's say my EMF genmodel has an nsURI of
'http://www.bmw.de/rhmi/image'
can my XText File depend on this Ns-Uri model like so:
import 'http://www.bmw.de/rhmi/image' as image
2) Is it a problem, that the generated code for the outside EMF Models like for example Factory and ImagePackage.java files, and util and impl folders, are not in the src/main/xtext-gen?
The generated code for outside models are not inside src/main/xtext-gen folder.
For example I have my Image.ecore and Image.genmodel, the generated model code for these are not in xtext-gen folder and when I tried to register the generated EPackage in my workflow like this:
registerGeneratedEPackage = "de.bmw.rhmi.image.ImagePackage"
I get the following error:
Caused by: org.eclipse.emf.mwe.core.ConfigurationException: Couldn't find an interface de.bmw.rhmi.image.ImagePackage
at org.eclipse.emf.mwe.utils.StandaloneSetup.addRegisterGeneratedEPackage(StandaloneSetup.java:487)
... 34 more
Although the full qualified name is correct.
Here is my complete workflow
module de.bmw.rhmi.GenerateHmi
import org.eclipse.xtext.xtext.generator.*
import org.eclipse.xtext.xtext.generator.model.project.*
import org.eclipse.emf.mwe.utils.*
var rootPath = ".."
var projectName = "de.bmw.rhmi"
var runtimeProject = "../${projectName}"
Workflow {
bean = StandaloneSetup {
scanClassPath = true
platformUri = "${rootPath}"
registerGenModelFile = "platform:/resource/de.bmw.rhmi/model/generated/Strings.genmodel"
registerGenModelFile = "platform:/resource/de.bmw.rhmi/model/Image.genmodel"
registerGeneratedEPackage = "de.bmw.rhmi.strings.StringsPackage"
registerGeneratedEPackage = "de.bmw.rhmi.image.ImagePackage"
}
component = XtextGenerator {
configuration = {
project = StandardProjectConfig {
baseName = "de.bmw.rhmi"
rootPath = rootPath
runtimeTest = {
enabled = true
}
genericIde = {
enabled = true
}
mavenLayout = true
}
code = {
encoding = "UTF-8"
lineDelimiter = "\n"
fileHeader = "/*\n * generated by Xtext \${version}\n */"
}
}
language = StandardLanguage {
name = "de.bmw.rhmi.Strings"
fileExtensions = "strings"
serializer = {
generateStub = false
}
validator = {
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
}
}
language = StandardLanguage {
referencedResource = "platform:/resource/de.bmw.rhmi/src/main/java/de/bmw/rhmi/Strings.xtext"
referencedResource = "platform:/resource/de.bmw.rhmi/model/Image.genmodel"
name = "de.bmw.rhmi.App"
fileExtensions = "rapp"
serializer = {
generateStub = false
}
validator = {
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
}
}
language = StandardLanguage {
referencedResource = "platform:/resource/de.bmw.rhmi/src/main/java/de/bmw/rhmi/Strings.xtext"
referencedResource = "platform:/resource/de.bmw.rhmi/model/Image.genmodel"
referencedResource = "platform:/resource/de.bmw.rhmi/src/main/java/de/bmw/rhmi/App.xtext"
name = "de.bmw.rhmi.Hmi"
fileExtensions = "hmi"
serializer = {
generateStub = false
}
parserGenerator={
debugGrammar=true
}
validator = {
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
}
}
}
}
[Updated on: Mon, 24 September 2018 16:37] Report message to a moderator
|
|
|
Re: XText File Relying on EMF Models [message #1795525 is a reply to message #1795523] |
Mon, 24 September 2018 16:39 |
|
Again. Without reproducing I can always just guess with your questions.
If you package the outside stuff and put it correctly on the classpath then this will work finde without any problems
So the question is how you packaged and put the de....rhmi stuff to the classpath
Another question would be is the dsl project and the emf project the same
The third question is the classes in a source folder
The third does the problem happen on maven or from eclipse
The forth question why did you change the stuff that was working before
The fifth if you want a separate metamodel why no separate project.
The problem is Xtext is extreme powerful and flexible and you need to know what you are doing
For me answering your questions is just wild guessing
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
Re: XText File Relying on outside EMF Models [message #1795536 is a reply to message #1795523] |
Mon, 24 September 2018 20:52 |
|
Quote:1) Can my grammar depend on outside EMF Models (which are not generated by Xtext, they are created manually by me), and their generated code?
Yes it can.
Quote:2) Is it a problem, that the generated code for the outside EMF Models like for example Factory and ImagePackage.java files, and util and impl folders, are not in the src/main/xtext-gen?
No, that's no problem. They must be found on the classpath, it is not dependend on the source path.
Quote:I get the following error:
ImagePackage can't be found on the classpath, or its genmodel is not registered.
We can only give you pointers here, our apologies.
~Karsten
|
|
|
Re: XText File Relying on outside EMF Models [message #1795538 is a reply to message #1795536] |
Mon, 24 September 2018 22:01 |
Mehmetcan Sinir Messages: 55 Registered: September 2018 |
Member |
|
|
Thank you very much for your answers.
I will look into it tomorrow, but this already makes things clearer.
@Christian
1) DSL Projekt and the EMF Project are the same, I have a single XText Project with Gradle/Maven Layout.
2) I defined two EMF Models manually inside the "model" folder, and then generated code from the genmodel files
3) The code I generated manually from the genmodels (imp, util, factory and so on) is inside the source (src/bmw/rhmi) folder
4) The code xtext generated ((also imp, util, factory and so on) )is inside src/main/xtext-gen folder, but they are in separate packages
5) I did not think I needed a second Project just because I wanted to define two EMF models
I will look into this tomorrow, if I cannot solve it by myself I will provide the code here=)
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03770 seconds