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


Java TreeIterator.prune方法代码示例

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


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

示例1: findByNestedRuleCall

import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected <T> List<T> findByNestedRuleCall(Class<T> clazz, AbstractRule... rule) {
	Set<AbstractRule> rls = new HashSet<AbstractRule>(Arrays.asList(rule));
	ArrayList<T> r = new ArrayList<T>();
	for (AbstractRule ar : getRules()) {
		TreeIterator<EObject> i = ar.eAllContents();
		while (i.hasNext()) {
			EObject o = i.next();
			if (clazz.isInstance(o)) {
				TreeIterator<EObject> ct = o.eAllContents();
				while (ct.hasNext()) {
					EObject cto = ct.next();
					if (cto instanceof RuleCall && rls.contains(((RuleCall) cto).getRule())) {
						r.add((T) o);
						break;
					}
				}
				i.prune();
			}
		}
	}
	return r;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:24,代码来源:AbstractElementFinder.java

示例2: collectNodes

import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
/**
 * Search entire containment tree below 'root' for objects of type 'cls'. If last argument is <code>false</code>,
 * then sub trees below a matching node won't be searched.
 */
public static final <T extends EObject> List<T> collectNodes(EObject root, Class<T> cls,
		boolean searchForNestedNodes) {
	final List<T> result = new ArrayList<>();
	final TreeIterator<EObject> iter = root.eAllContents();
	while (iter.hasNext()) {
		final EObject obj = iter.next();
		if (cls.isAssignableFrom(obj.getClass())) {
			@SuppressWarnings("unchecked")
			final T objCasted = (T) obj;
			result.add(objCasted);
			if (!searchForNestedNodes)
				iter.prune();
		}
	}
	return result;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:21,代码来源:TranspilerUtils.java

示例3: collectNodesWithinSameThisEnvironment

import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
/**
 * root usually a function or other ThisProviding environment.
 *
 * @param root
 *            function or method.
 * @param cls
 *            Type of element to report.
 * @return nodes of (sub-)type cls in the same this-environment
 */
public static final <T extends EObject> List<T> collectNodesWithinSameThisEnvironment(EObject root, Class<T> cls) {
	final List<T> result = new ArrayList<>();
	final TreeIterator<EObject> iter = root.eAllContents();
	while (iter.hasNext()) {
		final EObject obj = iter.next();
		if (cls.isAssignableFrom(obj.getClass())) {
			@SuppressWarnings("unchecked")
			final T objCasted = (T) obj;
			result.add(objCasted);
		}
		// check for same environment
		if (obj instanceof ThisArgProvider) {
			iter.prune();
		}
	}
	return result;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:27,代码来源:TranspilerUtils.java

示例4: buildMap

import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
@Override
protected void buildMap(Resource resource, Map<QualifiedName, IEObjectDescription> elements) {
	IDefaultResourceDescriptionStrategy strategy = ((XtextResource) resource).getResourceServiceProvider()
			.get(IDefaultResourceDescriptionStrategy.class);
	TreeIterator<EObject> allProperContents = EcoreUtil.getAllProperContents(resource, false);
	IAcceptor<IEObjectDescription> acceptor = new IAcceptor<IEObjectDescription>() {
		@Override
		public void accept(IEObjectDescription description) {
			elements.put(description.getQualifiedName(), description);
		}
	};
	while (allProperContents.hasNext()) {
		EObject content = allProperContents.next();
		if (!strategy.createEObjectDescriptions(content, acceptor)) {
			allProperContents.prune();
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:19,代码来源:GlobalObjectScope.java

示例5: getSuperTypeImports

import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
protected List<ImportNormalizer> getSuperTypeImports(Resource res, EReference reference) {
	List<ImportNormalizer> result = Lists.newArrayList();
	TreeIterator<EObject> allContents = res.getAllContents();
	while (allContents.hasNext()) {
		EObject next = allContents.next();
		if (next instanceof ContractDefinition) {
			ContractDefinition contract = (ContractDefinition) next;
			EList<ComplexType> superTypes = contract.getSuperTypes();
			for (ComplexType complexType : superTypes) {
				// if (complexType.eIsProxy() || complexType.getName() ==
				// null)
				// continue;
				ImportNormalizer resolver = createImportedNamespaceResolver(complexType.getName() + ".*", false);
				result.add(resolver);
			}
			allContents.prune();
		}
	}
	return result;
}
 
开发者ID:Yakindu,项目名称:solidity-ide,代码行数:21,代码来源:SolidityImportedNamespaceAwareLocalScopeProvider.java

示例6: checkIsValidConstructorArgument

import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
protected void checkIsValidConstructorArgument(XExpression argument, JvmType containerType) {
	TreeIterator<EObject> iterator = EcoreUtil2.eAll(argument);
	while(iterator.hasNext()) {
		EObject partOfArgumentExpression = iterator.next();
		if (partOfArgumentExpression instanceof XFeatureCall || partOfArgumentExpression instanceof XMemberFeatureCall) {				
			XAbstractFeatureCall featureCall = (XAbstractFeatureCall) partOfArgumentExpression;
			XExpression actualReceiver = featureCall.getActualReceiver();
			if(actualReceiver instanceof XFeatureCall && ((XFeatureCall)actualReceiver).getFeature() == containerType) {
				JvmIdentifiableElement feature = featureCall.getFeature();
				if (feature != null && !feature.eIsProxy()) {
					if (feature instanceof JvmField) {
						if (!((JvmField) feature).isStatic())
							error("Cannot refer to an instance field " + feature.getSimpleName() + " while explicitly invoking a constructor", 
									partOfArgumentExpression, null, INVALID_CONSTRUCTOR_ARGUMENT);
					} else if (feature instanceof JvmOperation) {
						if (!((JvmOperation) feature).isStatic())
							error("Cannot refer to an instance method while explicitly invoking a constructor", 
									partOfArgumentExpression, null, INVALID_CONSTRUCTOR_ARGUMENT);	
					}
				}
			}
		} else if(isLocalClassSemantics(partOfArgumentExpression)) {
			iterator.prune();
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:27,代码来源:XbaseValidator.java

示例7: isImplicitReturn

import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
protected boolean isImplicitReturn(ITypeComputationResult expressionResult) {
	int flags = expressionResult.getConformanceFlags();
	if ((ConformanceFlags.NO_IMPLICIT_RETURN & flags) != 0) {
		return false;
	}
	XExpression expression = expressionResult.getExpression();
	if (expression == null) {
		return true;
	}
	if (expression.eClass() == XbasePackage.Literals.XRETURN_EXPRESSION) {
		return false;
	}
	TreeIterator<EObject> contents = expression.eAllContents();
	while (contents.hasNext()) {
		EObject next = contents.next();
		if (next.eClass() == XbasePackage.Literals.XRETURN_EXPRESSION) {
			return false;
		}
		if (next.eClass() == XbasePackage.Literals.XCLOSURE) {
			contents.prune();
		}
	}
	return true;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:25,代码来源:ClosureWithExpectationHelper.java

示例8: canCompileToJavaLambda

import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
protected boolean canCompileToJavaLambda(XClosure closure, LightweightTypeReference typeRef, JvmOperation operation) {
	if (!typeRef.isInterfaceType())
		return false;
	
	if (!operation.getTypeParameters().isEmpty())
		return false;
	
	TreeIterator<EObject> iterator = closure.eAllContents();
	JvmType jvmType = typeRef.getType();
	while (iterator.hasNext()) {
		EObject obj = iterator.next();
		if (obj instanceof XClosure) {
			iterator.prune();
		} else if (obj instanceof XFeatureCall && isReferenceToSelf((XFeatureCall) obj, jvmType)) {
			return false;
		}
	}
	return true;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:20,代码来源:XbaseCompiler.java

示例9: ruleContainsAssignedAction

import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
protected boolean ruleContainsAssignedAction(AbstractRule rule, Set<AbstractRule> visited) {
	if (!visited.add(rule))
		return false;
	TreeIterator<EObject> i = rule.eAllContents();
	while (i.hasNext()) {
		EObject o = i.next();
		if (o instanceof Action && ((Action) o).getFeature() != null)
			return true;
		else if (o instanceof Assignment)
			i.prune();
		else if (o instanceof RuleCall && isParserRule(((RuleCall) o).getRule())) {
			if (ruleContainsAssignedAction(((RuleCall) o).getRule(), visited))
				return true;
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:18,代码来源:ConcreteSyntaxConstraintProvider.java

示例10: computeExportedObjects

import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
@Override
protected List<IEObjectDescription> computeExportedObjects() {
	if (!getResource().isLoaded()) {
		try {
			getResource().load(null);
		} catch (IOException e) {
			log.error(e.getMessage(), e);
			return Collections.<IEObjectDescription> emptyList();
		}
	}
	final List<IEObjectDescription> exportedEObjects = newArrayList();
	IAcceptor<IEObjectDescription> acceptor = new IAcceptor<IEObjectDescription>() {
		@Override
		public void accept(IEObjectDescription eObjectDescription) {
			exportedEObjects.add(eObjectDescription);
		}
	};
	TreeIterator<EObject> allProperContents = EcoreUtil.getAllProperContents(getResource(), false);
	while (allProperContents.hasNext()) {
		EObject content = allProperContents.next();
		if (!strategy.createEObjectDescriptions(content, acceptor))
			allProperContents.prune();
	}
	return exportedEObjects;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:26,代码来源:DefaultResourceDescription.java

示例11: computeReferenceDescriptions

import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
protected List<IReferenceDescription> computeReferenceDescriptions() {
	final List<IReferenceDescription> referenceDescriptions = Lists.newArrayList();
	IAcceptor<IReferenceDescription> acceptor = new IAcceptor<IReferenceDescription>() {
		@Override
		public void accept(IReferenceDescription referenceDescription) {
			referenceDescriptions.add(referenceDescription);
		}
	};
	EcoreUtil2.resolveLazyCrossReferences(resource, CancelIndicator.NullImpl);
	Map<EObject, IEObjectDescription> eObject2exportedEObjects = createEObject2ExportedEObjectsMap(getExportedObjects());
	TreeIterator<EObject> contents = EcoreUtil.getAllProperContents(this.resource, true);
	while (contents.hasNext()) {
		EObject eObject = contents.next();
		URI exportedContainerURI = findExportedContainerURI(eObject, eObject2exportedEObjects);
		if (!strategy.createReferenceDescriptions(eObject, exportedContainerURI, acceptor))
			contents.prune();
	}
	return referenceDescriptions;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:DefaultResourceDescription.java

示例12: findCrossReferences

import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
public List<CrossReference> findCrossReferences(EClassifier... targetEClassifiers) {
	Set<EClassifier> classifiers = new HashSet<EClassifier>(Arrays.asList(targetEClassifiers));
	Collection<EClass> classes = Lists.newArrayList(Iterables.filter(classifiers, EClass.class));
	ArrayList<CrossReference> r = new ArrayList<CrossReference>();
	for (AbstractRule ar : getRules()) {
		TreeIterator<EObject> i = ar.eAllContents();
		while (i.hasNext()) {
			EObject o = i.next();
			if (o instanceof CrossReference) {
				CrossReference c = (CrossReference) o;
				if (classifiers.contains(c.getType().getClassifier()))
					r.add(c);
				else if (c.getType().getClassifier() instanceof EClass)
					for (EClass cls : classes)
						if (EcoreUtil2.isAssignableFrom(cls,(EClass) c.getType().getClassifier())) {
							r.add(c);
							break;
						}
				i.prune();
			}
		}
	}
	return r;

}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:26,代码来源:AbstractElementFinder.java

示例13: computeReferenceDescriptions

import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
@Override
protected List<IReferenceDescription> computeReferenceDescriptions() {
  final ImmutableList.Builder<IReferenceDescription> referenceDescriptions = ImmutableList.builder();
  EcoreUtil2.resolveLazyCrossReferences(getResource(), CancelIndicator.NullImpl);
  Map<EObject, IEObjectDescription> eObject2exportedEObjects = createEObject2ExportedEObjectsMap(getExportedObjects());
  TreeIterator<EObject> contents = EcoreUtil.getAllProperContents(getResource(), true);
  while (contents.hasNext()) {
    EObject eObject = contents.next();
    URI exportedContainerURI = findExportedContainerURI(eObject, eObject2exportedEObjects);
    if (!strategy.createReferenceDescriptions(eObject, exportedContainerURI, referenceDescriptions::add)) {
      contents.prune();
    }
  }
  if (strategy instanceof AbstractResourceDescriptionStrategy) {
    ((AbstractResourceDescriptionStrategy) strategy).createImplicitReferenceDescriptions(getResource(), referenceDescriptions::add);
  }
  return referenceDescriptions.build();
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:19,代码来源:ResourceDescription2.java

示例14: computeObjectFolding

import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
protected void computeObjectFolding(XtextResource xtextResource, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor) {
	IParseResult parseResult = xtextResource.getParseResult();
	if(parseResult != null){
		EObject rootASTElement = parseResult.getRootASTElement();
		if(rootASTElement != null){
			TreeIterator<EObject> allContents = rootASTElement.eAllContents();
			while (allContents.hasNext()) {
				EObject eObject = allContents.next();
				if (isHandled(eObject)) {
					computeObjectFolding(eObject, foldingRegionAcceptor);
				}
				if (!shouldProcessContent(eObject)) {
					allContents.prune();
				}
			}
		}
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:19,代码来源:DefaultFoldingRegionProvider.java

示例15: getAllSubDiagrams

import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
protected Collection<? extends Diagram> getAllSubDiagrams(State semanticState) {
	List<Diagram> subDiagrams = new ArrayList<>();
	addSubDiagram(semanticState, subDiagrams);

	TreeIterator<EObject> iter = semanticState.eAllContents();
	while (iter.hasNext()) {
		EObject next = iter.next();
		if (next instanceof State) {
			State subState = (State) next;
			if (subState.isComposite()) {
				addSubDiagram(subState, subDiagrams);
			} else {
				iter.prune();
			}
		}
	}
	return subDiagrams;
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:19,代码来源:SubdiagramAwareCopyCommand.java


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