Search in sources :

Example 16 with InternalEList

use of org.eclipse.emf.ecore.util.InternalEList in project dsl-devkit by dsldevkit.

the class AbstractResourceDescriptionStrategy method createReferenceDescriptions.

@Override
@SuppressWarnings("unchecked")
public boolean createReferenceDescriptions(final EObject from, final URI exportedContainerURI, final IAcceptor<IReferenceDescription> acceptor) {
    final EList<EReference> references = from.eClass().getEAllReferences();
    for (EReference eReference : references) {
        if (isIndexable(from, eReference)) {
            final Object val = from.eGet(eReference, false);
            if (val != null) {
                if (eReference.isMany()) {
                    final InternalEList<EObject> list = (InternalEList<EObject>) val;
                    for (int i = 0; i < list.size(); i++) {
                        EObject to = list.basicGet(i);
                        acceptResolvedReference(from, to, eReference, exportedContainerURI, i, acceptor);
                    }
                } else {
                    final EObject to = (EObject) val;
                    acceptResolvedReference(from, to, eReference, exportedContainerURI, -1, acceptor);
                }
            }
        }
    }
    return true;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) InternalEList(org.eclipse.emf.ecore.util.InternalEList) EObject(org.eclipse.emf.ecore.EObject) EReference(org.eclipse.emf.ecore.EReference)

Example 17 with InternalEList

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

the class BasicLazyLinkingTest method testLazyMultiRef.

@Test
public void testLazyMultiRef() throws Exception {
    XtextResource resource = getResource(new StringInputStream("type A {} type B { A B a; }"));
    Model m = (Model) resource.getContents().get(0);
    Type t2 = m.getTypes().get(1);
    Property property = t2.getProperties().get(0);
    EList<Type> types = property.getType();
    assertTrue(((InternalEObject) ((InternalEList<Type>) types).basicGet(0)).eIsProxy());
    assertTrue(((InternalEObject) ((InternalEList<Type>) types).basicGet(0)).eIsProxy());
    assertFalse(((InternalEObject) types.get(0)).eIsProxy());
    assertFalse(((InternalEObject) types.get(1)).eIsProxy());
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) Type(org.eclipse.xtext.linking.lazy.lazyLinking.Type) Model(org.eclipse.xtext.linking.lazy.lazyLinking.Model) InternalEList(org.eclipse.emf.ecore.util.InternalEList) XtextResource(org.eclipse.xtext.resource.XtextResource) UnresolvedProxyProperty(org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty) Property(org.eclipse.xtext.linking.lazy.lazyLinking.Property) Test(org.junit.Test)

Example 18 with InternalEList

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

the class LazyLinkingResourceTest method testResolveLazyCrossReferences_02.

@Test
public void testResolveLazyCrossReferences_02() throws Exception {
    with(lazyLinkingTestLangaugeSetup());
    ResourceSetImpl rs = new ResourceSetImpl();
    final Resource res1 = rs.createResource(URI.createURI("file1.lazylinkingtestlanguage"));
    Resource res2 = rs.createResource(URI.createURI("file2.lazylinkingtestlanguage"));
    res1.load(new StringInputStream("type Foo { } type Baz { Foo Bar prop; } }"), null);
    res2.load(new StringInputStream("type Bar { }"), null);
    res1.eAdapters().add(notificationAlert);
    Model m = (Model) res1.getContents().get(0);
    Type t = m.getTypes().get(1);
    Property p = t.getProperties().get(0);
    final InternalEList<Type> types = (InternalEList<Type>) p.getType();
    assertEquals(2, types.size());
    for (Iterator<Type> it = types.basicIterator(); it.hasNext(); ) {
        final Type tt = it.next();
        assertTrue(tt.eIsProxy());
    }
    ((LazyLinkingResource) res1).resolveLazyCrossReferences(CancelIndicator.NullImpl);
    assertFalse(types.basicGet(0).eIsProxy());
    assertTrue(types.basicGet(1).eIsProxy());
    res1.eAdapters().remove(notificationAlert);
    EcoreUtil.resolveAll(res1);
    assertFalse(types.basicGet(0).eIsProxy());
    assertFalse(types.basicGet(1).eIsProxy());
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) Type(org.eclipse.xtext.linking.lazy.lazyLinking.Type) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) Resource(org.eclipse.emf.ecore.resource.Resource) Model(org.eclipse.xtext.linking.lazy.lazyLinking.Model) InternalEList(org.eclipse.emf.ecore.util.InternalEList) Property(org.eclipse.xtext.linking.lazy.lazyLinking.Property) Test(org.junit.Test)

Example 19 with InternalEList

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

the class JdtBasedTypeFactory method createFormalParameter.

protected JvmFormalParameter createFormalParameter(ITypeBinding parameterType, String paramName, IAnnotationBinding[] annotations) {
    JvmFormalParameter result = TypesFactory.eINSTANCE.createJvmFormalParameter();
    if (paramName != null)
        result.setName(paramName);
    result.setParameterType(createTypeReference(parameterType));
    if (annotations != null && annotations.length > 0) {
        InternalEList<JvmAnnotationReference> parameterAnnotations = (InternalEList<JvmAnnotationReference>) result.getAnnotations();
        for (IAnnotationBinding annotation : annotations) {
            parameterAnnotations.addUnique(createAnnotationReference(annotation));
        }
    }
    return result;
}
Also used : JvmFormalParameter(org.eclipse.xtext.common.types.JvmFormalParameter) IAnnotationBinding(org.eclipse.jdt.core.dom.IAnnotationBinding) InternalEList(org.eclipse.emf.ecore.util.InternalEList) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference)

Example 20 with InternalEList

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

the class JdtBasedTypeFactory method createNestedTypes.

/**
 * @since 2.4
 */
protected void createNestedTypes(ITypeBinding typeBinding, JvmDeclaredType result, String handleIdentifier, List<String> path, StringBuilder fqn) {
    resolveMembers.start();
    ITypeBinding[] declaredTypes = typeBinding.getDeclaredTypes();
    if (declaredTypes.length > 0) {
        InternalEList<JvmMember> members = (InternalEList<JvmMember>) result.getMembers();
        int length = fqn.length();
        for (ITypeBinding declaredType : declaredTypes) {
            if (!declaredType.isAnonymous() && !declaredType.isSynthetic()) {
                JvmDeclaredType nestedType = createType(declaredType, handleIdentifier, path, fqn);
                if (nestedType.eClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) {
                    if (((JvmGenericType) nestedType).isInterface()) {
                        nestedType.setStatic(true);
                    }
                } else {
                    nestedType.setStatic(true);
                }
                members.addUnique(nestedType);
                fqn.setLength(length);
            }
        }
    }
    resolveMembers.stop();
}
Also used : ITypeBinding(org.eclipse.jdt.core.dom.ITypeBinding) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) InternalEList(org.eclipse.emf.ecore.util.InternalEList) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) JvmMember(org.eclipse.xtext.common.types.JvmMember) JvmTypeConstraint(org.eclipse.xtext.common.types.JvmTypeConstraint)

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