Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Global Scope, Filtering and name collisions
Global Scope, Filtering and name collisions [message #656230] Thu, 24 February 2011 16:09 Go to next message
Rafael Angarita is currently offline Rafael AngaritaFriend
Messages: 94
Registered: November 2010
Member
Hello all,

I needed to limit the available objects to be chosen for a certain cross-reference. This reference can be of several types so I wrote this:

AorC:
	a=([ecore::EObject])
;



Looking at the Arithmetics example I found the FilteringScope class and, as in the example, I overwrote this method:

public IScope getScope(EObject context, EReference reference)


Now, the content proposal shows me only the objects that I want, but the grammar shows me an error if there exist
another object with the same name even if this objects is of a type that I thought was filtered.

What am i missing to really limit the visible objects?

Thank you very much!
Re: Global Scope, Filtering and name collisions [message #656290 is a reply to message #656230] Thu, 24 February 2011 23:16 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Rafael,

what kind of error do you get? Did you try to remove the
NamesAreUniqueValidator that is automatically added by the workflow that
generates your language infrastructure.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 24.02.11 17:09, schrieb Rafael Angarita:
> Hello all,
>
> I needed to limit the available objects to be chosen for a certain
> cross-reference. This reference can be of several types so I wrote this:
>
>
> AorC:
> a=([ecore::EObject])
> ;
>
>
>
> Looking at the Arithmetics example I found the FilteringScope class and,
> as in the example, I overwrote this method:
>
>
> public IScope getScope(EObject context, EReference reference)
>
>
> Now, the content proposal shows me only the objects that I want, but the
> grammar shows me an error if there exist
> another object with the same name even if this objects is of a type that
> I thought was filtered.
> What am i missing to really limit the visible objects?
>
> Thank you very much!
>
Re: Global Scope, Filtering and name collisions [message #656413 is a reply to message #656290] Fri, 25 February 2011 13:42 Go to previous messageGo to next message
Rafael Angarita is currently offline Rafael AngaritaFriend
Messages: 94
Registered: November 2010
Member
Hi Sebastian!


The error I get is :

Couldn't resolve reference to EObject 'objectName'


and I did remove NamesAreUniqueValidator from the workflow.

[Updated on: Fri, 25 February 2011 14:36]

Report message to a moderator

Re: Global Scope, Filtering and name collisions [message #656442 is a reply to message #656413] Fri, 25 February 2011 15:37 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Rafael,

the FilteringScope from the arithmetics example is a very limited
implementation. I'd assume that your scope does not work correctly with
regards to shadowing of duplicate names that are inherited from the
parent scope.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 25.02.11 14:42, schrieb Rafael Angarita:
> Hi Sebastian!
>
>
> The error I get is :
>
>
> Description Resource Path Location Type
> Couldn't resolve reference to EObject 'objectName'
>
>
> and I did remove NamesAreUniqueValidator from the workflow.
Re: Global Scope, Filtering and name collisions [message #656474 is a reply to message #656442] Fri, 25 February 2011 20:07 Go to previous message
Rafael Angarita is currently offline Rafael AngaritaFriend
Messages: 94
Registered: November 2010
Member
After reading this post http://www.eclipse.org/forums/index.php?t=msg&goto=515848& I wrote a scoping method
like the one posted there:

public IScope scope_PointerType_ref(FieldType context, EReference ref){
		IScope result = delegateGetScope(context, ref);
		Iterable<IEObjectDescription> objects = Iterables.filter(result.getAllContents(), new Predicate<IEObjectDescription>() {
			@Override
			public boolean apply(IEObjectDescription input) {
				return input.getEObjectURI().fileExtension().equals("mdd") ;
			}
		});
		return new SimpleScope(objects);
	}


And it works fine except for the exception mentioned in that post, which is:

getAllContents schouldn't be called on a global scope during linking


The apply method I wrote there and when I was trying the way showed in the Arithmetics example are exactly the same.

I don't know what else I could do.

Thank you very much for your help.






Previous Topic:Extra output during serialization
Next Topic:Quick Fix: Serialized Text Formatted Incorrectly
Goto Forum:
  


Current Time: Mon Jun 10 11:25:57 GMT 2024

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

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

Back to the top