complete{TypeName}_{FeatureName} called with parent i.s.o. node itself [message #1753974] |
Mon, 13 February 2017 14:53 |
Paul Hoogendijk Messages: 2 Registered: February 2017 |
Junior Member |
|
|
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.
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02120 seconds