Search in sources :

Example 11 with Property

use of org.eclipse.xtext.linking.lazy.lazyLinking.Property in project xtext-core by eclipse.

the class BasicLazyLinkingTest method testLazyMultiRefDuplicates.

@Test
public void testLazyMultiRefDuplicates() throws Exception {
    XtextResource resource = getResource(new StringInputStream("type A {} type B { A B A a; }"));
    Model m = (Model) resource.getContents().get(0);
    Type t1 = m.getTypes().get(0);
    Type t2 = m.getTypes().get(1);
    Property property = t2.getProperties().get(0);
    EList<Type> types = property.getType();
    assertEquals(t1, types.get(0));
    assertEquals(t2, types.get(1));
    assertEquals(t1, types.get(2));
    assertEquals(t1, types.get(0));
    assertEquals(t2, types.get(1));
    assertEquals(t1, types.get(2));
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) Type(org.eclipse.xtext.linking.lazy.lazyLinking.Type) Model(org.eclipse.xtext.linking.lazy.lazyLinking.Model) XtextResource(org.eclipse.xtext.resource.XtextResource) UnresolvedProxyProperty(org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty) Property(org.eclipse.xtext.linking.lazy.lazyLinking.Property) Test(org.junit.Test)

Example 12 with Property

use of org.eclipse.xtext.linking.lazy.lazyLinking.Property in project xtext-core by eclipse.

the class BasicLazyLinkingTest method testBug281775_01.

@Test
public void testBug281775_01() throws Exception {
    String model = "type A {\n" + "  A B a;\n" + "}\n" + "type B {\n" + "  B A b;\n" + "}";
    XtextResource resource = getResource(new StringInputStream(model));
    Model m = (Model) resource.getContents().get(0);
    Type t1 = m.getTypes().get(0);
    assertEquals("A", t1.getName());
    Type t2 = m.getTypes().get(1);
    assertEquals("B", t2.getName());
    Property propA = t1.getProperties().get(0);
    assertEquals(2, propA.getType().size());
    assertEquals(t1, propA.getType().get(0));
    assertEquals(t2, propA.getType().get(1));
    Property propB = t2.getProperties().get(0);
    assertEquals(2, propB.getType().size());
    assertEquals(t2, propB.getType().get(0));
    assertEquals(t1, propB.getType().get(1));
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) Type(org.eclipse.xtext.linking.lazy.lazyLinking.Type) Model(org.eclipse.xtext.linking.lazy.lazyLinking.Model) XtextResource(org.eclipse.xtext.resource.XtextResource) UnresolvedProxyProperty(org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty) Property(org.eclipse.xtext.linking.lazy.lazyLinking.Property) Test(org.junit.Test)

Example 13 with Property

use of org.eclipse.xtext.linking.lazy.lazyLinking.Property in project xtext-core by eclipse.

the class LazyLinkingResourceTest method testResolveLazyCrossReferences_02.

@Test
public void testResolveLazyCrossReferences_02() throws Exception {
    with(lazyLinkingTestLangaugeSetup());
    ResourceSetImpl rs = new ResourceSetImpl();
    final Resource res1 = rs.createResource(URI.createURI("file1.lazylinkingtestlanguage"));
    Resource res2 = rs.createResource(URI.createURI("file2.lazylinkingtestlanguage"));
    res1.load(new StringInputStream("type Foo { } type Baz { Foo Bar prop; } }"), null);
    res2.load(new StringInputStream("type Bar { }"), null);
    res1.eAdapters().add(notificationAlert);
    Model m = (Model) res1.getContents().get(0);
    Type t = m.getTypes().get(1);
    Property p = t.getProperties().get(0);
    final InternalEList<Type> types = (InternalEList<Type>) p.getType();
    assertEquals(2, types.size());
    for (Iterator<Type> it = types.basicIterator(); it.hasNext(); ) {
        final Type tt = it.next();
        assertTrue(tt.eIsProxy());
    }
    ((LazyLinkingResource) res1).resolveLazyCrossReferences(CancelIndicator.NullImpl);
    assertFalse(types.basicGet(0).eIsProxy());
    assertTrue(types.basicGet(1).eIsProxy());
    res1.eAdapters().remove(notificationAlert);
    EcoreUtil.resolveAll(res1);
    assertFalse(types.basicGet(0).eIsProxy());
    assertFalse(types.basicGet(1).eIsProxy());
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) Type(org.eclipse.xtext.linking.lazy.lazyLinking.Type) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) Resource(org.eclipse.emf.ecore.resource.Resource) Model(org.eclipse.xtext.linking.lazy.lazyLinking.Model) InternalEList(org.eclipse.emf.ecore.util.InternalEList) Property(org.eclipse.xtext.linking.lazy.lazyLinking.Property) Test(org.junit.Test)

Aggregations

Property (org.eclipse.xtext.linking.lazy.lazyLinking.Property)13 UnresolvedProxyProperty (org.eclipse.xtext.linking.lazy.lazyLinking.UnresolvedProxyProperty)11 Model (org.eclipse.xtext.linking.lazy.lazyLinking.Model)7 Type (org.eclipse.xtext.linking.lazy.lazyLinking.Type)6 EList (org.eclipse.emf.common.util.EList)5 Test (org.junit.Test)5 XtextResource (org.eclipse.xtext.resource.XtextResource)4 StringInputStream (org.eclipse.xtext.util.StringInputStream)4 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)3 IGeneratorNode (org.eclipse.xtext.generator.trace.node.IGeneratorNode)3 InternalEList (org.eclipse.emf.ecore.util.InternalEList)2 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)2 Adapter (org.eclipse.emf.common.notify.Adapter)1 EPackage (org.eclipse.emf.ecore.EPackage)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)1 Action (org.eclipse.xtext.Action)1 IGrammarAccess (org.eclipse.xtext.IGrammarAccess)1 Parameter (org.eclipse.xtext.Parameter)1