Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Resolving references across different models using ImportedNamespaceAwareLocalScopeProvider
Resolving references across different models using ImportedNamespaceAwareLocalScopeProvider [message #724201] Sun, 11 September 2011 11:33 Go to next message
Maxim Frolov is currently offline Maxim FrolovFriend
Messages: 20
Registered: March 2010
Location: Aachen
Junior Member
Given the following grammar:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Module:
	(imports+=Import)*
	"Module" name=ID "{"		
		(enitities+=Entity)*
	'}'
	;
	
Entity:
	'entity' name=ID '{'
		(references+=Reference)*
	'}';


Reference:
	to=[Entity] name=ID ';'
;
	
	
Import:
	'import' importedNamespace=QualifiedNameWithWildCard;
	
QualifiedNameWithWildCard :
	QualifiedName  ('.' '*')?;
	
	
QualifiedName:
  ValidID (=>'.' ValidID)*;
 
ValidID:
	ID
;


and the following 2 models:

x.mydsl:
Module x {
	entity X1 { }
	
	entity X2 {
		  X1 x1;
	}
}



and y.mydsl:
import x.*

Module y {
	entity Y {
		X1 a; 
	}
}



There is a 'grey' error in model editor for y.mydsl:
https://lh5.googleusercontent.com/-2AZERJL6F38/TmyX5FUwbaI/AAAAAAAAApc/4wVz5mNYPCU/s144/xtext_err.jpg

And a 'red' error In Problems view: Couldn't resolve reference to Entity X1.

Auto-Completion feature works as expected: all local and imported references are shown.

The language project was generated by Xtext wizard with default settings and the language runtime has been customized with two Guice bindings:



  • IQualifiedNameProvider => DefaultDeclarativeQualifiedNameProvider.
  • IScopeProvider => ImportedNamespaceAwareLocalScopeProvider.



The version of Xtext bundle is:
org.eclipse.xtext_2.0.1.v201107070603




What is wrong with resolving references? Do I need to customize ImportedNamespaceAwareLocalScopeProvider?


Re: Resolving references across different models using ImportedNamespaceAwareLocalScopeProvider [message #724217 is a reply to message #724201] Sun, 11 September 2011 13:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi,

don't to that IScopeProvider => ImportedNamespaceAwareLocalScopeProvider. stuff and it will work nicely with the default settings.
of course you have to save the file to get rid of the grey stuff.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sun, 11 September 2011 13:53]

Report message to a moderator

Re: Resolving references across different models using ImportedNamespaceAwareLocalScopeProvider [message #724219 is a reply to message #724217] Sun, 11 September 2011 13:53 Go to previous message
Maxim Frolov is currently offline Maxim FrolovFriend
Messages: 20
Registered: March 2010
Location: Aachen
Junior Member
@Christian:
I bound IScopeProvider to a class which extends AbstractDeclarativeScopeProvider and it works!

Thank you very much for your help!

Previous Topic:Content Assist, enum types and templates
Next Topic:Where are XText GMF integration examples ?
Goto Forum:
  


Current Time: Thu Sep 19 21:18:10 GMT 2024

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

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

Back to the top