Search in sources :

Example 31 with FastPartitioner

use of org.eclipse.jface.text.rules.FastPartitioner in project ch.hsr.ifs.cdttesting by IFS-HSR.

the class DocumentSetupParticipant method setup.

@Override
public void setup(final IDocument document) {
    if (document instanceof IDocumentExtension3) {
        final IDocumentExtension3 extension3 = (IDocumentExtension3) document;
        final IDocumentPartitioner partitioner = new FastPartitioner(Activator.getDefault().getTestFilePartitionScanner(), TestFile.PARTITION_TYPES);
        extension3.setDocumentPartitioner("__rts_partitioning", partitioner);
        partitioner.connect(document);
    }
}
Also used : IDocumentExtension3(org.eclipse.jface.text.IDocumentExtension3) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner)

Example 32 with FastPartitioner

use of org.eclipse.jface.text.rules.FastPartitioner in project webtools.sourceediting by eclipse.

the class AbstractPairMatcherTest method createPartitioner.

private static IDocumentPartitioner createPartitioner() {
    final RuleBasedPartitionScanner scan = new RuleBasedPartitionScanner();
    final List /*<IPredicateRule>*/
    rules = new ArrayList();
    rules.add(new SingleLineRule("|a", "a|", new Token("a")));
    rules.add(new SingleLineRule("|b", "b|", new Token("b")));
    rules.add(new SingleLineRule("|c", "c|", new Token("c")));
    scan.setPredicateRules((IPredicateRule[]) rules.toArray(new IPredicateRule[rules.size()]));
    scan.setDefaultReturnToken(new Token(DEFAULT_PARTITION));
    return new FastPartitioner(scan, new String[] { DEFAULT_PARTITION, "a", "b", "c" });
}
Also used : RuleBasedPartitionScanner(org.eclipse.jface.text.rules.RuleBasedPartitionScanner) SingleLineRule(org.eclipse.jface.text.rules.SingleLineRule) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Token(org.eclipse.jface.text.rules.Token) IPredicateRule(org.eclipse.jface.text.rules.IPredicateRule)

Example 33 with FastPartitioner

use of org.eclipse.jface.text.rules.FastPartitioner in project abstools by abstools.

the class ABSDocumentProvider method createDocument.

@Override
protected IDocument createDocument(Object element) throws CoreException {
    // Avoid ResourceException if you open a file that has disappeared.
    if (isDeleted(element))
        return super.createEmptyDocument();
    IDocument document = super.createDocument(element);
    if (document == null) {
        if (element instanceof IURIEditorInput) {
            IURIEditorInput ei = (IURIEditorInput) element;
            document = createEmptyDocument();
            InputStream is = null;
            try {
                is = ei.getURI().toURL().openStream();
                setDocumentContent(document, is, getEncoding(element));
            } catch (IOException ex) {
                throw new CoreException(new Status(IStatus.ERROR, Constants.PLUGIN_ID, "ABS Editor", ex));
            } finally {
                if (is != null) {
                    try {
                        is.close();
                    } catch (IOException ex) {
                        throw new CoreException(new Status(IStatus.ERROR, Constants.PLUGIN_ID, "ABS Editor", ex));
                    }
                }
            }
        } else
            throw new CoreException(new Status(IStatus.ERROR, Constants.PLUGIN_ID, "Don't know how to open " + element.toString()));
    }
    ABSPartitionScanner scanner = new ABSPartitionScanner();
    IDocumentPartitioner partitioner = new FastPartitioner(scanner, PARTITION_TYPES);
    document.setDocumentPartitioner(partitioner);
    partitioner.connect(document);
    return document;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IURIEditorInput(org.eclipse.ui.IURIEditorInput) CoreException(org.eclipse.core.runtime.CoreException) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) InputStream(java.io.InputStream) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) IOException(java.io.IOException) IDocument(org.eclipse.jface.text.IDocument)

Example 34 with FastPartitioner

use of org.eclipse.jface.text.rules.FastPartitioner in project hale by halestudio.

the class GroovySourceViewerUtil method setupDocument.

/**
 * Setup a Groovy document.
 *
 * @param doc the document
 */
public static void setupDocument(IDocument doc) {
    IPartitionTokenScanner scanner = new GroovyPartitionScanner();
    IDocumentPartitioner partitioner = new FastPartitioner(scanner, GroovyPartitionScanner.LEGAL_CONTENT_TYPES);
    doc.setDocumentPartitioner(partitioner);
    partitioner.connect(doc);
}
Also used : IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) IPartitionTokenScanner(org.eclipse.jface.text.rules.IPartitionTokenScanner) GroovyPartitionScanner(eu.esdihumboldt.hale.ui.util.groovy.internal.GroovyPartitionScanner)

