Referencing existing metamodels in a DSL [message #688051] |
Thu, 23 June 2011 19:08 |
Zoltan Ujhelyi Messages: 392 Registered: July 2015 |
Senior Member |
|
|
We are currently experimenting with Xtext, and would like to create a special constraint language over EMF models.
The Xtext grammar language contains similar option: metamodels (EPackages) can be referenced via their namespace URIs, and then EClassifiers can be used inside the language.
I would like to create a similar functionality for our constraint language. I defined our import option similarly to the one in xtext.xtext:
Import: 'import' ePackage=[ecore::EPackage|STRING] ('as' alias=ID)?; , and used the code from the Xtext scope provider to gather the list of NS URIs (and thus content assist was also working) with a minor modification: the qualified name is created using the default qualified name converter:
public IScope scope_EPackage(Import ctx, EReference ref){
IScope current = new SimpleScope(IScope.NULLSCOPE, Iterables.transform(EPackage.Registry.INSTANCE.keySet(), new Function<String, IEObjectDescription>() {
public IEObjectDescription apply(String from) {
InternalEObject proxyPackage = (InternalEObject) EcoreFactory.eINSTANCE.createEPackage();
proxyPackage.eSetProxyURI(URI.createURI(from));
return EObjectDescription.create(qualifiedNameConverter.toQualifiedName(from), proxyPackage, Collections.singletonMap("nsURI", "true"));
}
}));
return current;
}
However, the inserted namespace is not resolved: I got a nullpointer exception, as during the linking phase it tried to resolve the object of the URI "http://www.eclipse.org/emf/2002/Ecore", but its fragment part was missing.
My question is, what might be missing from my code? Do I have to register some specific linking functionality? Or should I use a completely different mechanism for resolution?
Thank you for your help,
Zoltán Ujhelyi
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02993 seconds