Skip to main content



      Home
Home » Modeling » TMF (Xtext) » importURI 101(ImportURI facility fails to resolve resource content / how to debug)
importURI 101 [message #896046] Mon, 16 July 2012 23:39 Go to next message
Eclipse UserFriend
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: Mon, 16 July 2012 23:48] by Moderator

Re: importURI 101 [message #896057 is a reply to message #896046] Tue, 17 July 2012 02:02 Go to previous messageGo to next message
Eclipse UserFriend
Hi you have to provide an Iresourceserviceprovider for non Xtext
models. See
http://christiandietrich.wordpress.com/2011/07/17/xtext-2-0-and-uml/

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Re: importURI 101 [message #896295 is a reply to message #896057] Tue, 17 July 2012 18:37 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: importURI 101 [message #896334 is a reply to message #896295] Wed, 18 July 2012 01:59 Go to previous message
Eclipse UserFriend
Yes this has changed since the old times of Xtext 0.7

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Previous Topic:Get all text for a node?
Next Topic:Server-side parsing concepts
Goto Forum:
  


Current Time: Thu Jul 10 00:19:59 EDT 2025

Powered by FUDForum. Page generated in 0.09641 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top