Example 35 with FastPartitioner

use of org.eclipse.jface.text.rules.FastPartitioner in project dbeaver by dbeaver.

the class SQLEditorBase method reloadSyntaxRules.

public void reloadSyntaxRules() {
    // Refresh syntax
    SQLDialect dialect = getSQLDialect();
    IDocument document = getDocument();
    syntaxManager.init(dialect, getActivePreferenceStore());
    SQLRuleManager ruleManager = new SQLRuleManager(syntaxManager);
    ruleManager.loadRules(getDataSource(), SQLEditorBase.isBigScript(getEditorInput()));
    ruleScanner.refreshRules(getDataSource(), ruleManager);
    parserContext = new SQLParserContext(SQLEditorBase.this, syntaxManager, ruleManager, document != null ? document : new Document());
    if (document instanceof IDocumentExtension3) {
        IDocumentPartitioner partitioner = new FastPartitioner(new SQLPartitionScanner(getDataSource(), dialect), SQLParserPartitions.SQL_CONTENT_TYPES);
        partitioner.connect(document);
        try {
            ((IDocumentExtension3) document).setDocumentPartitioner(SQLParserPartitions.SQL_PARTITIONING, partitioner);
        } catch (Throwable e) {
            // $NON-NLS-1$
            log.warn("Error setting SQL partitioner", e);
        }
        ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer();
        if (projectionViewer != null && projectionViewer.getAnnotationModel() != null && document.getLength() > 0) {
            // projectionViewer.getTextWidget().redraw();
            try {
                projectionViewer.reinitializeProjection();
            } catch (Throwable ex) {
                // We can catch OutOfMemory here for too big/complex documents
                // $NON-NLS-1$
                log.warn("Can't initialize SQL syntax projection", ex);
            }
        }
    }
    final IVerticalRuler verticalRuler = getVerticalRuler();
    // Update configuration
    if (getSourceViewerConfiguration() instanceof SQLEditorSourceViewerConfiguration) {
        ((SQLEditorSourceViewerConfiguration) getSourceViewerConfiguration()).onDataSourceChange();
    }
    if (verticalRuler != null) {
        verticalRuler.update();
    }
}
Also used : SQLRuleManager(org.jkiss.dbeaver.model.sql.parser.SQLRuleManager) BasicSQLDialect(org.jkiss.dbeaver.model.impl.sql.BasicSQLDialect) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) SQLPartitionScanner(org.jkiss.dbeaver.ui.editors.sql.syntax.SQLPartitionScanner) ProjectionViewer(org.eclipse.jface.text.source.projection.ProjectionViewer) SQLParserContext(org.jkiss.dbeaver.model.sql.parser.SQLParserContext)

Aggregations

FastPartitioner (org.eclipse.jface.text.rules.FastPartitioner)37 IDocumentPartitioner (org.eclipse.jface.text.IDocumentPartitioner)25 IDocument (org.eclipse.jface.text.IDocument)17 IDocumentExtension3 (org.eclipse.jface.text.IDocumentExtension3)14 RuleBasedPartitionScanner (org.eclipse.jface.text.rules.RuleBasedPartitionScanner)5 Document (org.eclipse.jface.text.Document)4 DocumentEvent (org.eclipse.jface.text.DocumentEvent)4 IDocumentListener (org.eclipse.jface.text.IDocumentListener)4 IPredicateRule (org.eclipse.jface.text.rules.IPredicateRule)4 Token (org.eclipse.jface.text.rules.Token)4 IPartitionTokenScanner (org.eclipse.jface.text.rules.IPartitionTokenScanner)3 SQLDocument (com.cubrid.common.ui.query.editor.SQLDocument)2 SQLPartitionScanner (com.cubrid.common.ui.query.editor.SQLPartitionScanner)2 SQLTextViewer (com.cubrid.common.ui.query.editor.SQLTextViewer)2 SQLViewerConfiguration (com.cubrid.common.ui.query.editor.SQLViewerConfiguration)2 DocumentProvider (com.cubrid.tool.editor.DocumentProvider)2 ArrayList (java.util.ArrayList)2 TextViewerUndoManager (org.eclipse.jface.text.TextViewerUndoManager)2 IToken (org.eclipse.jface.text.rules.IToken)2 MultiLineRule (org.eclipse.jface.text.rules.MultiLineRule)2