Search in sources :

Example 1 with ListBasedDiagnosticConsumer

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

the class XtextResource method doLinking.

protected void doLinking() {
    if (parseResult == null || parseResult.getRootASTElement() == null)
        return;
    final ListBasedDiagnosticConsumer consumer = new ListBasedDiagnosticConsumer();
    linker.linkModel(parseResult.getRootASTElement(), consumer);
    if (!validationDisabled) {
        getErrors().addAll(consumer.getResult(Severity.ERROR));
        getWarnings().addAll(consumer.getResult(Severity.WARNING));
    }
}
Also used : ListBasedDiagnosticConsumer(org.eclipse.xtext.resource.impl.ListBasedDiagnosticConsumer)

Example 2 with ListBasedDiagnosticConsumer

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

the class LazyLinkerTest method testManyValuedResolveProxiesReference.

@Test
public void testManyValuedResolveProxiesReference() throws Exception {
    final EObject foo = newEObject("Foo");
    final List<EObject> bars = Lists.newArrayList(newEObject("Bar"), newEObject("Bar"));
    final Iterator<EObject> barsIterator = bars.iterator();
    final Resource resource = new ResourceImpl(URI.createURI("http://foo/bar.ecore")) {

        @Override
        public EObject getEObject(String uriFragment) {
            return barsIterator.next();
        }
    };
    resourceSet.getResources().add(resource);
    resource.getContents().add(foo);
    final EReference eReference = (EReference) foo.eClass().getEStructuralFeature("many");
    assertFalse(eReference.isResolveProxies());
    final INode leafNode = newCrossReferenceAssignmentNode(eReference.getName());
    final INode leafNode2 = newCrossReferenceAssignmentNode(eReference.getName());
    final ICompositeNode adapter = newSimpleNodeAdapter(leafNode, leafNode2);
    foo.eAdapters().add((Adapter) adapter);
    linker.linkModel(foo, new ListBasedDiagnosticConsumer());
    assertEquals(bars, foo.eGet(eReference, false));
}
Also used : INode(org.eclipse.xtext.nodemodel.INode) ResourceImpl(org.eclipse.emf.ecore.resource.impl.ResourceImpl) EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) ListBasedDiagnosticConsumer(org.eclipse.xtext.resource.impl.ListBasedDiagnosticConsumer) EReference(org.eclipse.emf.ecore.EReference) Test(org.junit.Test)

Example 3 with ListBasedDiagnosticConsumer

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

the class LazyLinkerTest method testSingleValuedResolveProxiesReference.

@Test
public void testSingleValuedResolveProxiesReference() throws Exception {
    final EObject foo = newEObject("Foo");
    final EObject bar = newEObject("Bar");
    final Resource resource = new ResourceImpl(URI.createURI("http://foo/bar.ecore")) {

        @Override
        public EObject getEObject(String uriFragment) {
            return bar;
        }
    };
    resourceSet.getResources().add(resource);
    resource.getContents().add(foo);
    final EReference eReference = (EReference) foo.eClass().getEStructuralFeature("single");
    assertFalse(eReference.isResolveProxies());
    final INode leafNode = newCrossReferenceAssignmentNode(eReference.getName());
    final ICompositeNode adapter = newSimpleNodeAdapter(leafNode);
    foo.eAdapters().add((Adapter) adapter);
    linker.linkModel(foo, new ListBasedDiagnosticConsumer());
    assertEquals(bar, foo.eGet(eReference, false));
}
Also used : INode(org.eclipse.xtext.nodemodel.INode) ResourceImpl(org.eclipse.emf.ecore.resource.impl.ResourceImpl) EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) ListBasedDiagnosticConsumer(org.eclipse.xtext.resource.impl.ListBasedDiagnosticConsumer) EReference(org.eclipse.emf.ecore.EReference) Test(org.junit.Test)

Aggregations

ListBasedDiagnosticConsumer (org.eclipse.xtext.resource.impl.ListBasedDiagnosticConsumer)3 EObject (org.eclipse.emf.ecore.EObject)2 EReference (org.eclipse.emf.ecore.EReference)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 ResourceImpl (org.eclipse.emf.ecore.resource.impl.ResourceImpl)2 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)2 INode (org.eclipse.xtext.nodemodel.INode)2 Test (org.junit.Test)2