importURI 101 [message #896046] |
Tue, 17 July 2012 03:39 |
|
Symptom:
I have an issue with basic cross-referencing to an external (non-local) model. I employ the importURI facility. The resource is identified, as a URI pointing to a non-existing resource fails.
Details:
I have implemented a simplemost DSL based on the settings generated by the xtext project wizard.
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
import "platform:/resource/org.eclipse.emf.examples.library/model/extlibrary.ecore"
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Model: (imports+=Import)* writers+=[Writer]*;
Import :'import' importURI=STRING;
The referenced model is the Eclipse EMF stock standard library example.
I have included the reference to the model files in the manifest.mf, so the generated xText code compiles.
I have included the reference to the Generator model in the workflow file:
Workflow {
bean = StandaloneSetup {
scanClassPath = true
platformUri = "${runtimeProject}/.."
registerGenModelFile = "platform:/resource/org.eclipse.emf.examples.library/model/extlibrary.genmodel"
}
I have changed the scoping from Namespaces to use URIScoping.
// scoping and exporting API
fragment = scoping.ImportURIScopingFragment {}
fragment = exporting.SimpleNamesFragment {}
// scoping and exporting API
// fragment = scoping.ImportNamespacesScopingFragment {}
// fragment = exporting.QualifiedNamesFragment {}
At runtime, I have defined a Library model with one Writer object named "JoeDoe" in it. This model validates and saves. The resource is called 'My.extlibrary'.
A file 'test.mydsl' is located next to it, in the runtime project's root. The import statement works. This is can be tested by using a non-existent resource name instead. With such a name, xText displays an error marker'Imported resource could not be found..
test.mydsl:
import "My.extlibrary"
JoeDoe
With access to the resource, xText should now resolve 'JoeDoe'. However, it marks the line with the warning Couldn't resolve reference to Writer 'JoeDoe'. Also, there is no display of model element choices in the context assist drop down (Ctrl-Space).
As the generated code base is very large, I have no clue where to attach the debugger or what to look for to fix this error.
- Has anyone come across this issue?
- Is there anything totally obvious that I am missing?
- Can anyone supply a simplement working example of such a linking that I could modify?
[Updated on: Tue, 17 July 2012 03:48] Report message to a moderator
|
|
|
|
Re: importURI 101 [message #896295 is a reply to message #896057] |
Tue, 17 July 2012 22:37 |
|
Christian, thanks for this. Does this mean this has to be done for every non-xText model, even if using the importURI facility? This seems extremely tedious ! I had understood from posts like this one and from the xText documentation, that the ability to cross-reference with a resource defined as an import is built in. It is difficult for me to gauge the aim of IResourceServiceProvider, as JavaDoc is very sparsely documented. Please confirm that your advice points me in the right direction, before I embark on a coding spree.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03220 seconds