createNode is not called for MySyntaxTransformer.java [message #644019] |
Thu, 09 December 2010 05:59 |
Lita Messages: 12 Registered: December 2010 |
Junior Member |
|
|
Hi,
I create a file called MySyntaxTransformer.java extends AbstractDeclarativeSemanticModelTransformer to customise the outline view for xtext.
Most of the createNode functions are called, except for one function.
Initially, I use the default setLabel function:
public ContentOutlineNode createNode(
Include semanticNode, ContentOutlineNode parentNode) {
ContentOutlineNode node = super.newOutlineNode(semanticNode, parentNode);
node.setLabel("Include " + node.getLabel());
return node;
}
But it doesn't work but I think that was perhaps because the node label was not there. I then modify the code to:
public ContentOutlineNode createNode(
Include semanticNode, ContentOutlineNode parentNode) {
if (semanticNode.getIncName().getExt() != null)
{
node.setLabel("Include " + semanticNode.getIncName().getExt().getIname());
}
else if (semanticNode.getIncName().getInt() != null)
{
node.setLabel("Include " + semanticNode.getIncName().getInt().getIname());
}
else if (semanticNode.getIncName().getMod() != null)
{
node.setLabel("Include " + semanticNode.getIncName().getMod().getIname());
}
else
{
node.setLabel("Include ");
}
return node;
}
but this particular createNode is not called, while the createNode for other instances of semanticNode are called.
The xtext for this particular input is
Include:
'include' incName=[IncludeType|SYMBOL] ';';
IncludeType:
{IncludeType}
(int=Interface | ext=External | mod=Module);
Interface:
'interface' iname=SYMBOL '{'
( iIncludes+=Include
| iConsts+=Constant
| iMessages+=Message
)*
'}' BlockDeclEnd ;
External:
'external' iname=SYMBOL '{'
( extIncludes+=Include
| extDefines+=Constant
| extResources+=Resource
)*
'}' BlockDeclEnd;
Module:
'module' iname=SYMBOL '{'
( includes+=Include
| defines+=Constant
| elements+=ElementDecl
)*
'}' BlockDeclEnd;
I know the name for Include is a cross reference but that is the requirement of the syntax so I am not sure either to change the xtext or to modify the MySyntaxTransformer.java code.
Thanks in advance for any help or advice!
|
|
|
Powered by
FUDForum. Page generated in 0.02636 seconds