Search in sources :

Example 21 with InternalEList

use of org.eclipse.emf.ecore.util.InternalEList in project xtext-eclipse by eclipse.

the class JdtBasedTypeFactory method createAnnotationValues.

protected void createAnnotationValues(IBinding annotated, JvmAnnotationTarget result) {
    try {
        resolveAnnotations.start();
        IAnnotationBinding[] annotationBindings = annotated.getAnnotations();
        if (annotationBindings.length != 0) {
            InternalEList<JvmAnnotationReference> annotations = (InternalEList<JvmAnnotationReference>) result.getAnnotations();
            for (IAnnotationBinding annotation : annotationBindings) {
                annotations.addUnique(createAnnotationReference(annotation));
            }
        }
    } catch (AbortCompilation aborted) {
        if (aborted.problem.getID() == IProblem.IsClassPathCorrect) {
        // ignore
        } else {
            log.info("Couldn't resolve annotations of " + annotated, aborted);
        }
    } finally {
        resolveAnnotations.stop();
    }
}
Also used : IAnnotationBinding(org.eclipse.jdt.core.dom.IAnnotationBinding) InternalEList(org.eclipse.emf.ecore.util.InternalEList) AbortCompilation(org.eclipse.jdt.internal.compiler.problem.AbortCompilation) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference)

Example 22 with InternalEList

use of org.eclipse.emf.ecore.util.InternalEList in project statecharts by Yakindu.

the class AbstractSCTResource method resolveLazyCrossReference.

// copied from xtext LazyLinkingResource
protected void resolveLazyCrossReference(InternalEObject source, EStructuralFeature crossRef, CancelIndicator monitor) {
    if (crossRef.isDerived())
        return;
    if (crossRef.isMany()) {
        @SuppressWarnings("unchecked") InternalEList<EObject> list = (InternalEList<EObject>) source.eGet(crossRef);
        for (int i = 0; i < list.size(); i++) {
            EObject proxy = list.basicGet(i);
            if (proxy.eIsProxy()) {
                URI proxyURI = ((InternalEObject) proxy).eProxyURI();
                if (getURI().equals(proxyURI.trimFragment())) {
                    final String fragment = proxyURI.fragment();
                    if (encoder.isCrossLinkFragment(this, fragment) && !monitor.isCanceled()) {
                        EObject target = getEObject(fragment);
                        if (target != null) {
                            try {
                                source.eSetDeliver(false);
                                list.setUnique(i, target);
                            } finally {
                                source.eSetDeliver(true);
                            }
                        }
                    }
                }
            }
        }
    } else {
        EObject proxy = (EObject) source.eGet(crossRef, false);
        if (proxy != null && proxy.eIsProxy()) {
            URI proxyURI = ((InternalEObject) proxy).eProxyURI();
            if (getURI().equals(proxyURI.trimFragment())) {
                final String fragment = proxyURI.fragment();
                if (encoder.isCrossLinkFragment(this, fragment) && !monitor.isCanceled()) {
                    EObject target = getEObject(fragment);
                    if (target != null) {
                        try {
                            source.eSetDeliver(false);
                            source.eSet(crossRef, target);
                        } finally {
                            source.eSetDeliver(true);
                        }
                    }
                }
            }
        }
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) InternalEList(org.eclipse.emf.ecore.util.InternalEList) URI(org.eclipse.emf.common.util.URI) InternalEObject(org.eclipse.emf.ecore.InternalEObject)

Example 23 with InternalEList

use of org.eclipse.emf.ecore.util.InternalEList in project statecharts by Yakindu.

the class DerivedEObjectEList method size.

@Override
public int size() {
    if (sourceFeatureIDs != null) {
        EList<Object> values = new UniqueEList.FastCompare<Object>();
        for (int i = 0; i < sourceFeatureIDs.length; i++) {
            int sourceFeatureID = sourceFeatureIDs[i];
            if (owner.eIsSet(sourceFeatureID)) {
                EStructuralFeature sourceFeature = getEStructuralFeature(sourceFeatureID);
                Object value = owner.eGet(sourceFeatureID, false, true);
                if (FeatureMapUtil.isFeatureMap(sourceFeature)) {
                    FeatureMap featureMap = (FeatureMap) value;
                    for (int j = 0, size = featureMap.size(); j < size; j++) {
                        value = featureMap.getValue(j);
                        if (isIncluded(featureMap.getEStructuralFeature(j)) ? value != null : isIncluded(value)) {
                            values.add(value);
                        }
                    }
                } else if (isIncluded(sourceFeature)) {
                    if (sourceFeature.isMany()) {
                        InternalEList<?> valuesList = (InternalEList<?>) value;
                        if (valuesList instanceof RandomAccess) {
                            for (int j = 0, size = valuesList.size(); j < size; j++) {
                                values.add(valuesList.basicGet(j));
                            }
                        } else {
                            for (Iterator<?> v = valuesList.basicIterator(); v.hasNext(); ) {
                                values.add(v.next());
                            }
                        }
                    } else if (value != null) {
                        values.add(value);
                    }
                } else {
                    if (sourceFeature.isMany()) {
                        InternalEList<?> valuesList = (InternalEList<?>) value;
                        if (valuesList instanceof RandomAccess) {
                            for (int j = 0, size = valuesList.size(); j < size; j++) {
                                value = valuesList.basicGet(j);
                                if (isIncluded(value)) {
                                    values.add(value);
                                }
                            }
                        } else {
                            for (Iterator<?> v = valuesList.basicIterator(); v.hasNext(); ) {
                                value = v.next();
                                if (isIncluded(value)) {
                                    values.add(value);
                                }
                            }
                        }
                    } else if (isIncluded(value)) {
                        values.add(value);
                    }
                }
            }
        }
        return values.size();
    }
    return 0;
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) Iterator(java.util.Iterator) ListIterator(java.util.ListIterator) AbstractSequentialInternalEList(org.eclipse.emf.ecore.util.AbstractSequentialInternalEList) InternalEList(org.eclipse.emf.ecore.util.InternalEList) RandomAccess(java.util.RandomAccess) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject)

