Class SyntheticCompositeNode
- java.lang.Object
-
- org.eclipse.xtext.nodemodel.impl.SyntheticCompositeNode
-
- All Implemented Interfaces:
java.lang.Iterable<INode>,BidiIterable<INode>,BidiTreeIterable<INode>,ICompositeNode,INode
public class SyntheticCompositeNode extends java.lang.Object implements ICompositeNode, BidiTreeIterable<INode>
Unfolds the array of grammar elements that is associated with a composite node.- Noextend:
- This class is not intended to be subclassed by clients.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSyntheticCompositeNode(CompositeNode delegate, int grammarElementIdx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)BidiTreeIterable<INode>getAsTreeIterable()Returns a tree iterable that uses this node as its origin and root instance.BidiIterable<INode>getChildren()Returns an iterable that provides access to the children of the composite node.intgetEndLine()Returns the line number relative to the complete input where the node ends (one based, excluding hidden tokens).intgetEndOffset()Returns the end offset (exclusive) of this node excluding hidden tokens.INodegetFirstChild()Returns the first child of this node.org.eclipse.emf.ecore.EObjectgetGrammarElement()Returns the grammar element that created this node.INodegetLastChild()Returns the last child of this node.java.lang.Iterable<ILeafNode>getLeafNodes()Returns an iterable for all contained leaf nodes.intgetLength()Returns the length of this node excluding hidden tokens.intgetLookAhead()Return the number of tokens that the parser had to peek before it could decide to create this node.INodegetNextSibling()Returns the next sibling ornull.intgetOffset()Returns the offset of this node excluding hidden tokens.ICompositeNodegetParent()Returns the parent of the node ornullif and only if this is the root node.INodegetPreviousSibling()Returns the previous sibling ornull.ICompositeNodegetRootNode()Returns the root node of this parse tree.org.eclipse.emf.ecore.EObjectgetSemanticElement()Returns the nearest semantic object that is associated with the subtree of this node.intgetStartLine()Returns the line number relative to the complete input where the node begins (one based, excluding hidden tokens).SyntaxErrorMessagegetSyntaxErrorMessage()Returns the directly associated syntax error message ornullif none.java.lang.StringgetText()Returns the parsed text that is covered by this node (including hidden tokens).org.eclipse.xtext.util.ITextRegiongetTextRegion()org.eclipse.xtext.util.ITextRegionWithLineInformationgetTextRegionWithLineInformation()Returns aregion with line informationfor this node excluding hidden tokens: anoffsetof this region is the same as anoffsetof this node; alengthof this region is the same as alengthof this node; aline numberof this region is the same as astart lineof this node; anend line numberof this region is the same as anend lineof this node.intgetTotalEndLine()Returns the line number relative to the complete input where the node ends (one based, including hidden tokens).intgetTotalEndOffset()Returns the end offset (exclusive) of this node including hidden tokens.intgetTotalLength()Returns the length of this node including hidden tokens.intgetTotalOffset()Returns the offset of this node including hidden tokens.intgetTotalStartLine()Returns the line number relative to the complete input where the node begins (one based, including hidden tokens).org.eclipse.xtext.util.ITextRegiongetTotalTextRegion()Returns aregionfor this node including hidden tokens: anoffsetof this region is the same as atotal offsetof this node; and alengthof this region is the same as atotal lengthof this node.org.eclipse.xtext.util.ITextRegionWithLineInformationgetTotalTextRegionWithLineInformation()Returns aregion with line informationfor this node including hidden tokens: anoffsetof this region is the same as atotal offsetof this node; alengthof this region is the same as atotal lengthof this node; aline numberof this region is the same as atotal start lineof this node; anend line numberof this region is the same as atotal end lineof this node.booleanhasChildren()Returnstrueif this node has any children.booleanhasDirectSemanticElement()Returnstrueif this node as a directly associated semantic element.inthashCode()booleanhasNextSibling()Returnstrueif this node is not the last child of its parent.booleanhasPreviousSibling()Returnstrueif this node is not the first child of its parent.booleanhasSiblings()Returnstrueif this node has any siblings.BidiTreeIterator<INode>iterator()Returns a tree iterator that can be used forwards and backwards.BidiTreeIterable<INode>reverse()Returns a reverse version of this iterable that can be used forwards and backwards.
-
-
-
Constructor Detail
-
SyntheticCompositeNode
protected SyntheticCompositeNode(CompositeNode delegate, int grammarElementIdx)
-
-
Method Detail
-
getParent
public ICompositeNode getParent()
Description copied from interface:INodeReturns the parent of the node ornullif and only if this is the root node.
-
hasSiblings
public boolean hasSiblings()
Description copied from interface:INodeReturnstrueif this node has any siblings.- Specified by:
hasSiblingsin interfaceINode- Returns:
trueif this node has any siblings.- See Also:
INode.hasPreviousSibling(),INode.hasNextSibling()
-
hasPreviousSibling
public boolean hasPreviousSibling()
Description copied from interface:INodeReturnstrueif this node is not the first child of its parent.- Specified by:
hasPreviousSiblingin interfaceINode- Returns:
trueif this node has a previous sibling thusINode.getPreviousSibling()will not returnnull.
-
hasNextSibling
public boolean hasNextSibling()
Description copied from interface:INodeReturnstrueif this node is not the last child of its parent.- Specified by:
hasNextSiblingin interfaceINode- Returns:
trueif this node has a next sibling thusINode.getNextSibling()will not returnnull.
-
getPreviousSibling
public INode getPreviousSibling()
Description copied from interface:INodeReturns the previous sibling ornull. The result has the sameparentas this node if it is notnull.- Specified by:
getPreviousSiblingin interfaceINode- Returns:
- the previous sibling or
null. - See Also:
INode.hasPreviousSibling(),INode.hasSiblings()
-
getNextSibling
public INode getNextSibling()
Description copied from interface:INode- Specified by:
getNextSiblingin interfaceINode- Returns:
- the next sibling or
null. - See Also:
INode.hasNextSibling(),INode.hasSiblings()
-
getRootNode
public ICompositeNode getRootNode()
Description copied from interface:INodeReturns the root node of this parse tree. Will not returnnullin a consistent tree.- Specified by:
getRootNodein interfaceINode- Returns:
- the root node of this parse tree. Will not return
nullin a consistent tree.
-
getTotalOffset
public int getTotalOffset()
Description copied from interface:INodeReturns the offset of this node including hidden tokens.- Specified by:
getTotalOffsetin interfaceINode- Returns:
- the offset of this node including hidden tokens.
-
getOffset
public int getOffset()
Description copied from interface:INodeReturns the offset of this node excluding hidden tokens. If this node is a hidden leaf node or a composite node that does only contain hidden leaf nodes, the total offset is returned.
-
getLength
public int getLength()
Description copied from interface:INodeReturns the length of this node excluding hidden tokens. If this node is a hidden leaf node, the total length is returned.
-
getTotalStartLine
public int getTotalStartLine()
Description copied from interface:INodeReturns the line number relative to the complete input where the node begins (one based, including hidden tokens).- Specified by:
getTotalStartLinein interfaceINode- Returns:
- the line number relative to the complete input where the node begins.
-
getEndLine
public int getEndLine()
Description copied from interface:INodeReturns the line number relative to the complete input where the node ends (one based, excluding hidden tokens).- Specified by:
getEndLinein interfaceINode- Returns:
- the line number relative to the complete input where the node ends.
-
getStartLine
public int getStartLine()
Description copied from interface:INodeReturns the line number relative to the complete input where the node begins (one based, excluding hidden tokens).- Specified by:
getStartLinein interfaceINode- Returns:
- the line number relative to the complete input where the node begins.
-
getTotalEndLine
public int getTotalEndLine()
Description copied from interface:INodeReturns the line number relative to the complete input where the node ends (one based, including hidden tokens).- Specified by:
getTotalEndLinein interfaceINode- Returns:
- the line number relative to the complete input where the node ends.
-
getTotalLength
public int getTotalLength()
Description copied from interface:INodeReturns the length of this node including hidden tokens.- Specified by:
getTotalLengthin interfaceINode- Returns:
- the length of this node including hidden tokens.
-
getTotalEndOffset
public int getTotalEndOffset()
Description copied from interface:INodeReturns the end offset (exclusive) of this node including hidden tokens. Yields the same result asoffset+lengthbut may be more efficient.- Specified by:
getTotalEndOffsetin interfaceINode- Returns:
- the end offset (exclusive) of this node including hidden tokens.
-
getText
public java.lang.String getText()
Description copied from interface:INodeReturns the parsed text that is covered by this node (including hidden tokens). The result is nevernullbut may be empty.
-
getGrammarElement
public org.eclipse.emf.ecore.EObject getGrammarElement()
Description copied from interface:INodeReturns the grammar element that created this node. May returnnullin case of unrecoverable syntax errors. This happens usually when a keyword occurred at an unexpected offset.- Specified by:
getGrammarElementin interfaceINode- Returns:
- the grammar element that created this node. May return
null.
-
getSemanticElement
public org.eclipse.emf.ecore.EObject getSemanticElement()
Description copied from interface:INodeReturns the nearest semantic object that is associated with the subtree of this node. May returnnullwhenever the parser refused to create any objects due to unrecoverable errors. Implementations will usually walk up the node tree to find the semantic object. As the node model structure does not reflect the containment structure of the semantic object graph, clients should usually use the utilities inNodeModelUtilsto obtain the semantic instance.- Specified by:
getSemanticElementin interfaceINode- Returns:
- the nearest semantic object that is associated with the subtree of this node. May return
null. - See Also:
INode.hasDirectSemanticElement(),NodeModelUtils.findActualSemanticObjectFor(INode)
-
hasDirectSemanticElement
public boolean hasDirectSemanticElement()
Description copied from interface:INodeReturnstrueif this node as a directly associated semantic element.- Specified by:
hasDirectSemanticElementin interfaceINode- Returns:
trueif this node as a directly associated semantic element.- See Also:
INode.getSemanticElement()
-
getSyntaxErrorMessage
public SyntaxErrorMessage getSyntaxErrorMessage()
Description copied from interface:INodeReturns the directly associated syntax error message ornullif none.- Specified by:
getSyntaxErrorMessagein interfaceINode- Returns:
- the directly associated syntax error message. May return
null.
-
getAsTreeIterable
public BidiTreeIterable<INode> getAsTreeIterable()
Description copied from interface:INodeReturns a tree iterable that uses this node as its origin and root instance. Its iterator will not return any siblings of this root. However, the first element returned byBidiTreeIterator.previous()orBidiTreeIterator.next()will be this instance.- Specified by:
getAsTreeIterablein interfaceINode- Returns:
- a tree iterable where this node represents the root instance.
-
iterator
public BidiTreeIterator<INode> iterator()
Description copied from interface:BidiTreeIterableReturns a tree iterator that can be used forwards and backwards.- Specified by:
iteratorin interfaceBidiIterable<INode>- Specified by:
iteratorin interfaceBidiTreeIterable<INode>- Specified by:
iteratorin interfacejava.lang.Iterable<INode>- Returns:
- an iterator. Never returns
null.
-
getLeafNodes
public java.lang.Iterable<ILeafNode> getLeafNodes()
Description copied from interface:INodeReturns an iterable for all contained leaf nodes. Nevernull.- Specified by:
getLeafNodesin interfaceINode- Returns:
- an iterable for all contained leaf nodes. Never
null.
-
reverse
public BidiTreeIterable<INode> reverse()
Description copied from interface:BidiTreeIterableReturns a reverse version of this iterable that can be used forwards and backwards. In other words, an iterator provided by the reverse iterable will delegate its
hasNext()andnext()invocations toBidiIterator.hasPrevious()andBidiIterator.previous()respectively.This allows clients to iterate backwards by means of the enhanced for-loop:
for(T t: iterable.reverse()) { // do something with t }- Specified by:
reversein interfaceBidiIterable<INode>- Specified by:
reversein interfaceBidiTreeIterable<INode>- Returns:
- the reversed iterable. Never returns
null.
-
getChildren
public BidiIterable<INode> getChildren()
Description copied from interface:ICompositeNodeReturns an iterable that provides access to the children of the composite node. Will never returnnullbut may be empty.- Specified by:
getChildrenin interfaceICompositeNode- Returns:
- an iterable that provides access to the children of the composite node.
- See Also:
ICompositeNode.hasChildren(),ICompositeNode.getFirstChild(),ICompositeNode.getLastChild()
-
hasChildren
public boolean hasChildren()
Description copied from interface:ICompositeNodeReturnstrueif this node has any children.- Specified by:
hasChildrenin interfaceICompositeNode- Returns:
trueif this node has any children.- See Also:
ICompositeNode.getChildren(),ICompositeNode.getFirstChild(),ICompositeNode.getLastChild()
-
getFirstChild
public INode getFirstChild()
Description copied from interface:ICompositeNodeReturns the first child of this node. May benullor may be the same as thelast child.- Specified by:
getFirstChildin interfaceICompositeNode- Returns:
- the first child of this node if any.
- See Also:
ICompositeNode.hasChildren(),ICompositeNode.getChildren()
-
getLastChild
public INode getLastChild()
Description copied from interface:ICompositeNodeReturns the last child of this node. May benullor may be the same as thefirst child.- Specified by:
getLastChildin interfaceICompositeNode- Returns:
- the last child of this node if any.
- See Also:
ICompositeNode.hasChildren(),ICompositeNode.getChildren()
-
getLookAhead
public int getLookAhead()
Description copied from interface:ICompositeNodeReturn the number of tokens that the parser had to peek before it could decide to create this node. Never negative. Clients will usually not have to deal withICompositeNode.getLookAhead().- Specified by:
getLookAheadin interfaceICompositeNode- Returns:
- the number of tokens that the parser had to peek before it could decide to create this node.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getTextRegion
public org.eclipse.xtext.util.ITextRegion getTextRegion()
Description copied from interface:INodeReturns a
regionfor this node excluding hidden tokens:- an
offsetof this region is the same as anoffsetof this node; - and a
lengthof this region is the same as alengthof this node.
This method could be more efficient than calculating an
offsetand alengthof this node separately.- Specified by:
getTextRegionin interfaceINode- Returns:
- a
regionfor this node excluding hidden tokens - Since:
- 2.5
- an
-
getTotalTextRegion
public org.eclipse.xtext.util.ITextRegion getTotalTextRegion()
Description copied from interface:INodeReturns a
regionfor this node including hidden tokens:- an
offsetof this region is the same as atotal offsetof this node; - and a
lengthof this region is the same as atotal lengthof this node.
This method could be more efficient than calculating a
total offsetand atotal lengthof this node separately.- Specified by:
getTotalTextRegionin interfaceINode- Returns:
- a
regionfor this node including hidden tokens - Since:
- 2.5
- an
-
getTextRegionWithLineInformation
public org.eclipse.xtext.util.ITextRegionWithLineInformation getTextRegionWithLineInformation()
Description copied from interface:INodeReturns a
region with line informationfor this node excluding hidden tokens:- an
offsetof this region is the same as anoffsetof this node; - a
lengthof this region is the same as alengthof this node; - a
line numberof this region is the same as astart lineof this node; - an
end line numberof this region is the same as anend lineof this node.
A
line numberand anend line numberof the returned region are one based.This method could be more efficient than calculating an
offset, alength, astart lineand anend lineof this node separately.- Specified by:
getTextRegionWithLineInformationin interfaceINode- Returns:
- a
region with line informationfor this node excluding hidden tokens - Since:
- 2.5
- an
-
getTotalTextRegionWithLineInformation
public org.eclipse.xtext.util.ITextRegionWithLineInformation getTotalTextRegionWithLineInformation()
Description copied from interface:INodeReturns a
region with line informationfor this node including hidden tokens:- an
offsetof this region is the same as atotal offsetof this node; - a
lengthof this region is the same as atotal lengthof this node; - a
line numberof this region is the same as atotal start lineof this node; - an
end line numberof this region is the same as atotal end lineof this node.
A
line numberand anend line numberof the returned region are one based.This method could be more efficient than calculating a
total offset, atotal length, atotal start lineand atotal end lineof this node separately.- Specified by:
getTotalTextRegionWithLineInformationin interfaceINode- Returns:
- a
region with line informationfor this node including hidden tokens - Since:
- 2.5
- an
-
getEndOffset
public int getEndOffset()
Description copied from interface:INodeReturns the end offset (exclusive) of this node excluding hidden tokens. Yields the same result asoffset+lengthbut may be more efficient.- Specified by:
getEndOffsetin interfaceINode- Returns:
- the end offset (exclusive) of this node excluding hidden tokens.
- Since:
- 2.5
-
-