Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » importURI 101(ImportURI facility fails to resolve resource content / how to debug)
importURI 101 [message #896046] Tue, 17 July 2012 03:39 Go to next message
Jörn Guy  Süß is currently offline Jörn Guy SüßFriend
Messages: 83
Registered: July 2009
Location: Germany
Member

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 #896057 is a reply to message #896046] Tue, 17 July 2012 06:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13357
Registered: July 2009
Senior Member
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


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: importURI 101 [message #896295 is a reply to message #896057] Tue, 17 July 2012 22:37 Go to previous messageGo to next message
Jörn Guy  Süß is currently offline Jörn Guy SüßFriend
Messages: 83
Registered: July 2009
Location: Germany
Member

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 05:59 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13357
Registered: July 2009
Senior Member
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


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Get all text for a node?
Next Topic:Server-side parsing concepts
Goto Forum:
  


Current Time: Thu Feb 20 02:26:44 GMT 2020

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

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

Back to the top