Example 24 with InternalEList

use of org.eclipse.emf.ecore.util.InternalEList in project statecharts by Yakindu.

the class DerivedEObjectEList method contains.

@Override
public boolean contains(Object object) {
    if (sourceFeatureIDs != null) {
        for (int i = 0; i < sourceFeatureIDs.length; i++) {
            int sourceFeatureID = sourceFeatureIDs[i];
            if (owner.eIsSet(sourceFeatureID)) {
                EStructuralFeature sourceFeature = getEStructuralFeature(sourceFeatureID);
                Object value = owner.eGet(sourceFeatureID, true, true);
                if (FeatureMapUtil.isFeatureMap(sourceFeature)) {
                    FeatureMap featureMap = (FeatureMap) value;
                    for (int j = 0, size = featureMap.size(); j < size; j++) {
                        value = featureMap.getValue(j);
                        if (isIncluded(featureMap.getEStructuralFeature(j)) ? value == object : isIncluded(value) && derive(value) == object) {
                            return true;
                        }
                    }
                } else if (isIncluded(sourceFeature)) {
                    if (sourceFeature.isMany() ? ((List<?>) value).contains(object) : value == object) {
                        return true;
                    }
                } else {
                    if (sourceFeature.isMany()) {
                        InternalEList<?> valuesList = (InternalEList<?>) value;
                        if (valuesList instanceof RandomAccess) {
                            for (int j = 0, size = valuesList.size(); j < size; j++) {
                                value = valuesList.basicGet(j);
                                if (isIncluded(value) && derive(value) == object) {
                                    return true;
                                }
                            }
                        } else {
                            for (Iterator<?> v = valuesList.basicIterator(); v.hasNext(); ) {
                                value = v.next();
                                if (isIncluded(value) && derive(value) == object) {
                                    return true;
                                }
                            }
                        }
                    } else if (isIncluded(value) && derive(value) == object) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) Iterator(java.util.Iterator) ListIterator(java.util.ListIterator) AbstractSequentialInternalEList(org.eclipse.emf.ecore.util.AbstractSequentialInternalEList) InternalEList(org.eclipse.emf.ecore.util.InternalEList) RandomAccess(java.util.RandomAccess) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) AbstractSequentialInternalEList(org.eclipse.emf.ecore.util.AbstractSequentialInternalEList) EList(org.eclipse.emf.common.util.EList) UniqueEList(org.eclipse.emf.common.util.UniqueEList) List(java.util.List) InternalEList(org.eclipse.emf.ecore.util.InternalEList)

Aggregations

InternalEList (org.eclipse.emf.ecore.util.InternalEList)24 EObject (org.eclipse.emf.ecore.EObject)9 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)9 JvmTypeConstraint (org.eclipse.xtext.common.types.JvmTypeConstraint)9 InternalEObject (org.eclipse.emf.ecore.InternalEObject)7 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)4 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)4 Iterator (java.util.Iterator)3 ListIterator (java.util.ListIterator)3 RandomAccess (java.util.RandomAccess)3 AbstractSequentialInternalEList (org.eclipse.emf.ecore.util.AbstractSequentialInternalEList)3 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)3 IAnnotationBinding (org.eclipse.jdt.core.dom.IAnnotationBinding)3 JvmAnnotationReference (org.eclipse.xtext.common.types.JvmAnnotationReference)3 JvmMember (org.eclipse.xtext.common.types.JvmMember)3 List (java.util.List)2 URI (org.eclipse.emf.common.util.URI)2 EReference (org.eclipse.emf.ecore.EReference)2 IMethodBinding (org.eclipse.jdt.core.dom.IMethodBinding)2 AbortCompilation (org.eclipse.jdt.internal.compiler.problem.AbortCompilation)2