Search in sources :

Example 1 with EObjectDescription

use of org.eclipse.xtext.resource.EObjectDescription in project xtext-core by eclipse.

the class ImportScopeTest method testDuplicatesNotVisible_05_IgnoreCase.

@Test
public void testDuplicatesNotVisible_05_IgnoreCase() throws Exception {
    final IEObjectDescription desc1 = new EObjectDescription(QualifiedName.create("com", "Foo"), EcorePackage.Literals.EANNOTATION, null);
    SimpleScope outer = new SimpleScope(newArrayList(desc1), true);
    ImportNormalizer n1 = new ImportNormalizer(QualifiedName.create("COM"), true, true);
    ImportNormalizer n2 = new ImportNormalizer(QualifiedName.create("com"), true, true);
    TestableImportScope scope = new TestableImportScope(newArrayList(n1, n2), outer, new ScopeBasedSelectable(outer), EcorePackage.Literals.EOBJECT, true);
    Iterator<IEObjectDescription> iterator = scope.getAllElements().iterator();
    assertEquals(QualifiedName.create("Foo"), iterator.next().getName());
    assertSame(desc1, iterator.next());
    assertFalse(iterator.hasNext());
}
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 2 with EObjectDescription

use of org.eclipse.xtext.resource.EObjectDescription in project xtext-core by eclipse.

the class ImportScopeTest method testGetAllLocalElements_01.

@Test
public void testGetAllLocalElements_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);
    Iterable<IEObjectDescription> elements = scope.getAllLocalElements();
    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 3 with EObjectDescription

use of org.eclipse.xtext.resource.EObjectDescription in project xtext-core by eclipse.

the class ImportScopeTest method testGetAllLocalElements_00.

@Test
public void testGetAllLocalElements_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);
    Iterable<IEObjectDescription> elements = scope.getAllLocalElements();
    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 4 with EObjectDescription

use of org.eclipse.xtext.resource.EObjectDescription in project xtext-core by eclipse.

the class ImportScopeTest method testDuplicatesNotVisible_03_IgnoreCase.

@Test
public void testDuplicatesNotVisible_03_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 5 with EObjectDescription

use of org.eclipse.xtext.resource.EObjectDescription in project xtext-core by eclipse.

the class ImportScopeTest method testAllAliasedElements_01.

@Test
public void testAllAliasedElements_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);
    final ArrayList<IEObjectDescription> newArrayList = newArrayList(desc1, desc2);
    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), IScope.NULLSCOPE, null, EcorePackage.Literals.EOBJECT, true);
    Iterable<IEObjectDescription> elements = scope.getAliasedElements(newArrayList);
    assertEquals(2, size(elements));
    Iterator<IEObjectDescription> iterator = elements.iterator();
    assertSame(desc1, ((AliasedEObjectDescription) iterator.next()).getAliasedEObjectDescription());
    assertSame(desc2, ((AliasedEObjectDescription) iterator.next()).getAliasedEObjectDescription());
}
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