I m working on a grammar (Xtext project) where I want to reuse OCL types. Usually you refer in Xtext to existing types with an import statement, e.g.
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
There is already an example Xtext project (CompleteOCL) which integrates OCL types in a grammar. Unfortunately the project refers in its import statements to local plugins, e.g.
import "platform:/resource/org.eclipse.ocl.examples.xtext.base/model/BaseCST.ecore" as base
So there are no dependencies defined in the Manifest.MF file. If I want to reuse OCL types in my grammar I have to write for example
import "http://www.eclipse.org/ocl/3.0.0/BaseCST" as base
I ve added the org.eclipse.ocl.examples.xtext.base dependency and can write rules in my grammar which refer to (OCL) BaseCST types. If I try to generate the Xtext artifcats I get the following error:
... 3 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.emf.mwe2.language.factory.SettingProviderImpl$1$1.setValue(SettingProviderImpl.java:54)
... 36 more
Caused by: java.lang.IllegalStateException: Problem parsing classpath:/org/xtext/example/mydsl/MyDsl.xtext :[XtextLinkingDiagnostic: null:5 Couldn t resolve reference to EPackage http://www.eclipse.org/ocl/3.0.0/BaseCST .]
at org.eclipse.xtext.generator.LanguageConfig.setUri(LanguageConfig.java:112)
... 41 more
So probably I missing something? The problem is quite easy to reproduce. Create a new Xtext project, add the dependency, edit the grammar and add the last import statement ("import "http://...") and try to generate the Xtext artifacts. Any ideas are welcome!
Thanks in advance!
Michael
EDIT: In order to use a grammar you have to refer in your MWE2 workflow (see section 3.2.2.2 of the the Xtext documentation (version 1.0.1)) to the corresponding genmodel file of the ecore model, for example
fragment = org.eclipse.xtext.generator.ecore.EcoreGeneratorFragement {
referencedGenModels = "platform:/plugins/org.eclipse.ocl.examples.xtext.base/model/BaseCST.genmodel
}
Nevertheless it s still not working for me.