Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Ambiguities in xText scoping "Context"
Ambiguities in xText scoping "Context" [message #1006852] Sat, 02 February 2013 17:26 Go to next message
Frank Tagne is currently offline Frank Tagne
Messages: 7
Registered: August 2012
Junior Member
Hello,

I'm dealing an scoping problem in my xtext language.

Let's see the grammar below and the associated MM (see attached)

CallService returns CallService:
	{CallService}
	'CallService' (=>'::'name=EString)?
	'{'
	     ('sourcePort' sourcePort=PortRef)?	
             ('targetPort' targetPort=PortRef)?
		
    '}';

PortRef returns PortRef: {PortRef} referencedPort=[PortEvent];
PortEvent returns PortEvent:'PortEvent'{PortEvent} (=>'::'name=EString)?;


index.php/fa/13271/0/

I would like to provide scoping rules for targetPort and sourcePort in such that the targetPort's scope should not contained PortRef assigned to sourcePort ( and vis versa).

big question here is : how can i know where am i ?

To do it, i need to know where i'm : the Context. Precisly, i would like have the "PortRef" instance as Context's return in the function getScope(context, Ereference), but it's not the case.

I tried this function scope_PortRef_referencedPort(Ctx,ref) in scope, but the Context passed in my function is an instance of CallService and not of PortRef like it supposed to be.

And that despite of the fact that i put {PortRef} intructions to force that the object creation.

Am i missing something ?

i hope i was clear.

Best regards.
F.

[Updated on: Sat, 02 February 2013 17:28]

Report message to a moderator

Re: Ambiguities in xText scoping "Context" [message #1006859 is a reply to message #1006852] Sat, 02 February 2013 19:42 Go to previous messageGo to next message
Ian McDevitt is currently offline Ian McDevitt
Messages: 27
Registered: December 2012
Junior Member
In the scoping function, could you get the PortRef you need from the passed in CallService context using context.getSourcePort() or context.getTargetPort()?
Re: Ambiguities in xText scoping "Context" [message #1006962 is a reply to message #1006859] Sun, 03 February 2013 04:17 Go to previous messageGo to next message
Frank Tagne is currently offline Frank Tagne
Messages: 7
Registered: August 2012
Junior Member
Yes Ian, i can do context.getSourcePort() or context.getTargetPort.

my question is exactly for which of both EReference ( sourcePort or targetPort) i'am scoping ?

Because i can not just do (context.getSourcePort() != null ) or (context.getTargetPort !=null) to know which one of both EReference user hint Crtl+Space. That will not cover users udaptes.

Re: Ambiguities in xText scoping "Context" [message #1006967 is a reply to message #1006962] Sun, 03 February 2013 05:38 Go to previous messageGo to next message
Ian McDevitt is currently offline Ian McDevitt
Messages: 27
Registered: December 2012
Junior Member
Maybe try two separate scope_CallService_sourcePort and scope_CallService_targetPort instead. The context may still be a CallService but you'd know which referenced item you were in.
Re: Ambiguities in xText scoping "Context" [message #1006998 is a reply to message #1006967] Sun, 03 February 2013 13:14 Go to previous messageGo to next message
Frank Tagne is currently offline Frank Tagne
Messages: 7
Registered: August 2012
Junior Member
I tried your proposition but it doesn't work.
Those two functions are never run. It seems to be logic because i'm scoping the reference "referencePort" at the end. But the context return are not the good one Crying or Very Sad

Re: Ambiguities in xText scoping "Context" [message #1007013 is a reply to message #1006998] Sun, 03 February 2013 18:12 Go to previous messageGo to next message
Ian McDevitt is currently offline Ian McDevitt
Messages: 27
Registered: December 2012
Junior Member
Just so I understand - you're saying that in your function scope_PortRef_referencedPort(Ctx,ref) the Ctx is a CallService and not a PortRef?

I'm hoping the ref parameter is a ReferencedPort so perhaps its getName() will be either "sourcePort" or "targetPort".

if (ref instanceof ReferencedPort)
{
  ReferencedPort refPort = (ReferencedPort)ref;
  String portName = refPort.getName();
  if (portName.equals("sourcePort")) { }
}


It doesn't look elegant I'll admit so possibly someone else will have a better way.
Re: Ambiguities in xText scoping "Context" [message #1007069 is a reply to message #1007013] Mon, 04 February 2013 05:41 Go to previous message
Frank Tagne is currently offline Frank Tagne
Messages: 7
Registered: August 2012
Junior Member
Re,

Quote:
I'm hoping the ref parameter is a ReferencedPort so perhaps its getName() will be either "sourcePort" or "targetPort".

ref parameter is an EReference. Its getName() is "referencedPort" and its eContainer() return an EClass ( not an EObject).

F.
Previous Topic:[Xbase] LValue-like expressions in DSL
Next Topic:Model serialization is very slow
Goto Forum:
  


Current Time: Sat May 25 19:45:41 EDT 2013

Powered by FUDForum. Page generated in 0.01659 seconds