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);
}
}
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" });
}
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;
}
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);
}
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();
}
}
Aggregations