Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Declarative scope provider disabling qualified namespace
Declarative scope provider disabling qualified namespace [message #1115268] Mon, 23 September 2013 23:05 Go to next message
Roza Ghamari is currently offline Roza Ghamari
Messages: 65
Registered: January 2013
Member

In my grammar I need to specify the scope of references based on the rules that applies. However, the grammar should still allow the references to be entered by both qualified and simple names.

I have extended the AbstractDeclarativeScopeProvider class and added my scope_... method. This works fine; however, I cannot have namespace for the reference anymore when the scope is defined.

How can I define the scope of a reference, but still have Qualified name base namespace (parent.child) enabled? I do not implement a name provider, I just use the default one using the rule QualifiedName : ID.ID;
When I comment the scope provider the namespace based referencing works fine.
Re: Declarative scope provider disabling qualified namespace [message #1115441 is a reply to message #1115268] Tue, 24 September 2013 05:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6396
Registered: July 2009
Senior Member
Hi,

this depends on the implementation of your scope_ method.

org.eclipse.xtext.scoping.Scopes.scopeFor(Iterable<? extends EObject>)
calls org.eclipse.xtext.scoping.Scopes.scopeFor(Iterable<? extends T>, Function<T, QualifiedName>, IScope)

with simplenameprovider as name computation (Function<T, QualifiedName>)
you can change this as you want.
Re: Declarative scope provider disabling qualified namespace [message #1116968 is a reply to message #1115441] Thu, 26 September 2013 01:45 Go to previous messageGo to next message
Roza Ghamari is currently offline Roza Ghamari
Messages: 65
Registered: January 2013
Member
Hi Christian,

In my scope_ function I just called Scopes.scopeFor(mylist). I added a DefaultDeclarativeQualifiedNameProvider and defined qualifiedName method for my specific object. Then I replace the scopeFor(list) with scopeFor(mylist, new MyNameProvider, IScope.NULLSCOPE) but this time I can do only full namespace based referencing and I cannot use simplename anymore.

I am looking for a case when I have scoping I can do both qualified and simple name. Is there anything I am doing wrong?

My name provider method is:
QualifiedName qualifiedName(MyObject myObj) {
 if (myObj.eContainer() == null)
  return super.qualifiedName(myObj);
 if (myObj.eContainer() instanceof Parent)
  return QualifiedName.create(((Parent)myObj.eContainer()).getName(), myObj.getName() );
 return super.qualifiedName(myObj);
}



I have a similar method for Parent type object as well. So, after I change the scopeFor to use the nameprovider, it needs a 3 level namescope for referencing.
Re: Declarative scope provider disabling qualified namespace [message #1117133 is a reply to message #1116968] Thu, 26 September 2013 06:01 Go to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6396
Registered: July 2009
Senior Member
Hi,

sorry i have no idea,

this is out of the box behaviour.
why do you customize the scope method at all.

of course you could expose the stuff with simplle name as well but this wont respect import semantics.

scopeFor(mylist, MyNameProvider, scopeFor(mylist, Simplenameprovider, IScope.NULLSCOPE) )
Previous Topic:How to build a correct grammar without conflicting keywords and ID's
Next Topic:Static in Xtend
Goto Forum:
  


Current Time: Fri Oct 31 10:59:20 GMT 2014

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

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