Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ImportURIScoping
ImportURIScoping [message #1089886] Mon, 19 August 2013 11:43 Go to next message
Robert Wild is currently offline Robert WildFriend
Messages: 33
Registered: August 2012
Member
ImportURIScoping does not seem to work transitively. I.e. file a includes file b, file b includes file c, file c contains something that should be referenced from file a. File a does not directly include file c, but via file b, but I can't reference things from file c in file a using ImportURIScoping.

Is this a know limitation of xtext, or am I missing something?

An example grammar:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
	imports+=Import*
	greetings+=Greeting*
	refs+=GreetingRef*;

Import:
	"include" importURI=STRING;

Greeting:
	'Hello' name=ID;

GreetingRef:
	'ref' ref=[Greeting]
;


generator using these modifications:
[...]
fragment = validation.ValidatorFragment auto-inject {
	composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
}
fragment = scoping.ImportURIScopingFragment auto-inject {}

//fragment = types.TypesGeneratorFragment auto-inject {}
//fragment = xbase.XbaseGeneratorFragment auto-inject {}


a.mydsl
include "b.mydsl"
ref cGreeting //error: Couldn't resolve reference to Greeting 'cGreeting'.
ref bGreeting 


b.mydsl
include "c.mydsl"
Hello bGreeting


c.mydsl
Hello cGreeting
Re: ImportURIScoping [message #1089897 is a reply to message #1089886] Mon, 19 August 2013 11:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

yes imports are not meant to work transitively.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: ImportURIScoping [message #1089936 is a reply to message #1089897] Mon, 19 August 2013 13:17 Go to previous messageGo to next message
Robert Wild is currently offline Robert WildFriend
Messages: 33
Registered: August 2012
Member
How can I make them work transitively? Write my own ScopeProvider based on ImportUriGlobalScopeProvider?
Re: ImportURIScoping [message #1089980 is a reply to message #1089936] Mon, 19 August 2013 14:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

sorry i have no idea, it might not be that easy. guess you have to customize ImportUriGlobalScopeProvider
but i dont know if it a good idea todo this (for performance reasons)



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: ImportURIScoping [message #1092057 is a reply to message #1089886] Thu, 22 August 2013 09:17 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Yes, it needs customizing of the ImportURIGlobalScopeProvider. It requires loading of the included resource to collect the resources included by it. I had to do this once for some project, and I only can recommend to not make this if ever possible! It is a really bad idea to load resources such aggressively and does not scale.

Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: ImportURIScoping [message #1092064 is a reply to message #1092057] Thu, 22 August 2013 09:26 Go to previous messageGo to next message
Robert Wild is currently offline Robert WildFriend
Messages: 33
Registered: August 2012
Member
Well, but what if transitive includes are a requirement? I need to implement this. If my language allows file based includes I'd expect them to work transitively.

I've implemented it basically and it seems to work fine. Though I haven't tested it in large scale yet.

I access resources this way (while in the editor):
currentResource.getResourceSet().getResource(uri)


Am I actually loading the resources? I'd guess, since they already are in the resourceSet they are somehow already loaded. Is it really that bad?

What's the alternative? Just don't support transitive includes?
Re: ImportURIScoping [message #1092499 is a reply to message #1089886] Thu, 22 August 2013 22:04 Go to previous message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Extremely hacky, but I wonder if it might be possible to hook into the model deserialization and recursively add members to the container holding the objects with the importUri references...
Previous Topic:Re: No EObjectDescription could be found in Scope
Next Topic:Folding in the embedded editor?
Goto Forum:
  


Current Time: Fri Apr 19 05:51:54 GMT 2024

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

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

Back to the top