本文整理匯總了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;
}