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;
}
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()));
}
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));
}
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));
}
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));
}
Aggregations