本文整理汇总了Java中org.eclipse.emf.common.util.TreeIterator.hasNext方法的典型用法代码示例。如果您正苦于以下问题:Java TreeIterator.hasNext方法的具体用法?Java TreeIterator.hasNext怎么用?Java TreeIterator.hasNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.common.util.TreeIterator
的用法示例。
在下文中一共展示了TreeIterator.hasNext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findRuleCalls
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
public List<RuleCall> findRuleCalls(AbstractRule... rules) {
Set<AbstractRule> rls = new HashSet<AbstractRule>(Arrays.asList(rules));
ArrayList<RuleCall> r = new ArrayList<RuleCall>();
for (AbstractRule ar : getRules()) {
TreeIterator<EObject> i = ar.eAllContents();
while (i.hasNext()) {
EObject o = i.next();
if (o instanceof RuleCall) {
RuleCall c = (RuleCall) o;
if (rls.contains(c.getRule()))
r.add(c);
}
}
}
return r;
}
示例2: cosem
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
public static void cosem(Resource cosemResource, Root root, Hashtable<String, MeterAsset> allMeterAssets) {
HashSet<PhysicalDevice> devices = new HashSet<>();
HashSet<MeterAssetPhysicalDevicePair> devicePairs = new HashSet<>();
TreeIterator<EObject> cosemIterator = cosemResource.getAllContents();
while (cosemIterator.hasNext()) {
EObject eOb = cosemIterator.next();
if (eOb instanceof PhysicalDevice) {
PhysicalDevice device = (PhysicalDevice) eOb;
devices.add(device);
String idNs = device.getID();
if (allMeterAssets.containsKey(idNs)) {
MeterAssetPhysicalDevicePair pair = GluemodelFactory.eINSTANCE
.createMeterAssetPhysicalDevicePair();
pair.setB(device);
pair.setA(allMeterAssets.get(idNs));
devicePairs.add(pair);
}
}
}
root.getMeterAssetToPhysicalDevice().addAll(devicePairs);
}
示例3: 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;
}
示例4: 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;
}
示例5: exposeTypesReferencedBy
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
private static void exposeTypesReferencedBy(EObject root) {
final TreeIterator<EObject> i = root.eAllContents();
while (i.hasNext()) {
final EObject object = i.next();
for (EReference currRef : object.eClass().getEAllReferences()) {
if (!currRef.isContainment() && !currRef.isContainer()) {
final Object currTarget = object.eGet(currRef);
if (currTarget instanceof Collection<?>) {
for (Object currObj : (Collection<?>) currTarget) {
exposeType(currObj);
}
} else {
exposeType(currTarget);
}
}
}
}
}
示例6: undoTextElementToTextNode
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
private static void undoTextElementToTextNode(XMLResource saturnResourceImpl_, Map<Entry, Entry> textNodes_)
{
DocumentRoot o = (DocumentRoot) saturnResourceImpl_.getContents().get(0);
Saturn saturn = (Saturn) o.eContents().get(0);
TreeIterator<EObject> ee = saturn.eAllContents();
while (ee.hasNext())
{
EObject e = ee.next();
if (e == null) continue;
EClass ec = e.eClass();
if (!ValuesPackage.eINSTANCE.getComplexValue().isSuperTypeOf(ec)) continue;
ComplexValue cv = (ComplexValue) e;
for (int i = 0; i < cv.getMixed().size(); i++)
{
FeatureMap.Entry entry = cv.getMixed().get(i);
if (textNodes_.containsKey(entry))
{
Entry textComplexValueEntry = textNodes_.get(entry);
cv.getMixed().set(i, textComplexValueEntry);
}
}
}
}
示例7: provideHighlightingFor
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
@Override
public void provideHighlightingFor(XtextResource resource,
org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightedPositionAcceptor acceptor) {
TreeIterator<EObject> allContents = resource.getAllContents();
while (allContents.hasNext()) {
EObject next = allContents.next();
if (next.eIsProxy()) {
continue;
}
if (next instanceof ElementReferenceExpression) {
if (next instanceof ElementReferenceExpression) {
ElementReferenceExpression expression = (ElementReferenceExpression) next;
provideHighligtingFor(expression, acceptor);
}
}
}
}
示例8: setSelection
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
@Override
public void setSelection(ISelection selection, boolean reveal) {
this.selection = selection;
if (selection instanceof StructuredSelection) {
Z: for (Object se: ((StructuredSelection) selection).toArray()) {
if (se instanceof EcoreCodeGenerator) {
generatorForm.setGenerator((EcoreCodeGenerator) se);
break;
}
if (se instanceof Resource) {
TreeIterator<EObject> tit = ((Resource) se).getAllContents();
while (tit.hasNext()) {
EObject next = tit.next();
if (next instanceof EcoreCodeGenerator) {
generatorForm.setGenerator((EcoreCodeGenerator) next);
break Z;
}
}
}
}
}
}
示例9: 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();
}
示例10: insertProxyModel
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public void insertProxyModel() {
// Node model can be accessed by:
// 1. checking the adapters of an EObject
ICompositeNode rootNode = null;
TreeIterator<EObject> iterator = EcoreUtil.getAllProperContents(resource, false);
while (iterator.hasNext()) {
EObject eObject = iterator.next();
LazyLoadingCompositeNode node = new LazyLoadingCompositeNode();
eObject.eAdapters().add(node);
if (rootNode == null) {
rootNode = node;
}
}
// 2. fetching the ParseResult instance of the Resource
EObject emfRootObject = resource.getContents().isEmpty() ? null : resource.getContents().get(0);
resource.setParseResult(new ParseResult(emfRootObject, rootNode, false));
// Add cache now, otherwise it will trigger model inference later.
IResourceScopeCache cache = resource.getCache();
if (cache instanceof OnChangeEvictingCache) {
((OnChangeEvictingCache) cache).getOrCreate(resource);
}
}
示例11: resolveLazyCrossReferences
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
/**
* resolves any lazy cross references in this resource, adding Issues for unresolvable elements to this resource.
* This resource might still contain resolvable proxies after this method has been called.
*
* @param mon a {@link CancelIndicator} can be used to stop the resolution.
*/
public void resolveLazyCrossReferences(final CancelIndicator mon) {
final CancelIndicator monitor = mon == null ? CancelIndicator.NullImpl : mon;
TreeIterator<Object> iterator = EcoreUtil.getAllContents(this, true);
while (iterator.hasNext()) {
operationCanceledManager.checkCanceled(monitor);
InternalEObject source = (InternalEObject) iterator.next();
EStructuralFeature[] eStructuralFeatures = ((EClassImpl.FeatureSubsetSupplier) source.eClass()
.getEAllStructuralFeatures()).crossReferences();
if (eStructuralFeatures != null) {
for (EStructuralFeature crossRef : eStructuralFeatures) {
operationCanceledManager.checkCanceled(monitor);
resolveLazyCrossReference(source, crossRef);
}
}
}
}
示例12: 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;
}
示例13: 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;
}
示例14: testExternalFormOfEReference
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
@Test public void testExternalFormOfEReference() throws Exception {
Registry registry = EPackage.Registry.INSTANCE;
Set<String> uris = Sets.newHashSet(registry.keySet());
for (String string : uris) {
EPackage ePackage = registry.getEPackage(string);
TreeIterator<Object> iterator = EcoreUtil.getAllProperContents(ePackage, true);
while (iterator.hasNext()) {
Object next = iterator.next();
if (next instanceof EReference) {
EReference ref = (EReference) next;
String externalForm = EcoreUtil2.toExternalForm(ref);
assertEquals(ref.toString() + " - " + externalForm, ref, EcoreUtil2.getEReferenceFromExternalForm(registry,externalForm));
}
}
}
}
示例15: findOppositeForFeature
import org.eclipse.emf.common.util.TreeIterator; //导入方法依赖的package包/类
/**
* Determines all objects that refer to <code>target</code> by the reference
* <code>reference</code>
*
* @param target
* the target of the references
* @param reference
* the reference to search for
* @return all (distinct) objects that refer to target by reference
* @author Dominik Werle
*/
public static Set<EObject> findOppositeForFeature(EObject target, EReference reference) {
Set<EObject> result = new HashSet<EObject>();
Resource resource = target.eResource();
TreeIterator<Object> iter = EcoreUtil.getAllProperContents(resource, true);
while (iter.hasNext()) {
Object obj = iter.next();
if (obj instanceof EObject) {
EObject eobj = (EObject) obj;
if (reference.getEContainingClass().isSuperTypeOf(eobj.eClass())) {
Object referencedObject = eobj.eGet(reference);
if ((referencedObject instanceof EList<?>) && (((EList<?>) referencedObject).contains(target))) {
result.add(eobj);
} else if (referencedObject.equals(target)) {
result.add(eobj);
}
}
}
}
return result;
}