mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 16:58:56 +00:00
*** empty log message ***
This commit is contained in:
parent
d9dab783c8
commit
9e5d55916c
1 changed files with 14 additions and 0 deletions
|
@ -120,5 +120,19 @@ public class NodeUtil {
|
|||
}
|
||||
System.out.println("} (" + node.getOffset() + ", " + node.getLength() + ")");
|
||||
}
|
||||
|
||||
public static AbstractNode findLeafNodeAtOffset(CompositeNode parseTreeRootNode, int offset) {
|
||||
for (AbstractNode node : parseTreeRootNode.getChildren()) {
|
||||
if (node.getOffset() + node.getLength() >= offset) {
|
||||
if (node.getOffset() <= offset) {
|
||||
if (node instanceof LeafNode)
|
||||
return (LeafNode) node;
|
||||
else if (node instanceof CompositeNode)
|
||||
return findLeafNodeAtOffset((CompositeNode) node, offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue