Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Scope provider/content assist mismatch
Scope provider/content assist mismatch [message #759779] Wed, 30 November 2011 01:01 Go to next message
Mirko Raner is currently offline Mirko RanerFriend
Messages: 125
Registered: July 2009
Location: New York City, NY
Senior Member
Hi all,

we're having some problems in a project that consists of multiple interoperating Xtext languages which each have their own custom scope providers. Unfortunately, providing some concrete source code is not feasible, but I'd like to ask a general question:
We are seeing the behavior that a certain model element appears as part of the content assist (i.e., it is apparently in scope) but once the user selects that element and inserts it into the source it immediately gets underlined in red and we see an error message saying that it could not resolve the reference to that element.
So, on the one hand the scope seems fine for the content assist, but once inserted into the source the element appears to be no longer in scope. We were wondering whether we have some ambiguities in our grammars that would change the way the source code is parsed after an element is inserted, but so far we were unable to confirm that suspicion.
So, generally speaking, what are the things that one should look into when encountering the described behavior?

Thanks a lot!


Re: Scope provider/content assist mismatch [message #759801 is a reply to message #759779] Wed, 30 November 2011 07:06 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

A first set of pointers: Would the proposed elements be valid at the given positions, i.e. are the proposals incorrect or the unresolved cross references? Did you adapt the scoping (i.e. who put the said elements into the scope)? Debug, which complete-rules are called for the given position. If there are several, you might overwrite them (disabling them) in order to check which resolveCrossReference-call adds them to the proposals.
Note that the context element passed into the proposal provider might actualy be an ancestor of the expected one (the "correct" one may not have been created yet in the partial model assumed by the proposal provider). As a consequence, the wrong scope might be used.

Alex
Re: Scope provider/content assist mismatch [message #759812 is a reply to message #759779] Wed, 30 November 2011 07:46 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Mirko,

it sounds like you enabled backtracking in your grammar where something
like this could happen (simplified):

Rule: RuleA | RuleB;
RuleA: name = ID crossRefA=[Something];
RuleB: name = ID crossRefB=[SomethingElse|QualifiedName];

Input model (| indicates the cursor position):

myId |

If you invoke CA at that position, you'll get all Somethings and
SomethingElses proposed. If however, the selected SomethingElse has only
a simple name, the parser will choose the first path as soon as you
inserted the name because RuleB will never be chosen due to backtracking.

Is that the case for your language?

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

Am 30.11.11 02:01, schrieb Mirko Raner:
> Hi all,
>
> we're having some problems in a project that consists of multiple
> interoperating Xtext languages which each have their own custom scope
> providers. Unfortunately, providing some concrete source code is not
> feasible, but I'd like to ask a general question:
> We are seeing the behavior that a certain model element appears as part
> of the content assist (i.e., it is apparently in scope) but once the
> user selects that element and inserts it into the source it immediately
> gets underlined in red and we see an error message saying that it could
> not resolve the reference to that element.
> So, on the one hand the scope seems fine for the content assist, but
> once inserted into the source the element appears to be no longer in
> scope. We were wondering whether we have some ambiguities in our
> grammars that would change the way the source code is parsed after an
> element is inserted, but so far we were unable to confirm that suspicion.
> So, generally speaking, what are the things that one should look into
> when encountering the described behavior?
>
> Thanks a lot!
>
>
>
Re: Scope provider/content assist mismatch [message #760019 is a reply to message #759801] Wed, 30 November 2011 23:46 Go to previous messageGo to next message
Mirko Raner is currently offline Mirko RanerFriend
Messages: 125
Registered: July 2009
Location: New York City, NY
Senior Member
Alexander Nittka wrote on Tue, 29 November 2011 23:06
Hi,

A first set of pointers: Would the proposed elements be valid at the given positions, i.e. are the proposals incorrect or the unresolved cross references? Did you adapt the scoping (i.e. who put the said elements into the scope)?

The proposals in the content assist are correct. It is the error markers that appear after selecting one of the content assist options that are incorrect.
And yes, the scope providers are heavily customized.
Re: Scope provider/content assist mismatch [message #760022 is a reply to message #759812] Thu, 01 December 2011 00:10 Go to previous messageGo to next message
Mirko Raner is currently offline Mirko RanerFriend
Messages: 125
Registered: July 2009
Location: New York City, NY
Senior Member
Sebastian Zarnekow wrote on Tue, 29 November 2011 23:46
Hi Mirko,
it sounds like you enabled backtracking in your grammar where something
like this could happen (simplified):

Thanks, Sebastian and Alexander!
I think the backtracking issue might have nailed it on the head. All 4 grammars that are involved in this issue have backtracking enabled Sad And it will be very hard to get rid of that.
I haven't specifically located the problematic pattern in our grammars yet, but there is a good chance that that's exactly what's happening.
Re: Scope provider/content assist mismatch [message #816827 is a reply to message #760022] Fri, 09 March 2012 09:59 Go to previous message
Alex G is currently offline Alex GFriend
Messages: 96
Registered: January 2012
Member
Hi Mirko!

It could be the same case, that I have as well. Assume you call a reference from different contexts:

scope_TypeA_ref(TypeB obj, EReference eRef) {...}
scope_TypeA_ref(TypeA obj, EReference eRef) {...}


The context provider in my case computes the scope from TypeB (upper method), but after completion, TypeA is the actual one (lower method), which is not delegated! Somehow disappointing, that the directions of searching for a scope method are not unique.
Previous Topic:Scoping in different contexts depending on non-resolved parameters
Next Topic:Backtrack on single rules
Goto Forum:
  


Current Time: Fri Apr 26 16:38:15 GMT 2024

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

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

Back to the top