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


Java NodeModelUtils.findNodesForFeature方法代码示例

本文整理汇总了Java中org.eclipse.xtext.nodemodel.util.NodeModelUtils.findNodesForFeature方法的典型用法代码示例。如果您正苦于以下问题:Java NodeModelUtils.findNodesForFeature方法的具体用法?Java NodeModelUtils.findNodesForFeature怎么用?Java NodeModelUtils.findNodesForFeature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.xtext.nodemodel.util.NodeModelUtils的用法示例。


在下文中一共展示了NodeModelUtils.findNodesForFeature方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doGetNode

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
protected INode doGetNode(EObject object, EStructuralFeature feature, int idx) {
	if (object == null)
		return null;
	if (feature == null) {
		INode result = NodeModelUtils.findActualNodeFor(object);
		if (result != null) {
			return result;
		}
		return doGetNode(object.eContainer(), object.eContainmentFeature(), -1);
	}
		
	List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(object, feature);
	if (nodesForFeature.isEmpty()) {
		return doGetNode(object, null, -1);
	}
	if (idx == -1 /* INSIGNIFICANT_INDEX */) {
		idx = 0;
	}
	if (nodesForFeature.size() > idx ) {
		return nodesForFeature.get(idx);
	}
	return doGetNode(object, null, -1);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:24,代码来源:EObjectDiagnosticImpl.java

示例2: getLegacyImportSyntax

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
@Override
public String getLegacyImportSyntax(XImportDeclaration importDeclaration) {
	List<INode> list = NodeModelUtils.findNodesForFeature(importDeclaration, XtypePackage.Literals.XIMPORT_DECLARATION__IMPORTED_TYPE);
	if (list.isEmpty()) {
		return null;
	}
	INode singleNode = list.get(0);
	if (singleNode.getText().indexOf('$') < 0) {
		return null;
	}
	StringBuilder sb = new StringBuilder();
	for(ILeafNode node: singleNode.getLeafNodes()) {
		if (!node.isHidden()) {
			sb.append(node.getText().replace("^", ""));
		}
	}
	return sb.toString();
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:DefaultImportsConfiguration.java

示例3: getNodeForModifier

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
/**
 * Returns the INode for a given modifier. This is intended for computing error message regions, quick fixes, etc.
 */
public static final ILeafNode getNodeForModifier(ModifiableElement elem, int index) {
	final List<INode> nodes = NodeModelUtils.findNodesForFeature(elem,
			N4JSPackage.eINSTANCE.getModifiableElement_DeclaredModifiers());
	if (index >= 0 && index < nodes.size()) {
		final Iterable<ILeafNode> leafNodes = nodes.get(index).getLeafNodes();
		for (ILeafNode currLeaf : leafNodes) {
			if (!currLeaf.isHidden())
				return currLeaf;
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:16,代码来源:ModifierUtils.java

示例4: getPropertyAsString

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
private String getPropertyAsString(ParameterizedPropertyAccessExpression propAccessExpr) {
	final StringBuilder sb = new StringBuilder();
	for (INode node : NodeModelUtils.findNodesForFeature(propAccessExpr,
			N4JSPackage.eINSTANCE.getParameterizedPropertyAccessExpression_Property())) {
		sb.append(NodeModelUtils.getTokenText(node));
	}
	return sb.toString();
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:9,代码来源:PreparationStep.java

示例5: test_05

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
@Test public void test_05() throws Exception {
	Model model = (Model) getModel("model id { element withNumbers01 }");
	assertEquals("id", model.getName());
	Element element = model.getElements().get(0);
	assertEquals("withNumbers01", element.getName());
	List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(element, InheritanceTestPackage.Literals.ELEMENT__NAME);
	assertTrue(nodesForFeature.size() == 1);
	assertEquals("withNumbers01", nodesForFeature.get(0).getText());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:10,代码来源:ParserTest.java

示例6: getFirstParseTreeNode

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
/**
 * Gets the first node from the parse tree for given semantic object and structural feature.
 * 
 * @param semanticElement
 *          the semantic element
 * @param feature
 *          the structural feature
 * @return the first parse tree node or {@code null} if none found
 */
private INode getFirstParseTreeNode(final EObject semanticElement, final EStructuralFeature feature) {
  if (feature == null) {
    return NodeModelUtils.findActualNodeFor(semanticElement);
  }
  List<INode> nodes = NodeModelUtils.findNodesForFeature(semanticElement, feature);
  if (!nodes.isEmpty()) {
    return nodes.get(0);
  }
  return null;
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:20,代码来源:SemanticHighlightingCalculator.java

示例7: test_02

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
@Test public void test_02() throws Exception {
	Model model = (Model) getModel("model id { element inheritedIdSyntax }");
	assertEquals("id", model.getName());
	Element element = model.getElements().get(0);
	assertEquals("inheritedIdSyntax", element.getName());
	List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(element, InheritanceTestPackage.Literals.ELEMENT__NAME);
	assertTrue(nodesForFeature.size() == 1);
	assertEquals("inheritedIdSyntax", nodesForFeature.get(0).getText());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:10,代码来源:ParserTest.java

示例8: test_03

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
@Test public void test_03() throws Exception {
	Model model = (Model) getModel("model id { element 'string' }");
	assertEquals("id", model.getName());
	Element element = model.getElements().get(0);
	assertEquals("string", element.getName());
	List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(element, InheritanceTestPackage.Literals.ELEMENT__NAME);
	assertTrue(nodesForFeature.size() == 1);
	assertEquals("'string'", nodesForFeature.get(0).getText());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:10,代码来源:ParserTest.java

示例9: getImportedTypeName

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
@Override
public String getImportedTypeName() {
	String result = getImportedNamespace();
	if (result == null) {
		if (this.eIsSet(XtypePackage.Literals.XIMPORT_DECLARATION__IMPORTED_TYPE)) {
			JvmType unresolvedType = (JvmType) this.eGet(XtypePackage.Literals.XIMPORT_DECLARATION__IMPORTED_TYPE, false);
			if(!unresolvedType.eIsProxy())
				return unresolvedType.getIdentifier();
			List<INode> list = NodeModelUtils.findNodesForFeature(this,
					XtypePackage.Literals.XIMPORT_DECLARATION__IMPORTED_TYPE);
			StringBuilder sb = new StringBuilder();
			for (INode iNode : list) {
				sb.append(NodeModelUtils.getTokenText(iNode).replace("^", ""));
			}
			result = sb.toString().replace(" ", "");
			if (isStatic()) {
				return trim(result, 1);
			}
			return result;
		}
		return null;
	}
	if (isWildcard()) {
		return trim(result, 2);
	}
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:28,代码来源:XImportDeclarationImplCustom.java

示例10: getCrossReferenceNode

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
protected INode getCrossReferenceNode(EObject context, EReference reference, EObject target) {
	List<INode> nodes = NodeModelUtils.findNodesForFeature(context, reference);
	if (!nodes.isEmpty()) {
		if (reference.isMany()) {
			int index = ((List<?>) context.eGet(reference, false)).indexOf(target);
			if (index >= 0 && index < nodes.size())
				return nodes.get(index);
		} else {
			return nodes.get(0);
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:14,代码来源:CrossRefTest.java

示例11: test_01

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
@Test public void test_01() throws Exception {
	Model model = (Model) getModel("model id { element id }");
	assertEquals("id", model.getName());
	Element element = model.getElements().get(0);
	assertEquals("id", element.getName());
	List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(element, InheritanceTestPackage.Literals.ELEMENT__NAME);
	assertTrue(nodesForFeature.size() == 1);
	assertEquals("id", nodesForFeature.get(0).getText());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:10,代码来源:ParserTest.java

示例12: highlightFeature

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
/**
 * Highlights an object at the position of the given {@link EStructuralFeature}
 */
protected void highlightFeature(IHighlightedPositionAcceptor acceptor, EObject object, EStructuralFeature feature,
		String... styleIds) {
	List<INode> children = NodeModelUtils.findNodesForFeature(object, feature);
	if (children.size() > 0)
		highlightNode(acceptor, children.get(0), styleIds);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:10,代码来源:DefaultSemanticHighlightingCalculator.java

示例13: testAssignment_rhs_01

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
@Test public void testAssignment_rhs_01() throws Exception {
	String text = "a=b";
	XAssignment assignment = (XAssignment) expression(text);
	List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(assignment, XbasePackage.Literals.XASSIGNMENT__VALUE);
	assertEquals(1, nodesForFeature.size());
	String nodeText = nodesForFeature.get(0).getText();
	assertEquals("b", nodeText);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:XbaseNodeModelTest.java

示例14: testAssignment_rhs_02

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
@Test public void testAssignment_rhs_02() throws Exception {
	String text = "a=b+=c";
	XAssignment assignment = (XAssignment) expression(text);
	List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(assignment, XbasePackage.Literals.XASSIGNMENT__VALUE);
	assertEquals(1, nodesForFeature.size());
	String nodeText = nodesForFeature.get(0).getText();
	assertEquals("b+=c", nodeText);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:XbaseNodeModelTest.java

示例15: testAssignment_rhs_03

import org.eclipse.xtext.nodemodel.util.NodeModelUtils; //导入方法依赖的package包/类
@Test public void testAssignment_rhs_03() throws Exception {
	String text = "a=b+=c";
	XBinaryOperation assignment = (XBinaryOperation) ((XAssignment) expression(text)).getValue();
	List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(assignment, XbasePackage.Literals.XBINARY_OPERATION__RIGHT_OPERAND);
	assertEquals(1, nodesForFeature.size());
	String nodeText = nodesForFeature.get(0).getText();
	assertEquals("c", nodeText);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:XbaseNodeModelTest.java


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