Search in sources :

Example 6 with DocumentTokenSource

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

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

the class BacktrackingLexerPresentationDamagerTest method createDocument.

@Override
protected Document createDocument(String before) throws Exception {
    DocumentTokenSource source = new BacktrackingLexerDocumentTokenSource();
    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) BacktrackingLexerDocumentTokenSource(org.eclipse.xtext.ui.editor.model.BacktrackingLexerDocumentTokenSource) DocumentTokenSource(org.eclipse.xtext.ui.editor.model.DocumentTokenSource) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) BacktrackingLexerDocumentTokenSource(org.eclipse.xtext.ui.editor.model.BacktrackingLexerDocumentTokenSource)

Example 8 with DocumentTokenSource

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

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

Example 10 with DocumentTokenSource

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

the class AbstractXtextDocumentTest 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, outdatedStateManager, operationCanceledManager);
    document.setDocumentPartitioner(partitioner);
    partitioner.connect(document);
    document.set(s);
    return document;
}
Also used : XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) TerminalsTokenTypeToPartitionMapper(org.eclipse.xtext.ui.editor.model.TerminalsTokenTypeToPartitionMapper) 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)

Aggregations

DocumentTokenSource (org.eclipse.xtext.ui.editor.model.DocumentTokenSource)11 Lexer (org.eclipse.xtext.parser.antlr.Lexer)8 XtextDocument (org.eclipse.xtext.ui.editor.model.XtextDocument)8 DocumentEvent (org.eclipse.jface.text.DocumentEvent)3 InternalXtextLexer (org.eclipse.xtext.parser.antlr.internal.InternalXtextLexer)3 OutdatedStateManager (org.eclipse.xtext.resource.OutdatedStateManager)3 OperationCanceledManager (org.eclipse.xtext.service.OperationCanceledManager)3 AntlrTokenDefProvider (org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider)2 XtextAntlrTokenFileProvider (org.eclipse.xtext.parser.antlr.XtextAntlrTokenFileProvider)2 DocumentPartitioner (org.eclipse.xtext.ui.editor.model.DocumentPartitioner)2 IXtextDocument (org.eclipse.xtext.ui.editor.model.IXtextDocument)2 PartitionTokenScanner (org.eclipse.xtext.ui.editor.model.PartitionTokenScanner)2 TerminalsTokenTypeToPartitionMapper (org.eclipse.xtext.ui.editor.model.TerminalsTokenTypeToPartitionMapper)2 List (java.util.List)1 URI (org.eclipse.emf.common.util.URI)1 Document (org.eclipse.jface.text.Document)1 IDocumentListener (org.eclipse.jface.text.IDocumentListener)1 IRegion (org.eclipse.jface.text.IRegion)1 Region (org.eclipse.jface.text.Region)1 TextAttribute (org.eclipse.jface.text.TextAttribute)1