Search in sources :

Example 1 with OutdatedStateManager

use of org.eclipse.xtext.resource.OutdatedStateManager in project xtext-eclipse by eclipse.

the class XtextDocumentModifyTest method createDocument.

private IXtextDocument createDocument(String model) throws Exception {
    resource = getResource(new StringInputStream(model));
    DocumentTokenSource tokenSource = new DocumentTokenSource();
    tokenSource.setLexer(new Provider<Lexer>() {

        @Override
        public Lexer get() {
            return new InternalXtextLexer();
        }
    });
    final XtextDocument document = new XtextDocument(tokenSource, get(ITextEditComposer.class), new OutdatedStateManager(), new OperationCanceledManager()) {

        @Override
        public <T> T internalModify(IUnitOfWork<T, XtextResource> work) {
            try {
                return work.exec((XtextResource) resource);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    };
    document.set(model);
    return document;
}
Also used : OutdatedStateManager(org.eclipse.xtext.resource.OutdatedStateManager) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) ITextEditComposer(org.eclipse.xtext.ui.editor.model.edit.ITextEditComposer) OperationCanceledManager(org.eclipse.xtext.service.OperationCanceledManager) IUnitOfWork(org.eclipse.xtext.util.concurrent.IUnitOfWork) StringInputStream(org.eclipse.xtext.util.StringInputStream) InternalXtextLexer(org.eclipse.xtext.parser.antlr.internal.InternalXtextLexer) Lexer(org.eclipse.xtext.parser.antlr.Lexer) DocumentTokenSource(org.eclipse.xtext.ui.editor.model.DocumentTokenSource) InternalXtextLexer(org.eclipse.xtext.parser.antlr.internal.InternalXtextLexer)

Example 2 with OutdatedStateManager

use of org.eclipse.xtext.resource.OutdatedStateManager in project xtext-eclipse by eclipse.

the class DocumentPartitionerTest method getDocument.

public XtextDocument getDocument(String s) {
    TerminalsTokenTypeToPartitionMapper mapper = new TerminalsTokenTypeToPartitionMapper() {

        {
            setTokenDefProvider(new AntlrTokenDefProvider() {

                {
                    setAntlrTokenFileProvider(new XtextAntlrTokenFileProvider());
                }
            });
        }
    };
    PartitionTokenScanner scanner = new PartitionTokenScanner();
    scanner.setMapper(mapper);
    DocumentPartitioner partitioner = new DocumentPartitioner(scanner, mapper);
    DocumentTokenSource tokenSource = new DocumentTokenSource();
    tokenSource.setLexer(new Provider<Lexer>() {

        @Override
        public Lexer get() {
            return new org.eclipse.xtext.parser.antlr.internal.InternalXtextLexer();
        }
    });
    XtextDocument document = new XtextDocument(tokenSource, null, new OutdatedStateManager(), new OperationCanceledManager());
    document.setDocumentPartitioner(partitioner);
    partitioner.connect(document);
    document.set(s);
    return document;
}
Also used : OutdatedStateManager(org.eclipse.xtext.resource.OutdatedStateManager) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) TerminalsTokenTypeToPartitionMapper(org.eclipse.xtext.ui.editor.model.TerminalsTokenTypeToPartitionMapper) OperationCanceledManager(org.eclipse.xtext.service.OperationCanceledManager) AntlrTokenDefProvider(org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider) XtextAntlrTokenFileProvider(org.eclipse.xtext.parser.antlr.XtextAntlrTokenFileProvider) Lexer(org.eclipse.xtext.parser.antlr.Lexer) DocumentTokenSource(org.eclipse.xtext.ui.editor.model.DocumentTokenSource) PartitionTokenScanner(org.eclipse.xtext.ui.editor.model.PartitionTokenScanner) DocumentPartitioner(org.eclipse.xtext.ui.editor.model.DocumentPartitioner)

Example 3 with OutdatedStateManager

use of org.eclipse.xtext.resource.OutdatedStateManager in project xtext-eclipse by eclipse.

the class OutlineTreeProviderTest method createXtextDocument.

protected XtextDocument createXtextDocument(String modelAsText) throws Exception {
    final XtextResource resource = getResource(modelAsText, "test.outlinetestlanguage");
    DocumentTokenSource tokenSource = new DocumentTokenSource();
    tokenSource.setLexer(new Provider<Lexer>() {

        @Override
        public Lexer get() {
            return new InternalXtextLexer();
        }
    });
    XtextDocument xtextDocument = new XtextDocument(tokenSource, null, new OutdatedStateManager(), new OperationCanceledManager());
    xtextDocument.setInput(resource);
    xtextDocument.set(modelAsText);
    return xtextDocument;
}
Also used : InternalXtextLexer(org.eclipse.xtext.parser.antlr.internal.InternalXtextLexer) Lexer(org.eclipse.xtext.parser.antlr.Lexer) DocumentTokenSource(org.eclipse.xtext.ui.editor.model.DocumentTokenSource) InternalXtextLexer(org.eclipse.xtext.parser.antlr.internal.InternalXtextLexer) OutdatedStateManager(org.eclipse.xtext.resource.OutdatedStateManager) XtextResource(org.eclipse.xtext.resource.XtextResource) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) OperationCanceledManager(org.eclipse.xtext.service.OperationCanceledManager)

Aggregations

Lexer (org.eclipse.xtext.parser.antlr.Lexer)3 OutdatedStateManager (org.eclipse.xtext.resource.OutdatedStateManager)3 OperationCanceledManager (org.eclipse.xtext.service.OperationCanceledManager)3 DocumentTokenSource (org.eclipse.xtext.ui.editor.model.DocumentTokenSource)3 XtextDocument (org.eclipse.xtext.ui.editor.model.XtextDocument)3 InternalXtextLexer (org.eclipse.xtext.parser.antlr.internal.InternalXtextLexer)2 IXtextDocument (org.eclipse.xtext.ui.editor.model.IXtextDocument)2 AntlrTokenDefProvider (org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider)1 XtextAntlrTokenFileProvider (org.eclipse.xtext.parser.antlr.XtextAntlrTokenFileProvider)1 XtextResource (org.eclipse.xtext.resource.XtextResource)1 DocumentPartitioner (org.eclipse.xtext.ui.editor.model.DocumentPartitioner)1 PartitionTokenScanner (org.eclipse.xtext.ui.editor.model.PartitionTokenScanner)1 TerminalsTokenTypeToPartitionMapper (org.eclipse.xtext.ui.editor.model.TerminalsTokenTypeToPartitionMapper)1 ITextEditComposer (org.eclipse.xtext.ui.editor.model.edit.ITextEditComposer)1 StringInputStream (org.eclipse.xtext.util.StringInputStream)1 IUnitOfWork (org.eclipse.xtext.util.concurrent.IUnitOfWork)1