下面列出了怎么用org.eclipse.jface.text.presentation.IPresentationReconciler的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Returns the {@link TMPresentationReconciler} of the given text viewer and
* null otherwise.
*
* @param textViewer
* @return the {@link TMPresentationReconciler} of the given text viewer and
* null otherwise.
*/
public static TMPresentationReconciler getTMPresentationReconciler(ITextViewer textViewer) {
try {
Field field = SourceViewer.class.getDeclaredField("fPresentationReconciler");
if (field != null) {
field.setAccessible(true);
IPresentationReconciler presentationReconciler = (IPresentationReconciler) field.get(textViewer);
return presentationReconciler instanceof TMPresentationReconciler
? (TMPresentationReconciler) presentationReconciler
: null;
}
} catch (Exception e) {
TMUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TMUIPlugin.PLUGIN_ID, e.getMessage(), e));
}
return null;
}
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
final PresentationReconciler reconciler = new PresentationReconciler();
reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
final SyntaxHighlighter scanner = new SyntaxHighlighter(
com.abstratt.mdd.frontend.textuml.core.TextUMLConstants.KEYWORDS);
final DefaultDamagerRepairer dr = new DefaultDamagerRepairer(scanner);
reconciler.setDamager(dr, ContentTypes.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, ContentTypes.DEFAULT_CONTENT_TYPE);
// fix bug 2127735 --multiline comment is broken
final ITokenScanner commentScanner = scanner.getCommentScanner();
final DefaultDamagerRepairer commentDamagerRepairer = new DefaultDamagerRepairer(commentScanner);
reconciler.setDamager(commentDamagerRepairer, ContentTypes.COMMENT_CONTENT_TYPE);
reconciler.setRepairer(commentDamagerRepairer, ContentTypes.COMMENT_CONTENT_TYPE);
return reconciler;
}
public IPresentationReconciler getPresentationReconciler(
ISourceViewer sourceViewer )
{
PresentationReconciler reconciler = new PresentationReconciler( );
NonRuleBasedDamagerRepairer dr = new NonRuleBasedDamagerRepairer( quoteString );
reconciler.setDamager( dr, SQLPartitionScanner.QUOTE_STRING );
reconciler.setRepairer( dr, SQLPartitionScanner.QUOTE_STRING );
dr = new NonRuleBasedDamagerRepairer( comment );
reconciler.setDamager( dr, SQLPartitionScanner.COMMENT );
reconciler.setRepairer( dr, SQLPartitionScanner.COMMENT );
DefaultDamagerRepairer ddr = new DefaultDamagerRepairer( new SQLKeywordScanner( ) );
reconciler.setDamager( ddr, IDocument.DEFAULT_CONTENT_TYPE );
reconciler.setRepairer( ddr, IDocument.DEFAULT_CONTENT_TYPE );
return reconciler;
}
/**
* @see SourceViewerConfiguration#getPresentationReconciler(ISourceViewer)
*/
public IPresentationReconciler getPresentationReconciler(
ISourceViewer sourceViewer )
{
PresentationReconciler reconciler = new PresentationReconciler( );
DefaultDamagerRepairer dr = new DefaultDamagerRepairer( getDefaultScanner( ) );
reconciler.setDamager( dr, IDocument.DEFAULT_CONTENT_TYPE );
reconciler.setRepairer( dr, IDocument.DEFAULT_CONTENT_TYPE );
NonRuleBasedDamagerRepairer commentRepairer = new NonRuleBasedDamagerRepairer( UIUtil.getAttributeFor( ReportPlugin.EXPRESSION_COMMENT_COLOR_PREFERENCE ) );
reconciler.setDamager( commentRepairer, JSPartitionScanner.JS_COMMENT );
reconciler.setRepairer( commentRepairer, JSPartitionScanner.JS_COMMENT );
NonRuleBasedDamagerRepairer stringRepairer = new NonRuleBasedDamagerRepairer( UIUtil.getAttributeFor( ReportPlugin.EXPRESSION_STRING_COLOR_PREFERENCE ) );
reconciler.setDamager( stringRepairer, JSPartitionScanner.JS_STRING );
reconciler.setRepairer( stringRepairer, JSPartitionScanner.JS_STRING );
NonRuleBasedDamagerRepairer keywordRepairer = new NonRuleBasedDamagerRepairer( UIUtil.getAttributeFor( ReportPlugin.EXPRESSION_KEYWORD_COLOR_PREFERENCE ) );
reconciler.setDamager( keywordRepairer, JSPartitionScanner.JS_KEYWORD );
reconciler.setRepairer( keywordRepairer, JSPartitionScanner.JS_KEYWORD );
return reconciler;
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
DSLPresentationReconciler reconciler = new DSLPresentationReconciler(sourceViewer);
ITokenScanner scanner = new TokenScanner();
String contentType = IDocument.DEFAULT_CONTENT_TYPE;
// TODO preference store
long delay = 300;
DefaultDamagerRepairer dr = new DelayedDamagerRepairer(scanner, reconciler, delay);
reconciler.setDamager(dr, contentType);
reconciler.setRepairer(dr, contentType);
// IResource file = this.extractResource(this.editor);
return reconciler;
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer viewer) {
// Defines a TextMate Presentation reconcilier
TMPresentationReconciler reconciler = new TMPresentationReconciler();
// Set the Angular2 grammar
reconciler.setGrammar(getGrammar());
return reconciler;
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer viewer) {
// Defines a TextMate Presentation reconcilier
TMPresentationReconciler reconciler = new TMPresentationReconciler();
// Set the TypeScript grammar
reconciler.setGrammar(getGrammar());
return reconciler;
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer viewer) {
// Defines a TextMate Presentation reconcilier
TMPresentationReconciler reconciler = new TMPresentationReconciler();
// Set the TypeScript grammar
reconciler.setGrammar(getGrammar());
//reconciler.setThemeId(ThemeIdConstants.Monokai);
return reconciler;
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
XtextPresentationReconciler reconciler = getPresentationReconcilerProvider().get();
reconciler.setDocumentPartitioning(getDocumentPartitioning(sourceViewer));
IPresentationRepairer repairer = repairerProvider.get();
IPresentationDamager damager = damagerProvider.get();
String[] types = partitionTypesMapper.getSupportedPartitionTypes();
for (String partitionType : types) {
reconciler.setRepairer(repairer, partitionType);
reconciler.setDamager(damager, partitionType);
}
return reconciler;
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
XtextPresentationReconciler reconciler = (XtextPresentationReconciler) super
.getPresentationReconciler(sourceViewer);
IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore();
IColorManager colorManager = JavaPlugin.getDefault().getJavaTextTools().getColorManager();
JavaDocScanner javaDocScanner = new JavaDocScanner(colorManager, store, null);
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(javaDocScanner);
reconciler.setRepairer(dr, TokenTypeToPartitionMapper.JAVA_DOC_PARTITION);
reconciler.setDamager(dr, TokenTypeToPartitionMapper.JAVA_DOC_PARTITION);
return reconciler;
}
/**
* This registers one damager repairer for all content in the source viewer.
* The damager-repairer scans the content for TLA keywords and sets them to the
* same color used in the tla editor.
*/
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer)
{
PresentationReconciler reconciler = new PresentationReconciler();
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(TLAEditorActivator.getDefault().getTLACodeScanner());
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
return reconciler;
}
/**
* Returns the {@link TMPresentationReconciler} of the given text viewer and
* null otherwise.
*
* @param textViewer
* @return the {@link TMPresentationReconciler} of the given text viewer and
* null otherwise.
*/
private static TMPresentationReconciler getTMPresentationReconciler(ITextViewer textViewer) {
try {
Field field = SourceViewer.class.getDeclaredField("fPresentationReconciler");
if (field != null) {
field.setAccessible(true);
IPresentationReconciler presentationReconciler = (IPresentationReconciler) field.get(textViewer);
return presentationReconciler instanceof TMPresentationReconciler
? (TMPresentationReconciler) presentationReconciler : null;
}
} catch (Exception e) {
}
return null;
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
if (preferenceStore.getBoolean(TypeScriptUIPreferenceConstants.USE_TEXMATE_FOR_SYNTAX_COLORING)) {
// Advanced Syntax coloration with TextMate
return new TMPresentationReconciler();
}
// Use classic Eclipse ITokenScaner.
PresentationReconciler reconciler = (PresentationReconciler) super.getPresentationReconciler(sourceViewer);
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getJSXScanner());
reconciler.setDamager(dr, IJSXPartitions.JSX);
reconciler.setRepairer(dr, IJSXPartitions.JSX);
return reconciler;
}
@Override
public IPresentationReconciler getPresentationReconciler(
ISourceViewer sourceViewer) {
PresentationReconciler reconciler = (PresentationReconciler) super.getPresentationReconciler(sourceViewer);
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(jsniScanner);
reconciler.setDamager(dr, GWTPartitions.JSNI_METHOD);
reconciler.setRepairer(dr, GWTPartitions.JSNI_METHOD);
return reconciler;
}
@Override
public IPresentationReconciler getPresentationReconciler(
ISourceViewer sourceViewer) {
PresentationReconciler reconciler = new PresentationReconciler();
/*
* Reconciler configuration
*/
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(new CSVTokenScanner(m_delimiter));
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
return reconciler;
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
PresentationReconciler reconciler = (PresentationReconciler) super.getPresentationReconciler(sourceViewer);
ISourceViewerConfiguration configuration = this.getSourceViewerConfiguration();
configuration.setupPresentationReconciler(reconciler, sourceViewer);
return reconciler;
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer)
{
if (disableBackgroundReconciler)
{
return super.getPresentationReconciler(sourceViewer);
}
else
{
PresentationReconciler reconciler = new CommonPresentationReconciler();
reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
return reconciler;
}
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
PresentationReconciler reconciler = (PresentationReconciler) super.getPresentationReconciler(sourceViewer);
DefaultDamagerRepairer dr = new ThemeingDamagerRepairer(getStartEndTokenScanner());
reconciler.setDamager(dr, CompositePartitionScanner.START_SWITCH_TAG);
reconciler.setRepairer(dr, CompositePartitionScanner.START_SWITCH_TAG);
reconciler.setDamager(dr, CompositePartitionScanner.END_SWITCH_TAG);
reconciler.setRepairer(dr, CompositePartitionScanner.END_SWITCH_TAG);
defaultSourceViewerConfiguration.setupPresentationReconciler(reconciler, sourceViewer);
primarySourceViewerConfiguration.setupPresentationReconciler(reconciler, sourceViewer);
return reconciler;
}
private static IPresentationReconciler getPresentationReconciler(ISegmentViewer viewer) {
// 构造函数中,已经默认设置 IDocumentExtension3.DEFAULT_PARTITIONING
PresentationReconciler reconciler = new PresentationReconciler();
PresentationRepairer repairer = new PresentationRepairer(getRecipeScanner(viewer.getDocument()), viewer);
reconciler.setRepairer(repairer, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.install(viewer);
return reconciler;
}
private static IPresentationReconciler getPresentationReconciler(ITextViewer viewer) {
// 构造函数中,已经默认设置 IDocumentExtension3.DEFAULT_PARTITIONING
PresentationReconciler reconciler = new PresentationReconciler();
PresentationRepairer repairer = new PresentationRepairer(getRecipeScanner(viewer.getDocument()));
reconciler.setRepairer(repairer, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.install(viewer);
return reconciler;
}
private static IPresentationReconciler getPresentationReconciler(CellEditorTextViewer viewer) {
// 构造函数中,已经默认设置 IDocumentExtension3.DEFAULT_PARTITIONING
PresentationReconciler reconciler = new PresentationReconciler();
PresentationRepairer repairer = new PresentationRepairer(getRecipeScanner(viewer.getDocument()), viewer);
reconciler.setRepairer(repairer, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.install(viewer);
return reconciler;
}
private static IPresentationReconciler getPresentationReconciler(ISegmentViewer viewer) {
// 构造函数中,已经默认设置 IDocumentExtension3.DEFAULT_PARTITIONING
PresentationReconciler reconciler = new PresentationReconciler();
PresentationRepairer repairer = new PresentationRepairer(getRecipeScanner(viewer.getDocument()), viewer);
reconciler.setRepairer(repairer, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.install(viewer);
return reconciler;
}
private static IPresentationReconciler getPresentationReconciler(ITextViewer viewer) {
// 构造函数中,已经默认设置 IDocumentExtension3.DEFAULT_PARTITIONING
PresentationReconciler reconciler = new PresentationReconciler();
PresentationRepairer repairer = new PresentationRepairer(getRecipeScanner(viewer.getDocument()));
reconciler.setRepairer(repairer, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.install(viewer);
return reconciler;
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
PresentationReconciler reconciler = createPresentationReconciler();
reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
setupPresentationReconciler(reconciler, sourceViewer);
return reconciler;
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
PresentationReconciler reconciler = createPresentationReconciler();
reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
setupPresentationReconciler(reconciler, sourceViewer);
return reconciler;
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
return reconciler;
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer viewer) {
// Defines a TextMate Presentation reconcilier
return new TMPresentationReconciler();
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer viewer) {
// Defines a TextMate Presentation reconcilier
return new TMPresentationReconciler();
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer viewer) {
// Defines a TextMate Presentation reconcilier
return new TMPresentationReconciler();
}
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer viewer) {
// Defines a TextMate Presentation reconcilier
return new TMPresentationReconciler();
}