Search in sources :

Example 36 with FastPartitioner

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

the class DiffDocument method connect.

/**
 * Sets up the document to use information from the given
 * {@link DiffRegionFormatter} for partitioning the document into
 * partitions for file headlines, hunk headers, and added or removed lines.
 * It is assumed that the given formatter has been used to generate content
 * into the document.
 *
 * @param formatter
 *            to obtain information from
 */
public void connect(DiffRegionFormatter formatter) {
    regions = formatter.getRegions();
    fileRegions = formatter.getFileRegions();
    if ((fileRegions == null || fileRegions.length == 0) && defaultRepository != null && defaultFileDiff != null) {
        fileRegions = new FileDiffRegion[] { new FileDiffRegion(defaultRepository, defaultFileDiff, 0, getLength()) };
    }
    newPathPattern = Pattern.compile(// $NON-NLS-1$
    Pattern.quote(formatter.getNewPrefix()) + "\\S+");
    oldPathPattern = Pattern.compile(// $NON-NLS-1$
    Pattern.quote(formatter.getOldPrefix()) + "\\S+");
    maximumLineNumbers = formatter.getMaximumLineNumbers();
    // Connect a new partitioner.
    IDocumentPartitioner partitioner = new FastPartitioner(new DiffPartitionTokenScanner(), new String[] { IDocument.DEFAULT_CONTENT_TYPE, HEADLINE_CONTENT_TYPE, HUNK_CONTENT_TYPE, ADDED_CONTENT_TYPE, REMOVED_CONTENT_TYPE });
    IDocumentPartitioner oldPartitioner = getDocumentPartitioner();
    if (oldPartitioner != null) {
        oldPartitioner.disconnect();
    }
    partitioner.connect(this);
    setDocumentPartitioner(partitioner);
}
Also used : IDocumentPartitioner(org.eclipse.jface.text.IDocumentPartitioner) FileDiffRegion(org.eclipse.egit.ui.internal.commit.DiffRegionFormatter.FileDiffRegion) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner)

Example 37 with FastPartitioner

use of org.eclipse.jface.text.rules.FastPartitioner in project jbosstools-hibernate by jbosstools.

the class HQLEditorDocumentSetupParticipant method setup.

/**
 * Sets up the document to be ready for use by a text file buffer.
 *
 * @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument)
 */
public void setup(IDocument document) {
    if (document instanceof IDocumentExtension3) {
        IDocumentExtension3 extension3 = (IDocumentExtension3) document;
        partitioner = new FastPartitioner(new HQLPartitionScanner(), HQLPartitionScanner.HQL_PARTITION_TYPES);
        partitioner.connect(document);
        extension3.setDocumentPartitioner(HQLSourceViewerConfiguration.HQL_PARTITIONING, partitioner);
    }
}
Also used : IDocumentExtension3(org.eclipse.jface.text.IDocumentExtension3) FastPartitioner(org.eclipse.jface.text.rules.FastPartitioner)

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