Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorangelozerr2018-03-20 17:35:21 -0400
committerMickael Istria2018-03-21 05:39:45 -0400
commit9b0af36cdbb65d7e8dff72e7eca340eb4f81f14b (patch)
treef6d42ddd3d0d8313f9396bc7ba320918b6af8e64
parent58b22c85cd2380c638d64ef290f6b7b80785c892 (diff)
downloadeclipse.platform.text-9b0af36cdbb65d7e8dff72e7eca340eb4f81f14b.tar.gz
eclipse.platform.text-9b0af36cdbb65d7e8dff72e7eca340eb4f81f14b.tar.xz
eclipse.platform.text-9b0af36cdbb65d7e8dff72e7eca340eb4f81f14b.zip
Bug 532679 - [CodeMining] should show an empty area before content is
available Change-Id: I525c97be153c8d1f091ce4e9699be0a071ca03f7 Signed-off-by: angelozerr <angelo.zerr@gmail.com>
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningLineHeaderAnnotation.java30
1 files changed, 24 insertions, 6 deletions
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 b0645b8c3..21a67dc6a 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
@@ -12,7 +12,9 @@ package org.eclipse.jface.internal.text.codemining;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
import java.util.function.Consumer;
+import java.util.stream.Stream;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.MouseEvent;
@@ -62,7 +64,7 @@ public class CodeMiningLineHeaderAnnotation extends LineHeaderAnnotation impleme
* Code mining annotation constructor.
*
* @param position the position
- * @param viewer the viewer
+ * @param viewer the viewer
*/
public CodeMiningLineHeaderAnnotation(Position position, ISourceViewer viewer) {
super(position, viewer);
@@ -72,6 +74,25 @@ public class CodeMiningLineHeaderAnnotation extends LineHeaderAnnotation impleme
}
@Override
+ public int getHeight() {
+ return hasAtLeastOneResolvedMining() ? super.getHeight() : 0;
+ }
+
+ /**
+ * Returns <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 and
+ * <code>false</code> otherwise.
+ */
+ private boolean hasAtLeastOneResolvedMining() {
+ if (fResolvedMinings == null || fResolvedMinings.length == 0) {
+ return false;
+ }
+ return Stream.of(fResolvedMinings).anyMatch(Objects::nonNull);
+ }
+
+ @Override
public void update(List<ICodeMining> minings, IProgressMonitor monitor) {
disposeMinings();
fMonitor= monitor;
@@ -106,9 +127,7 @@ public class CodeMiningLineHeaderAnnotation extends LineHeaderAnnotation impleme
for (int i= 0; i < minings.size(); i++) {
ICodeMining mining= minings.get(i);
if (!mining.isResolved()) {
- // the mining is not resolved.
if (!redrawn) {
- // redraw the annotation when mining is resolved.
redraw();
redrawn= true;
}
@@ -117,7 +136,6 @@ public class CodeMiningLineHeaderAnnotation extends LineHeaderAnnotation impleme
mining= fResolvedMinings[i];
}
if (mining == null) {
- // the last mining was not resolved, don't draw it.
continue;
}
} else {
@@ -145,8 +163,8 @@ public class CodeMiningLineHeaderAnnotation extends LineHeaderAnnotation impleme
* Initialize GC with given color and styled text background color and font.
*
* @param textWidget the text widget
- * @param color the color
- * @param gc the gc to initialize
+ * @param color the color
+ * @param gc the gc to initialize
*/
private void initGC(StyledText textWidget, Color color, GC gc) {
gc.setForeground(color);

Back to the top