Search in sources :

Example 16 with LazyLinkingResource

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

the class XtextValidationTest method getResourceFromString.

protected XtextResource getResourceFromString(String model, String uriString, XtextResourceSet rs) throws IOException {
    rs.setClasspathURIContext(getClasspathURIContext());
    XtextResource resource = (XtextResource) getResourceFactory().createResource(URI.createURI(uriString));
    rs.getResources().add(resource);
    resource.load(getAsStream(model), null);
    if (resource instanceof LazyLinkingResource) {
        ((LazyLinkingResource) resource).resolveLazyCrossReferences(CancelIndicator.NullImpl);
    } else {
        EcoreUtil.resolveAll(resource);
    }
    return resource;
}
Also used : LazyLinkingResource(org.eclipse.xtext.linking.lazy.LazyLinkingResource) XtextResource(org.eclipse.xtext.resource.XtextResource)

Aggregations

LazyLinkingResource (org.eclipse.xtext.linking.lazy.LazyLinkingResource)16 Test (org.junit.Test)8 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)5 INode (org.eclipse.xtext.nodemodel.INode)5 ReplaceRegion (org.eclipse.xtext.util.ReplaceRegion)4 XtextResource (org.eclipse.xtext.resource.XtextResource)3 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)3 Resource (org.eclipse.emf.ecore.resource.Resource)2 ANTLRStringStream (org.antlr.runtime.ANTLRStringStream)1 CommonToken (org.antlr.runtime.CommonToken)1 Token (org.antlr.runtime.Token)1 BasicDiagnostic (org.eclipse.emf.common.util.BasicDiagnostic)1 Diagnostic (org.eclipse.emf.ecore.resource.Resource.Diagnostic)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 InternalXtendLexer (org.eclipse.xtend.core.parser.antlr.internal.InternalXtendLexer)1 ExceptionDiagnostic (org.eclipse.xtext.diagnostics.ExceptionDiagnostic)1 Lexer (org.eclipse.xtext.parser.antlr.Lexer)1 StringInputStream (org.eclipse.xtext.util.StringInputStream)1