use of org.eclipse.xtext.resource.EObjectDescription in project xtext-core by eclipse.
the class ImportScopeTest method testGetByEObject_01.
@Test
public void testGetByEObject_01() throws Exception {
final IEObjectDescription desc1 = new EObjectDescription(QualifiedName.create("com", "foo"), EcorePackage.Literals.EANNOTATION, null);
final IEObjectDescription desc2 = new EObjectDescription(QualifiedName.create("de", "foo"), EcorePackage.Literals.EATTRIBUTE, null);
SimpleScope outer = new SimpleScope(newArrayList(desc1, desc2), true);
ImportNormalizer n1 = new ImportNormalizer(QualifiedName.create("COM"), true, true);
ImportNormalizer n2 = new ImportNormalizer(QualifiedName.create("DE"), true, true);
TestableImportScope scope = new TestableImportScope(newArrayList(n1, n2), outer, new ScopeBasedSelectable(outer), EcorePackage.Literals.EOBJECT, true);
Iterable<IEObjectDescription> iterable = scope.getElements(EcorePackage.Literals.EANNOTATION);
assertEquals(1, size(iterable));
assertEquals("com.foo", iterable.iterator().next().getName().toString());
}
use of org.eclipse.xtext.resource.EObjectDescription in project xtext-core by eclipse.
the class ImportScopeTest method testMultipleElementsByName_01.
@Test
public void testMultipleElementsByName_01() throws Exception {
final IEObjectDescription desc1 = new EObjectDescription(QualifiedName.create("com", "foo"), EcorePackage.Literals.EANNOTATION, null);
final IEObjectDescription desc2 = new EObjectDescription(QualifiedName.create("com", "foo"), EcorePackage.Literals.EATTRIBUTE, null);
SimpleScope outer = new SimpleScope(newArrayList(desc1, desc2), true);
ImportNormalizer n1 = new ImportNormalizer(QualifiedName.create("COM"), true, true);
ImportNormalizer n2 = new ImportNormalizer(QualifiedName.create("DE"), true, true);
TestableImportScope scope = new TestableImportScope(newArrayList(n1, n2), outer, new ScopeBasedSelectable(outer), EcorePackage.Literals.EOBJECT, true);
assertNotNull(scope.getSingleElement(QualifiedName.create("Foo")));
Iterable<IEObjectDescription> elements = scope.getLocalElementsByName(QualifiedName.create("Foo"));
assertEquals(2, size(elements));
}
use of org.eclipse.xtext.resource.EObjectDescription in project xtext-core by eclipse.
the class ImportScopeTest method testDuplicatesNotVisible_04_IgnoreCase.
@Test
public void testDuplicatesNotVisible_04_IgnoreCase() throws Exception {
final IEObjectDescription desc1 = new EObjectDescription(QualifiedName.create("com", "foo"), EcorePackage.Literals.EANNOTATION, null);
final IEObjectDescription desc2 = new EObjectDescription(QualifiedName.create("de", "foo"), EcorePackage.Literals.EATTRIBUTE, null);
SimpleScope outer = new SimpleScope(newArrayList(desc1, desc2), true);
ImportNormalizer n1 = new ImportNormalizer(QualifiedName.create("COM"), true, true);
ImportNormalizer n2 = new ImportNormalizer(QualifiedName.create("DE"), true, true);
TestableImportScope scope = new TestableImportScope(newArrayList(n1, n2), outer, new ScopeBasedSelectable(outer), EcorePackage.Literals.EOBJECT, true);
assertNull(scope.getSingleElement(QualifiedName.create("Foo")));
assertNotNull(scope.getSingleElement(QualifiedName.create("com", "Foo")));
assertNotNull(scope.getSingleElement(QualifiedName.create("de", "Foo")));
}
use of org.eclipse.xtext.resource.EObjectDescription in project xtext-core by eclipse.
the class ImportScopeTest method testMultipleElementsByName_00.
@Test
public void testMultipleElementsByName_00() throws Exception {
final IEObjectDescription desc1 = new EObjectDescription(QualifiedName.create("com", "foo"), EcorePackage.Literals.EANNOTATION, null);
final IEObjectDescription desc2 = new EObjectDescription(QualifiedName.create("com", "foo"), EcorePackage.Literals.EATTRIBUTE, null);
SimpleScope outer = new SimpleScope(newArrayList(desc1, desc2), true);
ImportNormalizer n1 = new ImportNormalizer(QualifiedName.create("com"), true, true);
ImportNormalizer n2 = new ImportNormalizer(QualifiedName.create("de"), true, true);
TestableImportScope scope = new TestableImportScope(newArrayList(n1, n2), outer, new ScopeBasedSelectable(outer), EcorePackage.Literals.EOBJECT, true);
assertNotNull(scope.getSingleElement(QualifiedName.create("Foo")));
Iterable<IEObjectDescription> elements = scope.getLocalElementsByName(QualifiedName.create("Foo"));
assertEquals(2, size(elements));
}
use of org.eclipse.xtext.resource.EObjectDescription in project xtext-core by eclipse.
the class ImportScopeTest method testGetByEObject_00.
@Test
public void testGetByEObject_00() throws Exception {
final IEObjectDescription desc1 = new EObjectDescription(QualifiedName.create("com", "foo"), EcorePackage.Literals.EANNOTATION, null);
final IEObjectDescription desc2 = new EObjectDescription(QualifiedName.create("de", "foo"), EcorePackage.Literals.EATTRIBUTE, null);
SimpleScope outer = new SimpleScope(newArrayList(desc1, desc2), true);
ImportNormalizer n1 = new ImportNormalizer(QualifiedName.create("com"), true, true);
ImportNormalizer n2 = new ImportNormalizer(QualifiedName.create("de"), true, true);
TestableImportScope scope = new TestableImportScope(newArrayList(n1, n2), outer, new ScopeBasedSelectable(outer), EcorePackage.Literals.EOBJECT, true);
Iterable<IEObjectDescription> iterable = scope.getElements(EcorePackage.Literals.EANNOTATION);
assertEquals(1, size(iterable));
assertEquals("com.foo", iterable.iterator().next().getName().toString());
}
Aggregations