Search in sources :

Example 1 with DocumentPartitioner

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

Example 2 with DocumentPartitioner

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

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

Example 4 with DocumentPartitioner

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

DocumentPartitioner (org.eclipse.xtext.ui.editor.model.DocumentPartitioner)4 XtextDocument (org.eclipse.xtext.ui.editor.model.XtextDocument)4 AntlrTokenDefProvider (org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider)2 Lexer (org.eclipse.xtext.parser.antlr.Lexer)2 XtextAntlrTokenFileProvider (org.eclipse.xtext.parser.antlr.XtextAntlrTokenFileProvider)2 DocumentTokenSource (org.eclipse.xtext.ui.editor.model.DocumentTokenSource)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 OutdatedStateManager (org.eclipse.xtext.resource.OutdatedStateManager)1 OperationCanceledManager (org.eclipse.xtext.service.OperationCanceledManager)1