Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Weird Scope provider behavior
Weird Scope provider behavior [message #1053622] Mon, 06 May 2013 22:16 Go to next message
Roza Ghamari is currently offline Roza Ghamari
Messages: 64
Registered: January 2013
Member
Hi all,

I have a grammar like this:

Model:
(CLass)* (Inst)*
;

Class:
'class' '{'
(variables += Variable ';')*
'}'
;

Variable:
'INT' name = ID ';'
;

Inst:
class = [Class] name=ID ';'
(variableSettings += VariableSettings ';')*
';'

VariableSettings :
instance = [Inst] '.' variable=[Variable] '=' value = INT ';'
;

I am trying to write a scope provider for variables referenced in VariableSettings to be scoped to the defined variables in the class of the instance.
My scope provider is:

IScope scope_Variable_variable (Variable var, ERefrence ref){
if(var.eContainer() instanceof VariableSettings){
return Scopes.scopeFor(((VariableSettings)var.eContainer()).getClass().getVariables())

}
return null;
}


The weired behavior I see is that when I try to use context helper (Ctrl+Space) the function call to scope_Variable_variable() gets called and in the popup box correct variables are displaying. But if I write any undefined variable after '.' the error doesn't get caught and the scope function is not called.

I tried moving VariableSettings to a level higher and writing it under Model, this works fine and the scope method gets called after I put '.'!

I really don't know how to solve this problem. My model is fixed so it is not possible for me to move VariableSettings under model. Do you know how to debug this? Where are these methods get called??

Thanks!
Re: Weird Scope provider behavior [message #1053624 is a reply to message #1053622] Mon, 06 May 2013 23:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
Hi this makes no sense to me

Why not

IScope scope_VariableSettings_variable(VariableSettings Ctx, Ereferece ref)
Re: Weird Scope provider behavior [message #1053625 is a reply to message #1053624] Mon, 06 May 2013 23:36 Go to previous messageGo to next message
Roza Ghamari is currently offline Roza Ghamari
Messages: 64
Registered: January 2013
Member
Hi Christian,

You are right, I am actually doing
IScope scope_VariableSettings_variable(VariableSettings Ctx, Ereferece ref)


The one I wrote was incorrect. But this doesn't get called when I am writing down! I see it's called for context assistance.

Thanks!
Re: Weird Scope provider behavior [message #1053626 is a reply to message #1053625] Mon, 06 May 2013 23:42 Go to previous messageGo to next message
Roza Ghamari is currently offline Roza Ghamari
Messages: 64
Registered: January 2013
Member
Two other thing I found out:

1. I was looking at the reflective ecore model, and I noticed that the references to instance and variable under VariableSettings is null! Regardless of a correct or incorrect parameter name.

2. Also I found out that my IScope scope_VariableSettings_instance(VariableSettings Ctx, Ereferece ref) doesn't get called neither.


Again everything is fine when I move the VariableSettings under model!

Really appreciate your help.

Roza
Re: Weird Scope provider behavior [message #1053628 is a reply to message #1053626] Tue, 07 May 2013 00:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
Hi can you please Share a Test Model i still dont know what you are actually doing
Re: Weird Scope provider behavior [message #1053629 is a reply to message #1053628] Tue, 07 May 2013 00:03 Go to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
BTW due Lazy init you may have to use

scope_VariableSettings_instance(Inst Ctx, Ereferece ref)
Previous Topic:Self-triggered Autocomplete
Next Topic:Mwe2 Workflow - modify variables at runtime
Goto Forum:
  


Current Time: Fri Oct 24 20:33:26 GMT 2014

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

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