Reputation: 862
I am trying to be able to import EMF resources using their URI from my DSL. Below I describe how I could import EPackages but I can't "explore" what is within these EPackages.
Using the default example of Fowler's state machines DSL, I added in the grammar header:
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
Then in the grammar itself:
Statemachine :
(imports+=Import)*
// the default stuff
('classes' classes+= [ecore::EObject|ID]+ 'end')?
('resetEvents'
resetEvents+=[Event]+
'end')?
;
Import:
'import' importURI=STRING
;
In the workflow, I made sure that I have:
// old scoping and exporting API
fragment = scoping.ImportURIScopingFragment auto-inject {}
fragment = exporting.SimpleNamesFragment auto-inject {}
// scoping and exporting API
//fragment = scoping.ImportNamespacesScopingFragment auto-inject {}
//fragment = exporting.QualifiedNamesFragment auto-inject {}
Also It seemed to raise issues in other posts I read so I commented the following:
// provides the necessary bindings for java types integration
//fragment = types.TypesGeneratorFragment auto-inject {}
// generates the required bindings only if the grammar inherits from Xbase
//fragment = xbase.XbaseGeneratorFragment auto-inject {}
// provides a preference page for template proposals
//fragment = templates.CodetemplatesGeneratorFragment auto-inject {}
I also uncommented the following:
fragment = validation.ValidatorFragment auto-inject {
composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
}
All in all, I can then create two instances say test1.statemachine and test2.statemachine. Then I can write in test1:
import "platform:/resource/test/test2.statemachine"
As expected, I am able to reference Events from test2 in the 'resetEvents' part. However, the following (as an example, but I've tried with other metamodels too):
import "platform:/plugin/org.eclipse.xtext.example.fowlerdsl/model/generated/Statemachine.ecore"
Only allows me to refer to the EPackage "statemachine", when I would like to be able to refer to anything within that very package (its EClasses, its EOperations, etc...). What am I missing in order to have access to these information ?
Upvotes: 1
Views: 802
Reputation: 862
Well apparently a good night's sleep is the best advice, so here's what I was missing:
('classes' classes+= [ecore::EObject|FQN]+ 'end')?
FQN: ID ("." ID)*;
Upvotes: 1