synchronized (lock) {
if (reconciler == null) {
reconciler = new PresentationReconciler();
reconciler.setDocumentPartitioning(IPythonPartitions.PYTHON_PARTITION_TYPE);
DefaultDamagerRepairer dr;
// DefaultDamagerRepairer implements both IPresentationDamager, IPresentationRepairer
// IPresentationDamager::getDamageRegion does not scan, just
// returns the intersection of document event, and partition region
// IPresentationRepairer::createPresentation scans
// gets each token, and sets text attributes according to token
// We need to cover all the content types from PyPartitionScanner
// Comments have uniform color
commentScanner = new PyColoredScanner(colorCache, PydevEditorPrefs.COMMENT_COLOR);
dr = new DefaultDamagerRepairer(commentScanner);
reconciler.setDamager(dr, IPythonPartitions.PY_COMMENT);
reconciler.setRepairer(dr, IPythonPartitions.PY_COMMENT);
// Backquotes have uniform color
backquotesScanner = new PyColoredScanner(colorCache, PydevEditorPrefs.BACKQUOTES_COLOR);
dr = new DefaultDamagerRepairer(backquotesScanner);
reconciler.setDamager(dr, IPythonPartitions.PY_BACKQUOTES);
reconciler.setRepairer(dr, IPythonPartitions.PY_BACKQUOTES);
// Strings have uniform color
stringScanner = new PyColoredScanner(colorCache, PydevEditorPrefs.STRING_COLOR);
dr = new DefaultDamagerRepairer(stringScanner);
reconciler.setDamager(dr, IPythonPartitions.PY_SINGLELINE_STRING1);
reconciler.setRepairer(dr, IPythonPartitions.PY_SINGLELINE_STRING1);
reconciler.setDamager(dr, IPythonPartitions.PY_SINGLELINE_STRING2);
reconciler.setRepairer(dr, IPythonPartitions.PY_SINGLELINE_STRING2);
reconciler.setDamager(dr, IPythonPartitions.PY_MULTILINE_STRING1);
reconciler.setRepairer(dr, IPythonPartitions.PY_MULTILINE_STRING1);
reconciler.setDamager(dr, IPythonPartitions.PY_MULTILINE_STRING2);
reconciler.setRepairer(dr, IPythonPartitions.PY_MULTILINE_STRING2);
// Default content is code, we need syntax highlighting
ICodeScannerKeywords codeScannerKeywords = null;
if (sourceViewer instanceof IAdaptable) {
IAdaptable iAdaptable = (IAdaptable) sourceViewer;
codeScannerKeywords = (ICodeScannerKeywords) iAdaptable.getAdapter(ICodeScannerKeywords.class);
codeScanner = new PyCodeScanner(colorCache, codeScannerKeywords);
} else {
codeScanner = new PyCodeScanner(colorCache);
}
dr = new DefaultDamagerRepairer(codeScanner);
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
}
}