Search in sources :

Example 51 with XtextDocument

use of org.eclipse.xtext.ui.editor.model.XtextDocument 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

XtextDocument (org.eclipse.xtext.ui.editor.model.XtextDocument)51 Test (org.junit.Test)22 IXtextDocument (org.eclipse.xtext.ui.editor.model.IXtextDocument)15 XtextResource (org.eclipse.xtext.resource.XtextResource)14 DocumentTokenSource (org.eclipse.xtext.ui.editor.model.DocumentTokenSource)12 Lexer (org.eclipse.xtext.parser.antlr.Lexer)9 IUnitOfWork (org.eclipse.xtext.util.concurrent.IUnitOfWork)7 EList (org.eclipse.emf.common.util.EList)6 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)5 EObject (org.eclipse.emf.ecore.EObject)4 ITypedRegion (org.eclipse.jface.text.ITypedRegion)4 Region (org.eclipse.jface.text.Region)4 AntlrTokenDefProvider (org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider)4 DocumentPartitioner (org.eclipse.xtext.ui.editor.model.DocumentPartitioner)4 IOutlineNode (org.eclipse.xtext.ui.editor.outline.IOutlineNode)4 AbstractXtextDocumentTest (org.eclipse.xtext.ui.tests.editor.model.AbstractXtextDocumentTest)4 IFile (org.eclipse.core.resources.IFile)3 Job (org.eclipse.core.runtime.jobs.Job)3 IRegion (org.eclipse.jface.text.IRegion)3 ITextEditComposer (org.eclipse.xtext.ui.editor.model.edit.ITextEditComposer)3