Search in sources :

Example 1 with ICoreXtextDocument

use of com.avaloq.tools.ddk.check.runtime.quickfix.ICoreXtextDocument in project dsl-devkit by dsldevkit.

the class ModificationContextRegistry method getXtextDocument.

/**
 * {@inheritDoc}
 */
public ICoreXtextDocument getXtextDocument(final URI uri) {
    final URI trimmedUri = uri.trimFragment();
    ICoreXtextDocument xtextDocument = xtextDocuments.get().get(trimmedUri);
    if (xtextDocument == null) {
        XtextResource xtextResource = getXtextResource(trimmedUri);
        xtextDocument = createDocument(xtextResource);
        xtextDocuments.get().put(trimmedUri, xtextDocument);
    }
    return xtextDocument;
}
Also used : ICoreXtextDocument(com.avaloq.tools.ddk.check.runtime.quickfix.ICoreXtextDocument) XtextResource(org.eclipse.xtext.resource.XtextResource) URI(org.eclipse.emf.common.util.URI)

Example 2 with ICoreXtextDocument

use of com.avaloq.tools.ddk.check.runtime.quickfix.ICoreXtextDocument in project dsl-devkit by dsldevkit.

the class ModificationContextRegistry method createDocument.

/**
 * Creates a new document with the contents of the given {@link XtextResource}.
 *
 * @param resource
 *          the resource to be used as input to the document
 * @return the created document
 */
private ICoreXtextDocument createDocument(final XtextResource resource) {
    XtextDocument document = documentProvider.get();
    if (resource.getParseResult() != null && resource.getParseResult().getRootNode() != null) {
        document.set(resource.getParseResult().getRootNode().getText());
    }
    document.setInput(resource);
    return new XtextDocumentAdapter(document);
}
Also used : ICoreXtextDocument(com.avaloq.tools.ddk.check.runtime.quickfix.ICoreXtextDocument) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument)

Aggregations

ICoreXtextDocument (com.avaloq.tools.ddk.check.runtime.quickfix.ICoreXtextDocument)2 URI (org.eclipse.emf.common.util.URI)1 XtextResource (org.eclipse.xtext.resource.XtextResource)1 XtextDocument (org.eclipse.xtext.ui.editor.model.XtextDocument)1