Search in sources :

Example 1 with InternalXtextLexer

use of org.eclipse.xtext.parser.antlr.internal.InternalXtextLexer 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 InternalXtextLexer

use of org.eclipse.xtext.parser.antlr.internal.InternalXtextLexer in project xtext-eclipse by eclipse.

the class DocumentLockerTest method createTokenSource.

private DocumentTokenSource createTokenSource() {
    DocumentTokenSource tokenSource = new DocumentTokenSource();
    tokenSource.setLexer(() -> new InternalXtextLexer());
    return tokenSource;
}
Also used : DocumentTokenSource(org.eclipse.xtext.ui.editor.model.DocumentTokenSource) InternalXtextLexer(org.eclipse.xtext.parser.antlr.internal.InternalXtextLexer)

Example 3 with InternalXtextLexer

use of org.eclipse.xtext.parser.antlr.internal.InternalXtextLexer 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

InternalXtextLexer (org.eclipse.xtext.parser.antlr.internal.InternalXtextLexer)3 DocumentTokenSource (org.eclipse.xtext.ui.editor.model.DocumentTokenSource)3 Lexer (org.eclipse.xtext.parser.antlr.Lexer)2 OutdatedStateManager (org.eclipse.xtext.resource.OutdatedStateManager)2 OperationCanceledManager (org.eclipse.xtext.service.OperationCanceledManager)2 IXtextDocument (org.eclipse.xtext.ui.editor.model.IXtextDocument)2 XtextDocument (org.eclipse.xtext.ui.editor.model.XtextDocument)2 XtextResource (org.eclipse.xtext.resource.XtextResource)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