Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Content assist strangely behaving in relation to scoping(Some EClass are just skipped...)
Content assist strangely behaving in relation to scoping [message #1015958] Mon, 04 March 2013 07:17 Go to next message
Victor Noël is currently offline Victor Noël
Messages: 112
Registered: June 2010
Senior Member
Hi,

Following the thread http://www.eclipse.org/forums/index.php/t/457539/ and my own problems with content assist and scoping, I open a new one because I think the problem is different (but maybe link to lazy instantiation...).

So, I have this language:
https://anon:anon@wwwsecu.irit.fr/hg/SMAC/victor-noel-phd/may/may-xtext2/

There is an ecore model, and then an xtext language built on top of it.
The point of interest here is the language description in xtext (in fr.irit.smac.may.speadl), I put some comments when there is things that could seem strange. There is some french comments but they are unimportant.
I'm using xtext 2.4M5.
I only committed the code I changed, for the rest one need to execute both mwe2 workflow in fr.irit.smac.may.spead then fr.irit.smac.may.speadl.

So I defined different scope methods in SpeADLDeclarativeScopeProvider (which is called by SpeADLScopeProvider without any problem) for my different rules to produce PortReference elements.

The problem is that while this scope is used correctly for validation, when doing content assist, the getScope method is called directly starting from the Binding context, without entering the {Required,PartProvided,ThisProvidedOrRequired}PortReference Eclasses, even though they do exist and that I forced the instantiation using an action.
Thus for content assist, the scope for my PortReference is never called.

Another strange thing is that only the predicate scope_PortReference_port is used, and never the predicate scope_{Required,PartProvided,ThisProvidedOrRequired}PortReference_port ... I don't know if it is normal.

Here is an example to play with it:
namespace Test {
	ecosystem TestE1 {
		provides test: String = a.test
		requires test2: String
		
		part a: TestE2 {
			bind test4 to a.test3
			bind test to a.test
			bind test2 to this.test2
		}
	}
	ecosystem TestE2 {
		provides test3: String = this.test3
		requires test4: String
	}
}


I hope this is clear :)

Thank you
Re: Content assist strangely behaving in relation to scoping [message #1016071 is a reply to message #1015958] Mon, 04 March 2013 14:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6144
Registered: July 2009
Senior Member
HI,

i cannot watch the grammar (get 500 http error)
never the less. if you have a look at org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider.getPredicate(EObject, EReference)
you can see that the method name has nothing todo with the grammar rules but with the (maybe) derived metamodel

scope_<Class that Containstheref>_refname.

since xtext moves stuff up to superclasses when deriving the metamodel it may actually be the superclass. in your case PortReference

another problem is that Xtext create objects lazy on the first assignment so the context may be a parent object if the referene is the first thing in your rule.

without knowing your exact grammar it is hard to tell what best to do. maybe using a simple action ({Type})can help
Re: Content assist strangely behaving in relation to scoping [message #1016076 is a reply to message #1016071] Mon, 04 March 2013 15:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6144
Registered: July 2009
Senior Member
Hi,

the server seems to be working now.
it seems that the simple actions need a keyword to be executed.

in your case i see 2 options.

(1) change the grammar and move the bind keyword down to the RequiredPortReference
(2) simply change the scoping (context seem to come from outside in your case anyway.

protected IScope scope_PortReference_port(fr.irit.smac.may.spead.Binding context, EReference ref) {
		return Scopes.scopeFor(getType((ComponentPart)context.eContainer()).getRequires());
	}
Re: Content assist strangely behaving in relation to scoping [message #1016132 is a reply to message #1016076] Tue, 05 March 2013 02:58 Go to previous messageGo to next message
Victor Noël is currently offline Victor Noël
Messages: 112
Registered: June 2010
Senior Member
Hi, sorry for the errors, I'm glad you could see the code in the end :)

Thank you for your explanation, I knew about the EClass being used in declarative scope, but not that the super class would be used.
But I guess it is also consistent with the fact that it seems the object are not created when content assist occurs...

Isn't there any way of forcing the creation of the object? I thought the simple action was there for that...

The two options seems to be a bit of a workaround, but well, I will certainly use that, maybe moving the keyword is the simplest to implement!

Thank you for your explanation!
Re: Content assist strangely behaving in relation to scoping [message #1016186 is a reply to message #1016132] Tue, 05 March 2013 06:56 Go to previous messageGo to next message
Victor Noël is currently offline Victor Noël
Messages: 112
Registered: June 2010
Senior Member
Well, I was happy too quickly, there is still something strange...

For the rules named PartProvidedPortReference and ThisProvidedOrRequiredPortReference, normally, for the feature "port", the scope should propose elements found based on the declaringComponent feature, but while it does so with validation, it does not with contentassist...

If I enter the first character of a port name, then it uses the correct scope, but I don't see how lazy evaluation is the problem as we are in the middle of a rule...
Re: Content assist strangely behaving in relation to scoping [message #1016188 is a reply to message #1016186] Tue, 05 March 2013 06:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6144
Registered: July 2009
Senior Member
Hi the portrefereces all start with the reference don't they

--
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
Re: Content assist strangely behaving in relation to scoping [message #1016189 is a reply to message #1016188] Tue, 05 March 2013 07:16 Go to previous messageGo to next message
Victor Noël is currently offline Victor Noël
Messages: 112
Registered: June 2010
Senior Member
Well,

All there is 3 types of PortReference from the point of view of the grammar:

RequiredPortReference: those without declaringComponent explicitly defined (just after the "bind" keyword).
PartProvidedPortReference: those with a declaringComponent identified by its name (after the "to" keyword).
ThisProvidedOrRequiredPortReference: thos with a declaringComponent being identified as "this" (after the "to" keyword also).

In all case, this results on the instance of PortReference having a declaringComponent defined (for RequiredPortReference case, the custom implementation of the ecore model takes care of that).

The first problem we solved earlier was concerning RequiredPortReference and its "port" feature.

Now my problem is with the other two and their "port" feature, but from my investigation with the debugger, it seems that one of my scope method was throwing an exception.

Is there a way to have some debug logs with this kind of exception shown?
Because I didn't see any in the consoleLog...
Re: Content assist strangely behaving in relation to scoping [message #1016257 is a reply to message #1016189] Tue, 05 March 2013 11:42 Go to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6144
Registered: July 2009
Senior Member
Hmmm i dont know of such a facility
Previous Topic:QNames with dots in segments
Next Topic:Automatic Validation
Goto Forum:
  


Current Time: Fri Aug 01 12:14:28 EDT 2014

Powered by FUDForum. Page generated in 0.04656 seconds