Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorangelozerr2017-12-13 15:02:43 +0000
committerMickael Istria2017-12-15 15:32:25 +0000
commit079815ecaf4c3f5aea1bb04692048e955daea8c4 (patch)
treeaac64e126f68b88bab0071ef2049de77d2a5a221 /org.eclipse.jface.text/src
parent9855af89aba96b423622037a259b65f3fa08ec86 (diff)
downloadeclipse.platform.text-079815ecaf4c3f5aea1bb04692048e955daea8c4.tar.gz
eclipse.platform.text-079815ecaf4c3f5aea1bb04692048e955daea8c4.tar.xz
eclipse.platform.text-079815ecaf4c3f5aea1bb04692048e955daea8c4.zip
Bug 528419 - [CodeMining] Provide extension point for CodeMiningI20171218-2000I20171217-2000I20171216-1500I20171215-2000
Change-Id: I1a7d51ae3772aefd382839d27814f88f7fa68efa Signed-off-by: angelozerr <angelo.zerr@gmail.com>
Diffstat (limited to 'org.eclipse.jface.text/src')
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/CodeMiningReconciler.java44
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/CodeMiningStrategy.java74
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java1
3 files changed, 119 insertions, 0 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/CodeMiningReconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/CodeMiningReconciler.java
new file mode 100644
index 00000000000..74e0830eb98
--- /dev/null
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/CodeMiningReconciler.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2017 Angelo ZERR.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Angelo Zerr <angelo.zerr@gmail.com> - [CodeMining] Provide extension point for CodeMining - Bug 528419
+ */
+package org.eclipse.jface.text.codemining;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.reconciler.Reconciler;
+
+/**
+ * A reconciler which update code minings.
+ *
+ * @since 3.13
+ */
+public class CodeMiningReconciler extends Reconciler {
+
+ private CodeMiningStrategy fStrategy;
+
+ public CodeMiningReconciler() {
+ super.setIsIncrementalReconciler(false);
+ fStrategy= new CodeMiningStrategy();
+ this.setReconcilingStrategy(fStrategy, IDocument.DEFAULT_CONTENT_TYPE);
+ }
+
+ @Override
+ public void install(ITextViewer textViewer) {
+ super.install(textViewer);
+ fStrategy.install(textViewer);
+ }
+
+ @Override
+ public void uninstall() {
+ super.uninstall();
+ fStrategy.uninstall();
+ }
+
+}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/CodeMiningStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/CodeMiningStrategy.java
new file mode 100644
index 00000000000..27e645801aa
--- /dev/null
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/CodeMiningStrategy.java
@@ -0,0 +1,74 @@
+/**
+ * Copyright (c) 2017 Angelo ZERR.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Angelo Zerr <angelo.zerr@gmail.com> - [CodeMining] Provide extension point for CodeMining - Bug 528419
+ */
+package org.eclipse.jface.text.codemining;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.reconciler.DirtyRegion;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
+import org.eclipse.jface.text.source.ISourceViewerExtension5;
+
+/**
+ * A reconciling strategy which updates code minings.
+ *
+ * @since 3.13
+ */
+class CodeMiningStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension {
+
+ private ISourceViewerExtension5 fViewer;
+
+ public void install(ITextViewer viewer) {
+ if (viewer instanceof ISourceViewerExtension5) {
+ fViewer= (ISourceViewerExtension5) viewer;
+ }
+ }
+
+ @Override
+ public void initialReconcile() {
+ if (fViewer != null) {
+ // FIXME: this update is done because minings is not updated on focus by AbstractTextEditor#setFocus
+ // But I'm a little afraid to update minings each time editor will have focus
+ // @Mickael what do you think about doing update minings on AbstractTextEditor#setFocus ?
+ fViewer.updateCodeMinings();
+ }
+ }
+
+ @Override
+ public void reconcile(IRegion partition) {
+ if (fViewer != null) {
+ fViewer.updateCodeMinings();
+ }
+ }
+
+ public void uninstall() {
+ fViewer= null;
+ }
+
+ @Override
+ public void setProgressMonitor(IProgressMonitor monitor) {
+ // Do nothing
+ }
+
+ @Override
+ public void setDocument(IDocument document) {
+ // Do nothing
+ }
+
+ @Override
+ public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
+ // Do nothing
+ }
+
+}
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 0876ffd5783..824486d6920 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
@@ -769,6 +769,7 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi
setCodeMiningProviders(null);
if (fInlinedAnnotationSupport != null) {
fInlinedAnnotationSupport.uninstall();
+ fInlinedAnnotationSupport= null;
}
}

Back to the top