Skip to main content



      Home
Home » Modeling » TMF (Xtext) » complete{TypeName}_{FeatureName} called with parent i.s.o. node itself
complete{TypeName}_{FeatureName} called with parent i.s.o. node itself [message #1753974] Mon, 13 February 2017 09:53 Go to next message
Eclipse UserFriend
Hi,

I have the following grammer (which is a stripped down version of the real own):

Model:
    models += ModelDeclaration*
;

ModelDeclaration:
    InterfaceDeclaration | ComponentDeclaration
;

InterfaceDeclaration:
    'interface' 
    name = ID 
    CURLYBRACKET_OPEN
    eventDecls += EventDeclaration 
    CURLYBRACKET_CLOSE
;

EventDeclaration:
    name = ID 
    SEMICOLON
;


ComponentDeclaration:
    'component'
    name = ID
    CURLYBRACKET_OPEN
    (ports += PortDeclaration)*
    (behaviour = BehaviourDeclaration)
    CURLYBRACKET_CLOSE
;

PortDeclaration:
    names = [InterfaceDeclaration]
    name = ID
    SEMICOLON
;


BehaviourDeclaration:
    'behaviour'
    CURLYBRACKET_OPEN
    stats += BehaviourStatement
    my = CURLYBRACKET_CLOSE
;

BehaviourStatement:
    CompoundBehaviourStatement
  | ActionStatement
  | ReplyStatement
;

CompoundBehaviourStatement:
    {CompoundBehaviourStatement}
    CURLYBRACKET_OPEN
    (stats += BehaviourStatement)*
    CURLYBRACKET_CLOSE
;

ActionStatement:
    port = [PortDeclaration] '.' action = [EventDeclaration]
    SEMICOLON
;


ReplyStatement:
    (port = [PortDeclaration] DOT)?
    actionReply = 'reply'
    SEMICOLON
;

CURLYBRACKET_OPEN : '{';
CURLYBRACKET_CLOSE : '}';
SEMICOLON : ';';
DOT : '.';


Now, for content assist I want to filter on certain events for each of the ports (which events are allowed depends on properties which are part of the real grammar).
So, I want to override


	override completeActionStatement_Action(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
		if (model instanceof ActionStatement) {
			var port = (model as ActionStatement).port
			port = port;
		}
		else {
			logger.error("Help; how to access port field?")					
		}
		super.completeActionStatement_Action(model, assignment, context, acceptor)
	}


However, sometimes this method is called with the parent (CompoundBehaviourStatement) i.s.o. the node it self.
As a result, I have no idea how to get the "port" field.

For instance this happens for the following example:

interface I {
	e;
}

component C {
	I p;
	I r;
	behaviour {
		{ p.}      // content assist after "p." does not work as expected; how to access port field?
	}
}


For the folling example it does work:
interface I {
	e;
}

component C {
	I p;
	I r;
	behaviour {
		{ p.e; p.}      // content assist after "p." does work as expected
	}
}



How to fix this, i.e. how to make sure it is always called with ActionStatement as model?

Thanks,

-Paul Hoogendijk.
Re: complete{TypeName}_{FeatureName} called with parent i.s.o. node itself [message #1753985 is a reply to message #1753974] Mon, 13 February 2017 11:37 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Depending on the error recovery this might work or might not. I'll have a look if the error recovery can be improved

[Updated on: Mon, 13 February 2017 12:07] by Moderator

Re: complete{TypeName}_{FeatureName} called with parent i.s.o. node itself [message #1754005 is a reply to message #1753985] Mon, 13 February 2017 13:10 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the quick response.

Two remarks/questions:

1) How do I access the PortDeclaration inside the parent? So the port name "p" and its corresponding declaration?

2) I noticed that if I remove the ReplyStatement that it does work. Does that make sense?

Thanks,

Paul.
Re: complete{TypeName}_{FeatureName} called with parent i.s.o. node itself [message #1754007 is a reply to message #1754005] Mon, 13 February 2017 13:32 Go to previous messageGo to next message
Eclipse UserFriend
well,

this is where your grammar is ambigous.

if you simply write

xxxx.

you can be inside an action or you can be inside a reply.
this is why the content assist cannot decide what to created.
thus you get the last object that could be decided as param.

=> there is no real solution for that.
Re: complete{TypeName}_{FeatureName} called with parent i.s.o. node itself [message #1754008 is a reply to message #1754007] Mon, 13 February 2017 13:36 Go to previous message
Eclipse UserFriend
p.s.

ofcourse you could merge both into one

PortBasedStatement:
((
port = [PortDeclaration] '.' (
action=[EventDeclaration] |
actionReply='reply'
)
) |
{PortBasedStatement}actionReply = 'reply')
";"
;
Previous Topic:xbase expression performance issue with nested feature calls
Next Topic:After Migtation from xtext 2.10 to xtext 2.11. Cannot open text editor for my DSL
Goto Forum:
  


Current Time: Wed Jul 16 16:43:36 EDT 2025

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

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

Back to the top