本文整理汇总了Java中org.eclipse.xtext.nodemodel.ILeafNode.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java ILeafNode.getParent方法的具体用法?Java ILeafNode.getParent怎么用?Java ILeafNode.getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.nodemodel.ILeafNode
的用法示例。
在下文中一共展示了ILeafNode.getParent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkNoJavaStyleTypeCasting
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
protected void checkNoJavaStyleTypeCasting(INode node) {
BidiTreeIterator<INode> iterator = node.getAsTreeIterable().reverse().iterator();
ILeafNode child = getFirstLeafNode(iterator);
if (child != null && child.getGrammarElement() == grammarAccess.getXParenthesizedExpressionAccess().getRightParenthesisKeyword_2()) {
INode expressionNode = getNode(iterator, grammarAccess.getXParenthesizedExpressionAccess().getXExpressionParserRuleCall_1());
EObject semanticObject = NodeModelUtils.findActualSemanticObjectFor(expressionNode);
if (semanticObject instanceof XFeatureCall || semanticObject instanceof XMemberFeatureCall) {
XAbstractFeatureCall featureCall = (XAbstractFeatureCall) semanticObject;
if (featureCall.isTypeLiteral()) {
ICompositeNode parenthesizedNode = child.getParent();
ITextRegion parenthesizedRegion = parenthesizedNode.getTextRegion();
addIssue("Use 'as' keyword for type casting.", featureCall, parenthesizedRegion.getOffset(), parenthesizedRegion.getLength(), JAVA_STYLE_TYPE_CAST);
}
}
}
}
示例2: calculatePartialParsingPointers
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
protected PartialParsingPointers calculatePartialParsingPointers(ICompositeNode oldRoot, ILeafNode left, ILeafNode right) {
ICompositeNode result = right.getParent();
while(result.getTotalOffset() > left.getTotalOffset()) {
result = result.getParent();
}
List<ICompositeNode> nodesEnclosingRegion = getAllParents(result);
Range range = new Range(left.getTotalOffset(), right.getTotalEndOffset());
List<ICompositeNode> validReplaceRootNodes = internalFindValidReplaceRootNodeForChangeRegion(nodesEnclosingRegion);
filterInvalidRootNodes(validReplaceRootNodes);
if (validReplaceRootNodes.isEmpty()) {
validReplaceRootNodes = Collections.singletonList(oldRoot);
}
return new PartialParsingPointers(oldRoot, range.getOffset(), range.getLength(), validReplaceRootNodes, nodesEnclosingRegion);
}
示例3: getLinkedMetaModel
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
private List<EObject> getLinkedMetaModel(TypeRef context, EReference ref, ILeafNode text) throws IllegalNodeException {
final ICompositeNode parentNode = text.getParent();
BidiIterator<INode> iterator = parentNode.getChildren().iterator();
while(iterator.hasPrevious()) {
INode child = iterator.previous();
if (child instanceof ILeafNode) {
ILeafNode leaf = (ILeafNode) child;
if (text == leaf)
return super.getLinkedObjects(context, ref, text);
if (!(leaf.getGrammarElement() instanceof Keyword) && !leaf.isHidden()) {
IScope scope = getScope(context, ref);
return XtextMetamodelReferenceHelper.findBestMetamodelForType(
context, text.getText(), leaf.getText(), scope);
}
}
}
return Collections.emptyList();
}
示例4: testFindLeafNodeAtOffset_1
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
@Test public void testFindLeafNodeAtOffset_1() throws Exception {
String grammarText = "grammar foo.Bar with org.eclipse.xtext.common.Terminals generate foo 'bar' Model : (name=ID value=ID);";
Grammar grammar = (Grammar) getModel(grammarText);
int equalsSign = grammarText.indexOf('=');
ICompositeNode grammarNode = NodeModelUtils.getNode(grammar);
ILeafNode leafNodeAtOffset = NodeModelUtils.findLeafNodeAtOffset(grammarNode, equalsSign);
assertEquals("=", leafNodeAtOffset.getText());
boolean syntheticNodeSeen = false;
INode parent = leafNodeAtOffset.getParent();
while(parent != null) {
// walk up the tree to make sure we call #findLeafNodeAtOffset with synthetic nodes, too
ILeafNode otherLeafNode = NodeModelUtils.findLeafNodeAtOffset(parent, equalsSign);
assertSame(leafNodeAtOffset, otherLeafNode);
if (parent instanceof SyntheticCompositeNode)
syntheticNodeSeen = true;
parent = parent.getParent();
}
assertTrue(syntheticNodeSeen);
}
示例5: findEntryPoint
import org.eclipse.xtext.nodemodel.ILeafNode; //导入方法依赖的package包/类
public ICompositeNode findEntryPoint(IParseResult parseResult, int offset) {
ICompositeNode rootNode = parseResult.getRootNode();
if (rootNode.getTotalLength() == offset) {
return null;
}
ILeafNode leafNode = NodeModelUtils.findLeafNodeAtOffset(rootNode, offset);
ICompositeNode parent = leafNode.getParent();
ICompositeNode result = findEntryPoint(parent, offset);
if (result != null) {
EObject grammarElement = result.getGrammarElement();
if (grammarElement instanceof AbstractElement) {
return result;
}
}
return null;
}