Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Weird Scope provider behavior
Weird Scope provider behavior [message #1053622] Mon, 06 May 2013 18:16 Go to next message
Eclipse UserFriend
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 19:19 Go to previous messageGo to next message
Eclipse UserFriend
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 19:36 Go to previous messageGo to next message
Eclipse UserFriend
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 19:42 Go to previous messageGo to next message
Eclipse UserFriend
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] Mon, 06 May 2013 20:00 Go to previous messageGo to next message
Eclipse UserFriend
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] Mon, 06 May 2013 20:03 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 08:41:08 EDT 2025

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

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

Back to the top