Search in sources :

Example 31 with XtextDocument

use of org.eclipse.xtext.ui.editor.model.XtextDocument in project xtext-xtend by eclipse.

the class AbstractOutlineTests method newAssertBuilder.

protected AssertBuilder newAssertBuilder(XtendFile xtendFile) throws Exception, CoreException {
    XtextDocument document = documentProvider.get();
    document.setInput((XtextResource) xtendFile.eResource());
    IOutlineNode root = treeProvider.createRoot(document);
    AssertBuilder assertBuilder = new AssertBuilder(root);
    return assertBuilder;
}
Also used : XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) IOutlineNode(org.eclipse.xtext.ui.editor.outline.IOutlineNode)

Example 32 with XtextDocument

use of org.eclipse.xtext.ui.editor.model.XtextDocument in project xtext-xtend by eclipse.

the class PresentationDamagerTest method createDocument.

@Override
public Document createDocument(final String before) throws Exception {
    XtextDocument _xblockexpression = null;
    {
        XtendDocumentTokenSource _xtendDocumentTokenSource = new XtendDocumentTokenSource();
        final Procedure1<XtendDocumentTokenSource> _function = (XtendDocumentTokenSource it) -> {
            AntlrTokenDefProvider _antlrTokenDefProvider = new AntlrTokenDefProvider();
            final Procedure1<AntlrTokenDefProvider> _function_1 = (AntlrTokenDefProvider it_1) -> {
                XtendAntlrTokenFileProvider _xtendAntlrTokenFileProvider = new XtendAntlrTokenFileProvider();
                it_1.setAntlrTokenFileProvider(_xtendAntlrTokenFileProvider);
            };
            AntlrTokenDefProvider _doubleArrow = ObjectExtensions.<AntlrTokenDefProvider>operator_doubleArrow(_antlrTokenDefProvider, _function_1);
            it.setTokenDefProvider(_doubleArrow);
            final Provider<Lexer> _function_2 = () -> {
                return this.createLexer();
            };
            it.setLexer(_function_2);
            it.setFlexerFactory(this.flexerFactory);
        };
        final XtendDocumentTokenSource source = ObjectExtensions.<XtendDocumentTokenSource>operator_doubleArrow(_xtendDocumentTokenSource, _function);
        final XtextDocument document = new XtextDocument(source, null, this.outdatedStateManager, this.operationCanceledManager);
        document.set(before);
        _xblockexpression = document;
    }
    return _xblockexpression;
}
Also used : AntlrTokenDefProvider(org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider) InternalXtendLexer(org.eclipse.xtend.core.parser.antlr.internal.InternalXtendLexer) Lexer(org.eclipse.xtext.parser.antlr.Lexer) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) XtendDocumentTokenSource(org.eclipse.xtend.ide.editor.model.XtendDocumentTokenSource) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) XtendAntlrTokenFileProvider(org.eclipse.xtend.core.parser.antlr.XtendAntlrTokenFileProvider)

Example 33 with XtextDocument

use of org.eclipse.xtext.ui.editor.model.XtextDocument in project xtext-eclipse by eclipse.

the class AbstractDamagerRepairerTest method createDocument.

protected Document createDocument(String before) throws Exception {
    DocumentTokenSource source = new DocumentTokenSource();
    source.setLexer(new Provider<Lexer>() {

        @Override
        public Lexer get() {
            return createLexer();
        }
    });
    XtextDocument document = new XtextDocument(source, null, outdatedStateManager, operationCanceledManager);
    document.set(before);
    return document;
}
Also used : Lexer(org.eclipse.xtext.parser.antlr.Lexer) DocumentTokenSource(org.eclipse.xtext.ui.editor.model.DocumentTokenSource) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument)

Example 34 with XtextDocument

use of org.eclipse.xtext.ui.editor.model.XtextDocument in project xtext-eclipse by eclipse.

the class AbstractQuickfixTest method getDocument.

/**
 * The implementation of the following helper methods are taken from the
 * {@code org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder} class.
 */
protected IXtextDocument getDocument(String model) {
    XtextResource xtextResource = getXtextResource(model);
    XtextDocument document = injector.getInstance(XtextDocument.class);
    document.set(model);
    document.setInput(xtextResource);
    return document;
}
Also used : XtextResource(org.eclipse.xtext.resource.XtextResource) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument)

Example 35 with XtextDocument

use of org.eclipse.xtext.ui.editor.model.XtextDocument in project xtext-eclipse by eclipse.

the class ContentAssistProcessorTestBuilder method getDocument.

public IXtextDocument getDocument(final XtextResource xtextResource, final String model) {
    XtextDocument document = get(XtextDocument.class);
    document.set(model);
    document.setInput(xtextResource);
    DocumentPartitioner partitioner = get(DocumentPartitioner.class);
    partitioner.connect(document);
    document.setDocumentPartitioner(partitioner);
    return document;
}
Also used : XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) DocumentPartitioner(org.eclipse.xtext.ui.editor.model.DocumentPartitioner)

Aggregations

XtextDocument (org.eclipse.xtext.ui.editor.model.XtextDocument)50 Test (org.junit.Test)21 IXtextDocument (org.eclipse.xtext.ui.editor.model.IXtextDocument)14 XtextResource (org.eclipse.xtext.resource.XtextResource)13 Lexer (org.eclipse.xtext.parser.antlr.Lexer)9 DocumentTokenSource (org.eclipse.xtext.ui.editor.model.DocumentTokenSource)8 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)5 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 ArrayList (java.util.ArrayList)3 Job (org.eclipse.core.runtime.jobs.Job)3 IDocument (org.eclipse.jface.text.IDocument)3 ITypedRegion (org.eclipse.jface.text.ITypedRegion)3 CancelIndicator (org.eclipse.xtext.util.CancelIndicator)3 StringInputStream (org.eclipse.xtext.util.StringInputStream)3 Injector (com.google.inject.Injector)2 IFile (org.eclipse.core.resources.IFile)2 CoreException (org.eclipse.core.runtime.CoreException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2