Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorangelozerr2018-03-23 17:23:58 -0400
committerKarsten Thoms2018-03-25 09:16:36 -0400
commit695bac0ada85a8d646ca492b7d1910e9c98b265a (patch)
tree239eda6c8cff5f98d8dbed7bfa883882cfcb2798 /org.eclipse.jface.text/src
parenta66504b047df85a45ad5680be34b2edbe430b39f (diff)
downloadeclipse.platform.text-695bac0ada85a8d646ca492b7d1910e9c98b265a.tar.gz
eclipse.platform.text-695bac0ada85a8d646ca492b7d1910e9c98b265a.tar.xz
eclipse.platform.text-695bac0ada85a8d646ca492b7d1910e9c98b265a.zip
Bug 532091 - [CodeMining] Don't draw minings which are canceledI20180326-2000I20180325-2000
Change-Id: Ib14d8e39030ec9b9c593fcb0be8edb0e56cd1815 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/internal/text/codemining/CodeMiningLineContentAnnotation.java43
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningLineHeaderAnnotation.java55
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/ICodeMining.java11
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationDrawingStrategy.java8
4 files changed, 80 insertions, 37 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningLineContentAnnotation.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningLineContentAnnotation.java
index 98f4315e2..45d4b0197 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningLineContentAnnotation.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningLineContentAnnotation.java
@@ -73,13 +73,22 @@ public class CodeMiningLineContentAnnotation extends LineContentAnnotation imple
@Override
public void update(List<ICodeMining> minings, IProgressMonitor monitor) {
+ if (fResolvedMinings == null || (fResolvedMinings.length != minings.size())) {
+ // size of resolved minings are different from size of minings to update, initialize it with size of minings to update
+ fResolvedMinings= new ICodeMining[minings.size()];
+ }
+ // fill valid resolved minings with old minings.
+ int length= Math.min(fMinings.size(), minings.size());
+ for (int i= 0; i < length; i++) {
+ ICodeMining mining= fMinings.get(i);
+ if (mining.getLabel() != null) {
+ // mining was resolved without an error.
+ fResolvedMinings[i]= mining;
+ }
+ }
disposeMinings();
fMonitor= monitor;
fMinings.addAll(minings);
- if (fResolvedMinings == null || (fResolvedMinings.length != fMinings.size())) {
- // size of resolved minings are different from size of minings to update, initialize it with size of minings to update
- fResolvedMinings= new ICodeMining[fMinings.size()];
- }
}
@Override
@@ -106,24 +115,26 @@ public class CodeMiningLineContentAnnotation extends LineContentAnnotation imple
fBounds.clear();
for (int i= 0; i < minings.size(); i++) {
ICodeMining mining= minings.get(i);
- if (!mining.isResolved()) {
- // the mining is not resolved.
+ // try to get the last resolved mining.
+ ICodeMining lastResolvedMining= (fResolvedMinings != null && fResolvedMinings.length > i) ? fResolvedMinings[i] : null;
+ if (mining.getLabel() != null) {
+ // mining is resolved without error, update the resolved mining list
+ fResolvedMinings[i]= mining;
+ } else if (!mining.isResolved()) {
+ // the mining is not resolved, draw the last resolved mining
+ mining= lastResolvedMining;
if (!redrawn) {
// redraw the annotation when mining is resolved.
redraw();
redrawn= true;
}
- // try to get the last resolved mining.
- if (fResolvedMinings != null) {
- mining= fResolvedMinings[i];
- }
- if (mining == null) {
- // the last mining was not resolved, don't draw it.
- continue;
- }
} else {
- // mining is resolved, update the resolved mining list
- fResolvedMinings[i]= mining;
+ // the mining is resolved with error, draw the last resolved mining
+ mining= lastResolvedMining;
+ }
+ if (mining == null) {
+ // ignore the draw of mining
+ continue;
}
// draw the mining
if (nbDraw > 0) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningLineHeaderAnnotation.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningLineHeaderAnnotation.java
index 21a67dc6a..b2d7e9dbe 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningLineHeaderAnnotation.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningLineHeaderAnnotation.java
@@ -75,32 +75,40 @@ public class CodeMiningLineHeaderAnnotation extends LineHeaderAnnotation impleme
@Override
public int getHeight() {
- return hasAtLeastOneResolvedMining() ? super.getHeight() : 0;
+ return hasAtLeastOneResolvedMiningNotEmpty() ? super.getHeight() : 0;
}
/**
- * Returns <code>true</code> if the annotation has at least one resolved mining and
- * <code>false</code> otherwise.
+ * Returns <code>true</code> if the annotation has at least one resolved mining which have a
+ * label and <code>false</code> otherwise.
*
- * @return <code>true</code> if the annotation has at least one resolved mining and
- * <code>false</code> otherwise.
+ * @return <code>true</code> if the annotation has at least one resolved mining which have a
+ * label and <code>false</code> otherwise.
*/
- private boolean hasAtLeastOneResolvedMining() {
+ private boolean hasAtLeastOneResolvedMiningNotEmpty() {
if (fResolvedMinings == null || fResolvedMinings.length == 0) {
return false;
}
- return Stream.of(fResolvedMinings).anyMatch(Objects::nonNull);
+ return Stream.of(fResolvedMinings).anyMatch(m -> Objects.nonNull(m) && !m.getLabel().isEmpty());
}
@Override
public void update(List<ICodeMining> minings, IProgressMonitor monitor) {
+ if (fResolvedMinings == null || (fResolvedMinings.length != minings.size())) {
+ // size of resolved minings are different from size of minings to update, initialize it with size of minings to update
+ fResolvedMinings= new ICodeMining[minings.size()];
+ }
+ // fill valid resolved minings with old minings.
+ int length= Math.min(fMinings.size(), minings.size());
+ for (int i= 0; i < length; i++) {
+ ICodeMining mining= fMinings.get(i);
+ if (mining.getLabel() != null) {
+ fResolvedMinings[i]= mining;
+ }
+ }
disposeMinings();
fMonitor= monitor;
fMinings.addAll(minings);
- if (fResolvedMinings == null || (fResolvedMinings.length != fMinings.size())) {
- // size of resolved minings are different from size of minings to update, initialize it with size of minings to update
- fResolvedMinings= new ICodeMining[fMinings.size()];
- }
}
@Override
@@ -126,21 +134,26 @@ public class CodeMiningLineHeaderAnnotation extends LineHeaderAnnotation impleme
fBounds.clear();
for (int i= 0; i < minings.size(); i++) {
ICodeMining mining= minings.get(i);
- if (!mining.isResolved()) {
+ // try to get the last resolved mining.
+ ICodeMining lastResolvedMining= (fResolvedMinings != null && fResolvedMinings.length > i) ? fResolvedMinings[i] : null;
+ if (mining.getLabel() != null) {
+ // mining is resolved with none error, update the resolved mining list
+ fResolvedMinings[i]= mining;
+ } else if (!mining.isResolved()) {
+ // the mining is not resolved, draw the last resolved mining
+ mining= lastResolvedMining;
if (!redrawn) {
+ // redraw the annotation when mining is resolved.
redraw();
redrawn= true;
}
- // try to get the last resolved mining.
- if (fResolvedMinings != null) {
- mining= fResolvedMinings[i];
- }
- if (mining == null) {
- continue;
- }
} else {
- // mining is resolved, update the resolved mining list
- fResolvedMinings[i]= mining;
+ // the mining is resolved with error, draw the last resolved mining
+ mining= lastResolvedMining;
+ }
+ if (mining == null) {
+ // ignore the draw of mining
+ continue;
}
// draw the mining
if (nbDraw > 0) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/ICodeMining.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/ICodeMining.java
index 4f8eb6284..7316e62db 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/ICodeMining.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/ICodeMining.java
@@ -53,6 +53,17 @@ public interface ICodeMining {
* Returns the label may be set early in the class lifecycle, or upon completion of the future
* provided by {@link #resolve(ITextViewer, IProgressMonitor)} operation.
*
+ * <p>
+ * The returned label can have several values:
+ * <ul>
+ * <li><code>null</code> when mining is not resolved</li>
+ * <li><code>null</code> when mining is resolved means that mining was resolved with an error and it will not
+ * be displayed.</li>
+ * <li>empty when mining is resolved means that mining will not be displayed</li>
+ * <li>non empty when mining must be displayed</li>
+ * </ul>
+ * </p>
+ *
* @return the label may be set early in the class lifecycle, or upon completion of the future
* provided by {@link #resolve(ITextViewer, IProgressMonitor)} operation.
*/
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationDrawingStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationDrawingStrategy.java
index ff290e978..3e5f1d327 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationDrawingStrategy.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationDrawingStrategy.java
@@ -141,6 +141,10 @@ class InlinedAnnotationDrawingStrategy implements IDrawingStrategy {
}
gc.drawString(s, charX, charY, true);
// END TO REMOVE
+ } else if (style != null && style.metrics != null && style.metrics.ascent != 0) {
+ // line header annotation had an height, reset it
+ style.metrics= null;
+ textWidget.setStyleRange(style);
}
} else {
if (style != null && style.metrics != null) {
@@ -280,6 +284,10 @@ class InlinedAnnotationDrawingStrategy implements IDrawingStrategy {
}
gc.drawString(s, charX, charY, true);
// END TO REMOVE
+ } else if (style != null && style.metrics != null && style.metrics.width != 0) {
+ // line content annotation had an , reset it
+ style.metrics= null;
+ textWidget.setStyleRange(style);
}
} else {
textWidget.redrawRange(offset, length, true);

Back to the top