firstChild attribute. [message #757708] |
Mon, 21 November 2011 10:20 |
haceface Messages: 5 Registered: November 2011 |
Junior Member |
|
|
Hey,
I would like to get the firstChild attribute of the INode but i just can't find a way how.
public void provideHighlightingFor(final XtextResource resource, IHighlightedPositionAcceptor acceptor) {
if( resource == null || resource.getParseResult() == null ) return;
INode root = resource.getParseResult().getRootNode();
BidiTreeIterator<INode> it = root.getAsTreeIterable().iterator();
while( it.hasNext() )
{
INode node = it.next();
if ( node instanceof CompositeNodeWithSemanticElement && node.getSemanticElement() instanceof Object
) {
setStyles( acceptor, it, OBJECT_ST);
setStyles( acceptor, node.getAsTreeIterable().reverse().iterator(), null, OBJECT_ST );
}
else if ( node instanceof CompositeNodeWithSemanticElement && node.getSemanticElement() instanceof Array) {
setStyles( acceptor, it, ARRAY_ST);
setStyles( acceptor, node.getAsTreeIterable().reverse().iterator(), null, ARRAY_ST );
}
else if( node instanceof CompositeNodeWithSemanticElement && node.getSemanticElement() instanceof mainObjectType)
{
setStyles( acceptor, it, OBJECT_TP);
???//node.getfirstChild()???
}
}
}
Do you know what's the problem with my code since i can't use it. thank you.
|
|
|
Re: firstChild attribute. [message #758202 is a reply to message #757708] |
Tue, 22 November 2011 10:23 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
I don't know what you are actually trying to do but there's usually _no_
need to cast the implementation classes for nodes. Please use INode,
ICompositeNode and ILeafNode. They do what they promise in the javadocs.
ICompositeNode#getFirstChild is probably what you are looking for. Please
note there #getLastChild, too.
Regards,
Sebastian
--
Need professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
On Mon, 21 Nov 2011 11:20:19 +0100, haceface <forums-noreply@eclipse.org>
wrote:
> Hey,
>
> I would like to get the firstChild attribute of the INode but i just
> can't find a way how. public void provideHighlightingFor(final
> XtextResource resource, IHighlightedPositionAcceptor acceptor) {
> if( resource == null || resource.getParseResult() == null ) return;
> INode root = resource.getParseResult().getRootNode();
> BidiTreeIterator<INode> it = root.getAsTreeIterable().iterator();
> while( it.hasNext() )
> {
> INode node = it.next();
> if ( node instanceof CompositeNodeWithSemanticElement &&
> node.getSemanticElement() instanceof Object
> ) {
> setStyles( acceptor, it, OBJECT_ST);
> setStyles( acceptor, node.getAsTreeIterable().reverse().iterator(),
> null, OBJECT_ST );
> } else if ( node instanceof CompositeNodeWithSemanticElement &&
> node.getSemanticElement() instanceof Array) {
> setStyles( acceptor, it, ARRAY_ST);
> setStyles( acceptor, node.getAsTreeIterable().reverse().iterator(),
> null, ARRAY_ST );
> } else if( node instanceof CompositeNodeWithSemanticElement &&
> node.getSemanticElement() instanceof mainObjectType)
> {
> setStyles( acceptor, it, OBJECT_TP);
> ???//node.getfirstChild()???
> }
> }
> }
>
> Do you know what's the problem with my code since i can't use it. thank
> you.
|
|
|
Powered by
FUDForum. Page generated in 0.02832 seconds