Search in sources :

Example 16 with FastPartitioner

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

the class XMLEditor method setupDocument.

private void setupDocument() {
    IDocument document = getDocument();
    if (document != null) {
        IDocumentPartitioner partitioner = new FastPartitioner(new XMLPartitionScanner(), new String[] { XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_COMMENT });
        partitioner.connect(document);
        ((IDocumentExtension3) document).setDocumentPartitioner(XMLPartitionScanner.XML_PARTITIONING, partitioner);
    }
}
Also used : IDocumentExtension3(org.eclipse.jface.text.IDocumentExtension3) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) IDocument(org.eclipse.jface.text.IDocument)

Example 17 with FastPartitioner

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

the class JSONTextEditor method setupDocument.

private void setupDocument() {
    IDocument document = getDocument();
    if (document != null) {
        IDocumentPartitioner partitioner = new FastPartitioner(new JSONPartitionScanner(), new String[] { JSONPartitionScanner.JSON_STRING });
        partitioner.connect(document);
        ((IDocumentExtension3) document).setDocumentPartitioner(JSONPartitionScanner.JSON_PARTITIONING, partitioner);
    }
}
Also used : IDocumentExtension3(org.eclipse.jface.text.IDocumentExtension3) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) IDocument(org.eclipse.jface.text.IDocument)

Example 18 with FastPartitioner

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

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)

Example 19 with FastPartitioner

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

the class JSONTextEditor method setupDocument.

private void setupDocument() {
    IDocument document = getDocument();
    if (document != null) {
        IDocumentPartitioner partitioner = new FastPartitioner(new JSONPartitionScanner(), new String[] { JSONPartitionScanner.JSON_STRING });
        partitioner.connect(document);
        ((IDocumentExtension3) document).setDocumentPartitioner(JSONPartitionScanner.JSON_PARTITIONING, partitioner);
    }
}
Also used : IDocumentExtension3(org.eclipse.jface.text.IDocumentExtension3) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) IDocument(org.eclipse.jface.text.IDocument)

Example 20 with FastPartitioner

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

the class XMLEditor method setupDocument.

private void setupDocument() {
    IDocument document = getDocument();
    if (document != null) {
        IDocumentPartitioner partitioner = new FastPartitioner(new XMLPartitionScanner(), new String[] { XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_COMMENT });
        partitioner.connect(document);
        ((IDocumentExtension3) document).setDocumentPartitioner(XMLPartitionScanner.XML_PARTITIONING, partitioner);
    }
}
Also used : IDocumentExtension3(org.eclipse.jface.text.IDocumentExtension3) IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner) IDocument(org.eclipse.jface.text.IDocument)

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