Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » createNode is not called for MySyntaxTransformer.java(One of the createNode function is not called for outline view)
createNode is not called for MySyntaxTransformer.java [message #644019] Thu, 09 December 2010 05:59
Lita  is currently offline Lita Friend
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!
Previous Topic:knowing the java package of the model generated classes
Next Topic:Formatting - OneWhitespaceFormatter - How to deactivate?
Goto Forum:
  


Current Time: Fri Apr 26 10:27:51 GMT 2024

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

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

Back to the top