当前位置: 首页>>代码示例>>Java>>正文


Java ILeafNode.getParent方法代码示例

本文整理汇总了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);
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:XbaseValidator.java

示例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);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:TokenSequencePreservingPartialParsingHelper.java

示例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();
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:19,代码来源:XtextLinkingService.java

示例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);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:NodeModelUtilsTest.java

示例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;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:EntryPointFinder.java


注:本文中的org.eclipse.xtext.nodemodel.ILeafNode.getParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。