Search in sources :

Example 6 with EObjectDescription

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

the class ImportScopeTest method testDuplicatesNotVisible_02_IgnoreCase.

@Test
public void testDuplicatesNotVisible_02_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);
    Iterator<IEObjectDescription> iterator = scope.getAllElements().iterator();
    assertSame(desc1, iterator.next());
    assertSame(desc2, 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 7 with EObjectDescription

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

the class ImportScopeTest method testAllAliasedElements_02.

@Test
public void testAllAliasedElements_02() 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);
    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(0, 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 8 with EObjectDescription

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

the class ImportScopeTest method testAllAliasedElements_03.

@Test
public void testAllAliasedElements_03() 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);
    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(0, 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 9 with EObjectDescription

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

the class ImportScopeTest method testAllAliasedElements_04.

@Test
public void testAllAliasedElements_04() throws Exception {
    final IEObjectDescription desc1 = new EObjectDescription(QualifiedName.create("com", "foo"), EcorePackage.Literals.EANNOTATION, null);
    final IEObjectDescription desc2 = new EObjectDescription(QualifiedName.create("com", "bar"), EcorePackage.Literals.EANNOTATION, null);
    final IEObjectDescription desc3 = new EObjectDescription(QualifiedName.create("de", "foo"), EcorePackage.Literals.EATTRIBUTE, null);
    final ArrayList<IEObjectDescription> newArrayList = newArrayList(desc1, desc2, desc3);
    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(1, size(elements));
    assertSame(desc2, ((AliasedEObjectDescription) elements.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)

Example 10 with EObjectDescription

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

the class DefaultResourceDescriptionDeltaTest method testHasChanges_DifferentTypes.

@Test
public void testHasChanges_DifferentTypes() throws Exception {
    TestResDesc resourceDesc = new TestResDesc();
    resourceDesc.imported.add(FOO);
    resourceDesc.exported.add(EObjectDescription.create(BAR, EcorePackage.Literals.EANNOTATION, Collections.singletonMap("foo", "bar")));
    TestResDesc resourceDesc2 = new TestResDesc();
    resourceDesc2.imported.add(FOO);
    resourceDesc2.exported.add(new EObjectDescription(BAR, EcorePackage.Literals.EANNOTATION__CONTENTS, Collections.singletonMap("foo", "bar")) {

        @Override
        public URI getEObjectURI() {
            return EcoreUtil.getURI(EcorePackage.Literals.EANNOTATION);
        }
    });
    assertTrue(new DefaultResourceDescriptionDelta(resourceDesc, resourceDesc2).haveEObjectDescriptionsChanged());
}
Also used : EObjectDescription(org.eclipse.xtext.resource.EObjectDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) URI(org.eclipse.emf.common.util.URI) 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