Search in sources :

Example 11 with EObjectDescription

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

the class DefaultResourceDescriptionDeltaTest method testHasChanges_DifferentURIs.

@Test
public void testHasChanges_DifferentURIs() 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, Collections.singletonMap("foo", "bar")) {

        @Override
        public URI getEObjectURI() {
            return super.getEObjectURI().appendFragment("foo");
        }
    });
    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)

Example 12 with EObjectDescription

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

the class ImportScopeTest method testAllAliasedElements_05.

@Test
public void testAllAliasedElements_05() 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 13 with EObjectDescription

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

the class ImportScopeTest method testDuplicatesNotVisible_05.

@Test
public void testDuplicatesNotVisible_05() throws Exception {
    final IEObjectDescription desc1 = new EObjectDescription(QualifiedName.create("com", "Foo"), EcorePackage.Literals.EANNOTATION, null);
    SimpleScope outer = new SimpleScope(newArrayList(desc1), false);
    ImportNormalizer n1 = new ImportNormalizer(QualifiedName.create("com"), true, false);
    ImportNormalizer n2 = new ImportNormalizer(QualifiedName.create("com"), true, false);
    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 14 with EObjectDescription

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

the class ImportScopeTest method testDuplicatesNotVisible_01_IgnoreCase.

@Test
public void testDuplicatesNotVisible_01_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 15 with EObjectDescription

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

the class ImportScopeTest method testAllAliasedElements_00.

@Test
public void testAllAliasedElements_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);
    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