Search in sources :

Example 16 with EObjectDescription

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());
}
Also used : AliasedEObjectDescription(org.eclipse.xtext.resource.impl.AliasedEObjectDescription) EObjectDescription(org.eclipse.xtext.resource.EObjectDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 17 with EObjectDescription

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));
}
Also used : AliasedEObjectDescription(org.eclipse.xtext.resource.impl.AliasedEObjectDescription) EObjectDescription(org.eclipse.xtext.resource.EObjectDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 18 with EObjectDescription

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")));
}
Also used : AliasedEObjectDescription(org.eclipse.xtext.resource.impl.AliasedEObjectDescription) EObjectDescription(org.eclipse.xtext.resource.EObjectDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 19 with EObjectDescription

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));
}
Also used : AliasedEObjectDescription(org.eclipse.xtext.resource.impl.AliasedEObjectDescription) EObjectDescription(org.eclipse.xtext.resource.EObjectDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 20 with EObjectDescription

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());
}
Also used : AliasedEObjectDescription(org.eclipse.xtext.resource.impl.AliasedEObjectDescription) EObjectDescription(org.eclipse.xtext.resource.EObjectDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Aggregations

EObjectDescription (org.eclipse.xtext.resource.EObjectDescription)20 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)20 Test (org.junit.Test)20 AliasedEObjectDescription (org.eclipse.xtext.resource.impl.AliasedEObjectDescription)18 URI (org.eclipse.emf.common.util.URI)2