Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension5.java20
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java13
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java3
3 files changed, 25 insertions, 11 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension5.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension5.java
index 2ed4f97bd..9a732cf44 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension5.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ISourceViewerExtension5.java
@@ -33,6 +33,20 @@ public interface ISourceViewerExtension5 {
void setCodeMiningAnnotationPainter(AnnotationPainter painter);
/**
+ * Register the code mining providers.
+ *
+ * @param codeMiningProviders the code mining providers to register.
+ */
+ void setCodeMiningProviders(ICodeMiningProvider[] codeMiningProviders);
+
+ /**
+ * Returns true there are code mining providers and false otherwise.
+ *
+ * @return true there are code mining providers and false otherwise.
+ */
+ boolean hasCodeMiningProviders();
+
+ /**
* Update the code minings.
*
* Clients and implementors are responsible of calling this method when needed. A typical
@@ -41,10 +55,4 @@ public interface ISourceViewerExtension5 {
*/
void updateCodeMinings();
- /**
- * Register the code mining providers.
- *
- * @param codeMiningProviders the code mining providers to register.
- */
- void setCodeMiningProviders(ICodeMiningProvider[] codeMiningProviders);
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
index 93d7db848..c98d750c0 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
@@ -761,7 +761,7 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi
setHyperlinkDetectors(null, SWT.NONE);
- if (fCodeMiningManager != null) {
+ if (hasCodeMiningProviders()) {
fCodeMiningManager.uninstall();
fCodeMiningManager= null;
}
@@ -1272,12 +1272,12 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi
boolean enable= codeMiningProviders != null && codeMiningProviders.length > 0;
fCodeMiningProviders= codeMiningProviders;
if (enable) {
- if (fCodeMiningManager != null) {
+ if (hasCodeMiningProviders()) {
fCodeMiningManager.setCodeMiningProviders(fCodeMiningProviders);
}
ensureCodeMiningManagerInstalled();
} else {
- if (fCodeMiningManager != null)
+ if (hasCodeMiningProviders())
fCodeMiningManager.uninstall();
fCodeMiningManager= null;
}
@@ -1300,8 +1300,13 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi
}
@Override
+ public boolean hasCodeMiningProviders() {
+ return fCodeMiningManager != null;
+ }
+
+ @Override
public void updateCodeMinings() {
- if (fCodeMiningManager != null) {
+ if (hasCodeMiningProviders()) {
fCodeMiningManager.run();
}
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
index e57e427a8..bed6088bf 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
@@ -4038,9 +4038,10 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
/**
* Install codemining providers.
+ *
* @since 3.10
*/
- private void installCodeMinigProviders() {
+ protected void installCodeMinigProviders() {
ICodeMiningProvider[] providers = TextEditorPlugin.getDefault().getCodeMiningProviderRegistry()
.getProviders(this.getSourceViewer(), this);
((ISourceViewerExtension5) fSourceViewer).setCodeMiningProviders(providers);

Back to the top