use of org.eclipse.xtext.linking.lazy.lazyLinking.Type 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));
}
use of org.eclipse.xtext.linking.lazy.lazyLinking.Type in project xtext-core by eclipse.
the class BasicLazyLinkingTest method testReferenceWithOpposite.
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=282486
// and https://bugs.eclipse.org/bugs/show_bug.cgi?id=303441
@SuppressWarnings("unchecked")
@Test
public void testReferenceWithOpposite() throws Exception {
XtextResource resource = getResourceAndExpect(new StringInputStream("type foo {} type bar extends foo {}"), 1);
Model model = (Model) resource.getContents().get(0);
Type typeFoo = model.getTypes().get(0);
Type typeBar = model.getTypes().get(1);
InternalEObject proxy = (InternalEObject) typeBar.eGet(LazyLinkingPackage.Literals.TYPE__EXTENDS, false);
assertTrue(proxy.eIsProxy());
assertEquals(typeFoo, typeBar.getExtends());
List<Type> fooSubtypes = (List<Type>) typeFoo.eGet(LazyLinkingPackage.Literals.TYPE__SUBTYPES, false);
// the opposite is not automatically set (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=282486)
assertEquals(0, fooSubtypes.size());
}
use of org.eclipse.xtext.linking.lazy.lazyLinking.Type 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));
}
use of org.eclipse.xtext.linking.lazy.lazyLinking.Type 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());
}
Aggregations