use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class ResourceDescriptionsBasedContainerTest method testGetExportedObjectsByType_01.
@Test
public void testGetExportedObjectsByType_01() {
EClass classifier = EcorePackage.Literals.ECLASSIFIER;
Iterable<IEObjectDescription> iterable = container.getExportedObjectsByType(classifier);
EObject eObject = Iterables.getOnlyElement(iterable).getEObjectOrProxy();
assertSame(eClass, eObject);
}
use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class ResourceSetBasedResourceDescriptionsTest method testOneElement_Match.
@Test
public void testOneElement_Match() {
QualifiedName qualifiedName = QualifiedName.create("SomeName");
EClass type = EcorePackage.Literals.EPACKAGE;
Resource resource = createResource();
ENamedElement element = createNamedElement(qualifiedName, type, resource);
Iterable<IEObjectDescription> iterable = container.getExportedObjectsByType(EcorePackage.Literals.EPACKAGE);
assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
iterable = container.getExportedObjectsByType(EcorePackage.Literals.EOBJECT);
assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
iterable = container.getExportedObjects(EcorePackage.Literals.EPACKAGE, qualifiedName, false);
assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
iterable = container.getExportedObjects(EcorePackage.Literals.ENAMED_ELEMENT, qualifiedName, false);
assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
iterable = container.getExportedObjects(EcorePackage.Literals.EOBJECT, qualifiedName, false);
assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
}
use of org.eclipse.emf.ecore.EClass in project xtext-core by eclipse.
the class ScopeTest method testContentByEObject_withProxy.
@Test
public void testContentByEObject_withProxy() throws Exception {
EClass eClass = EcoreFactory.eINSTANCE.createEClass();
((InternalEObject) eClass).eSetProxyURI(EcoreUtil.getURI(EcorePackage.eINSTANCE.getEAnnotation()));
assertNotNull(scope.getSingleElement(eClass));
}
use of org.eclipse.emf.ecore.EClass 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.EClass 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));
}
Aggregations