Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorangelozerr2018-02-20 19:09:40 +0000
committerMickael Istria2018-02-21 16:36:30 +0000
commitd9ab254b705aa2b86247b7fbbe657f8fba9147a7 (patch)
treea2effac50c707ad3ddc9f6d4465765a133c0cf7d
parent64e89a8bde646e80ac219573267de2aaef01aa85 (diff)
downloadeclipse.platform.text-d9ab254b705aa2b86247b7fbbe657f8fba9147a7.tar.gz
eclipse.platform.text-d9ab254b705aa2b86247b7fbbe657f8fba9147a7.tar.xz
eclipse.platform.text-d9ab254b705aa2b86247b7fbbe657f8fba9147a7.zip
Bug 531421 - [CodeMining] Adapt the source viewer CodeMining API toI20180221-2000
support CodeMining preferences Change-Id: I1ba0624c29d08f5a64d5a02df76af2040e311f68 Signed-off-by: angelozerr <angelo.zerr@gmail.com>
-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