Declare and implement ecore model import in xtext grammar [message #1836971] |
Wed, 20 January 2021 12:08 |
|
I have declared an xtext grammar:
grammar de.mdsd.GeneratorModel with org.eclipse.xtext.common.Terminals
generate generatorModel "http://www.mdsd.de/GeneratorModel"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
GeneratorModel:
importList+=Import*
"generator" "model" name=ID "for" model=[ecore::EPackage]
(
namedFeatureList+=NamedFeatureReference
| generatorList+=Generator
)*
;
Import:
"import" referencedModel+=[ecore::EPackage|STRING]
;
...
The grammar compiles fine.
I declared an Instance of this grammar:
//import "GeneratorModelGenerator" // was a suggestion from the auto completion
//import "GeneratorModel"
//import "http://www.mdsd.de/GeneratorModel" // this is the grammars own URI
//import "platform:/resource/de.mdsd.generator.model/model/generated/GeneratorModel.genmodel" // genmodel location in the project
import "platform:/resource/de.mdsd.generator.model/model/generated/GeneratorModel.ecore" // ecore model location in the project
generator model GeneratorModelGenerator for GeneratorModel
...
but neither import works.
How I have to note the import declaration in the grammar instance.
Which other declaration I have to implement getting the Scope right thus the instance can find an load the imported model.
I have searched the web a lot but did not find a complete instruction how to handle grammar imports with Xtext 2.24.
It seems importing does not work out of the box like it does in former versions of Xtext.
It is no error that I try to import the grammars model here, it is like a bootstrap in this case.
A pointer to a complete tutorial would just be fine.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03403 seconds