本文整理汇总了Java中org.eclipse.xtext.nodemodel.INode.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java INode.getParent方法的具体用法?Java INode.getParent怎么用?Java INode.getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.nodemodel.INode
的用法示例。
在下文中一共展示了INode.getParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: IEObjectCoveringRegion
import org.eclipse.xtext.nodemodel.INode; //导入方法依赖的package包/类
/***/
@Creates
public IEObjectCoveringRegion IEObjectCoveringRegion() {
final boolean haveRegion = region != null;
int offset = haveRegion ? region.getOffset() : this.matchedOffset;
int length = haveRegion ? region.getLength() : 0;
int endOffset = offset + length;
EObject semanticObject = null;
INode node = NodeModelUtils.findLeafNodeAtOffset(resource.getParseResult().getRootNode(), offset);
while (node != null) {
EObject actualObject = NodeModelUtils.findActualSemanticObjectFor(node);
if (actualObject != null) {
if (haveRegion) {
int nodeEndOffset = node.getEndOffset();
if (nodeEndOffset <= endOffset || semanticObject == null) {
semanticObject = actualObject;
}
if (nodeEndOffset >= endOffset) {
break;
}
} else { // no region given, just a matched offset
if (semanticObject == null) {
semanticObject = actualObject;
break;
}
}
}
node = node.getParent();
}
return new EObjectCoveringRegion(semanticObject, offset);
}
示例2: hasAsParent
import org.eclipse.xtext.nodemodel.INode; //导入方法依赖的package包/类
/**
* Test if directParent is in parent-chain.
*
* @param child
* child to test.
* @param directParent
* parent to look for
* @return true if any parent of child (including child) equals to directParent
*/
private boolean hasAsParent(INode child, ICompositeNode directParent) {
INode parent = child;
while (parent != null) {
if (parent == directParent)
return true;
parent = parent.getParent();
}
return false;
}