Search in sources :

Example 86 with EReference

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

the class AbstractLiveContainerTest method createRefToRoot.

private EReference createRefToRoot() {
    EReference ref = EcoreFactory.eINSTANCE.createEReference();
    EcoreFactory.eINSTANCE.createEClass().getEStructuralFeatures().add(ref);
    ref.setEType(getModelRootType());
    return ref;
}
Also used : EReference(org.eclipse.emf.ecore.EReference)

Example 87 with EReference

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

the class AbstractLiveContainerTest method testGlobalScope.

@Test
public void testGlobalScope() throws Exception {
    EReference ref = createRefToRoot();
    ResourceSet resourceSet = new XtextResourceSet();
    Resource res = parse("local", resourceSet).eResource();
    parse("other", resourceSet);
    assertEquals("other", format(scopeProvider.getScope(res, ref).getAllElements()));
    Resource foo = parse("foo", resourceSet).eResource();
    assertEquals("foo, other", format(scopeProvider.getScope(res, ref).getAllElements()));
    resourceSet.getResources().remove(foo);
    assertEquals("other", format(scopeProvider.getScope(res, ref).getAllElements()));
}
Also used : XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) EReference(org.eclipse.emf.ecore.EReference) Test(org.junit.Test)

Example 88 with EReference

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

the class DeclarativeScopeProviderTest method testScopeByReference2.

@SuppressWarnings("unused")
@Test
public void testScopeByReference2() throws Exception {
    final IScope a = new SimpleScope(IScope.NULLSCOPE, Collections.<IEObjectDescription>emptySet());
    final IScope b = new SimpleScope(IScope.NULLSCOPE, Collections.<IEObjectDescription>emptySet());
    final IScope c = new SimpleScope(IScope.NULLSCOPE, Collections.<IEObjectDescription>emptySet());
    AbstractDeclarativeScopeProvider provider = new AbstractDeclarativeScopeProvider() {

        private IScope scope_EClass_eSuperTypes(EClassifier clazz, EReference ref) {
            return a;
        }

        private IScope scope_EClass_eSuperTypes(EClass clazz, EReference ref) {
            return b;
        }

        private IScope scope_EClass_eSuperTypes(EReference ctx, EReference ref) {
            return c;
        }
    };
    EReference details = EcorePackage.eINSTANCE.getEClass_ESuperTypes();
    assertEquals(a, provider.getScope(EcorePackage.eINSTANCE.getEShort(), details));
    assertEquals(b, provider.getScope(details.getEContainingClass(), details));
    assertEquals(c, provider.getScope(details, details));
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IScope(org.eclipse.xtext.scoping.IScope) EClassifier(org.eclipse.emf.ecore.EClassifier) EReference(org.eclipse.emf.ecore.EReference) Test(org.junit.Test)

Example 89 with EReference

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

the class DeclarativeScopeProviderTest method testNested.

@SuppressWarnings("unused")
@Test
public void testNested() throws Exception {
    final IScope a = new SimpleScope(IScope.NULLSCOPE, Collections.<IEObjectDescription>emptySet());
    final IScope b = new SimpleScope(IScope.NULLSCOPE, Collections.<IEObjectDescription>emptySet());
    AbstractDeclarativeScopeProvider provider = new AbstractDeclarativeScopeProvider() {

        private IScope scope_EClass(EClass clazz, EReference ref) {
            return a;
        }

        private IScope scope_EClass(EReference ctx, EReference ref) {
            return b;
        }
    };
    EReference details = EcorePackage.eINSTANCE.getEClass_ESuperTypes();
    assertEquals(b, provider.getScope(details, details));
    assertEquals(a, provider.getScope(details.getEContainingClass(), details));
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IScope(org.eclipse.xtext.scoping.IScope) EReference(org.eclipse.emf.ecore.EReference) Test(org.junit.Test)

Example 90 with EReference

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

the class DeclarativeScopeProviderTest method testScopeByReference.

@SuppressWarnings("unused")
@Test
public void testScopeByReference() throws Exception {
    final IScope a = new SimpleScope(IScope.NULLSCOPE, Collections.<IEObjectDescription>emptySet());
    final IScope b = new SimpleScope(IScope.NULLSCOPE, Collections.<IEObjectDescription>emptySet());
    final IScope c = new SimpleScope(IScope.NULLSCOPE, Collections.<IEObjectDescription>emptySet());
    AbstractDeclarativeScopeProvider provider = new AbstractDeclarativeScopeProvider() {

        private IScope scope_EClass_eSuperTypes(EClassifier clazz, EReference ref) {
            return a;
        }

        private IScope scope_EClass(EClass clazz, EReference ref) {
            return c;
        }

        private IScope scope_EClass(EReference ctx, EReference ref) {
            return b;
        }
    };
    EReference details = EcorePackage.eINSTANCE.getEClass_ESuperTypes();
    assertEquals(a, provider.getScope(details, details));
    assertEquals(a, provider.getScope(details.getEContainingClass(), details));
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IScope(org.eclipse.xtext.scoping.IScope) EClassifier(org.eclipse.emf.ecore.EClassifier) EReference(org.eclipse.emf.ecore.EReference) Test(org.junit.Test)

Aggregations

EReference (org.eclipse.emf.ecore.EReference)229 EObject (org.eclipse.emf.ecore.EObject)118 EClass (org.eclipse.emf.ecore.EClass)58 List (java.util.List)52 ArrayList (java.util.ArrayList)48 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)37 Test (org.junit.Test)31 EAttribute (org.eclipse.emf.ecore.EAttribute)29 PalladioSelectEObjectDialog (org.palladiosimulator.editors.commons.dialogs.selection.PalladioSelectEObjectDialog)28 EClassifier (org.eclipse.emf.ecore.EClassifier)21 Resource (org.eclipse.emf.ecore.resource.Resource)21 IdEObject (org.bimserver.emf.IdEObject)18 EList (org.eclipse.emf.common.util.EList)17 IScope (org.eclipse.xtext.scoping.IScope)15 HashMapVirtualObject (org.bimserver.shared.HashMapVirtualObject)14 InternalEObject (org.eclipse.emf.ecore.InternalEObject)14 URI (org.eclipse.emf.common.util.URI)13 EPackage (org.eclipse.emf.ecore.EPackage)12 AbstractEList (org.eclipse.emf.common.util.AbstractEList)10 CrossReference (org.eclipse.xtext.CrossReference)10