Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2018-03-22 16:09:10 -0400
committerLars Vogel2018-03-22 16:09:10 -0400
commit6227d7fd9e564c12cfc7dc4b1069a1bcf734363f (patch)
treeb3af26365ad53d08638ade353b08e21a5df5d513 /org.eclipse.jface.text/src
parent3743188767f8cef3a9854b23ff7569f335f53f70 (diff)
downloadeclipse.platform.text-6227d7fd9e564c12cfc7dc4b1069a1bcf734363f.tar.gz
eclipse.platform.text-6227d7fd9e564c12cfc7dc4b1069a1bcf734363f.tar.xz
eclipse.platform.text-6227d7fd9e564c12cfc7dc4b1069a1bcf734363f.zip
Revert "Bug 532091 - [CodeMining] Don't draw minings which are cancelled"I20180323-0355I20180322-2000
Diffstat (limited to 'org.eclipse.jface.text/src')
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningLineContentAnnotation.java41
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningLineHeaderAnnotation.java42
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/AbstractCodeMining.java27
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/ICodeMining.java15
4 files changed, 27 insertions, 98 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 9a57f8dbe..98f4315e2 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,21 +73,13 @@ 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.isResolved() && !mining.isResolutionFailed()) {
- 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
@@ -114,31 +106,24 @@ public class CodeMiningLineContentAnnotation extends LineContentAnnotation imple
fBounds.clear();
for (int i= 0; i < minings.size(); i++) {
ICodeMining mining= minings.get(i);
- if (mining.isResolutionFailed()) {
- // mining has error, try to get the last resolved mining.
- if (fResolvedMinings.length > i) {
- mining= fResolvedMinings[i];
- }
- } else if (!mining.isResolved()) {
+ if (!mining.isResolved()) {
// the mining is not resolved.
- if (!redrawn && !mining.isResolutionFailed()) {
+ if (!redrawn) {
// redraw the annotation when mining is resolved.
redraw();
redrawn= true;
}
// try to get the last resolved mining.
- if (fResolvedMinings.length > i) {
+ 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
- if (fResolvedMinings.length > i) {
- fResolvedMinings[i]= mining;
- }
- }
- if (mining == null) {
- // the last mining was not resolved, don't draw it.
- continue;
+ fResolvedMinings[i]= mining;
}
// draw the mining
if (nbDraw > 0) {
@@ -176,7 +161,7 @@ public class CodeMiningLineContentAnnotation extends LineContentAnnotation imple
// redraw codemining annotation is done only if all current minings are resolved.
List<ICodeMining> minings= new ArrayList<>(fMinings);
for (ICodeMining mining : minings) {
- if (!mining.isResolved() && !mining.isResolutionFailed()) {
+ if (!mining.isResolved()) {
// one of mining is not resolved, resolve it and then redraw the annotation.
mining.resolve(getViewer(), fMonitor).thenRunAsync(() -> {
this.redraw();
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 b2540dffe..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
@@ -94,21 +94,13 @@ public class CodeMiningLineHeaderAnnotation extends LineHeaderAnnotation impleme
@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.isResolved() && !mining.isResolutionFailed()) {
- 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
@@ -134,31 +126,21 @@ public class CodeMiningLineHeaderAnnotation extends LineHeaderAnnotation impleme
fBounds.clear();
for (int i= 0; i < minings.size(); i++) {
ICodeMining mining= minings.get(i);
- if (mining.isResolutionFailed()) {
- // mining has error, try to get the last resolved mining.
- if (fResolvedMinings.length > i) {
- mining= fResolvedMinings[i];
- }
- } else if (!mining.isResolved()) {
- // the mining is not resolved.
- if (!redrawn && !mining.isResolutionFailed()) {
- // redraw the annotation when mining is resolved.
+ if (!mining.isResolved()) {
+ if (!redrawn) {
redraw();
redrawn= true;
}
// try to get the last resolved mining.
- if (fResolvedMinings.length > i) {
+ if (fResolvedMinings != null) {
mining= fResolvedMinings[i];
}
+ if (mining == null) {
+ continue;
+ }
} else {
// mining is resolved, update the resolved mining list
- if (fResolvedMinings.length > i) {
- fResolvedMinings[i]= mining;
- }
- }
- if (mining == null) {
- // the last mining was not resolved, don't draw it.
- continue;
+ fResolvedMinings[i]= mining;
}
// draw the mining
if (nbDraw > 0) {
@@ -195,7 +177,7 @@ public class CodeMiningLineHeaderAnnotation extends LineHeaderAnnotation impleme
// redraw codemining annotation is done only if all current minings are resolved.
List<ICodeMining> minings= new ArrayList<>(fMinings);
for (ICodeMining mining : minings) {
- if (!mining.isResolved() && !mining.isResolutionFailed()) {
+ if (!mining.isResolved()) {
// one of mining is not resolved, resolve it and then redraw the annotation.
mining.resolve(getViewer(), fMonitor).thenRunAsync(() -> {
this.redraw();
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/AbstractCodeMining.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/AbstractCodeMining.java
index 767dcfac1..e683c76a9 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/AbstractCodeMining.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/AbstractCodeMining.java
@@ -57,21 +57,11 @@ public abstract class AbstractCodeMining implements ICodeMining {
private final Consumer<MouseEvent> action;
/**
- * The cached resolved state.
- */
- private boolean resolved;
-
- /**
- * The cached resolution failed state.
- */
- private boolean resolutionFailed;
-
- /**
* CodeMining constructor to locate the code mining in a given position.
*
* @param position the position where the mining must be drawn.
* @param provider the owner codemining provider which creates this mining.
- * @param action the action to execute when mining is clicked and null otherwise.
+ * @param action the action to execute when mining is clicked and null otherwise.
*/
protected AbstractCodeMining(Position position, ICodeMiningProvider provider, Consumer<MouseEvent> action) {
this.position= position;
@@ -125,25 +115,12 @@ public abstract class AbstractCodeMining implements ICodeMining {
@Override
public boolean isResolved() {
- if (resolveFuture != null) {
- return resolved= resolveFuture.isDone();
- }
- return resolved;
- }
-
- @Override
- public boolean isResolutionFailed() {
- if (resolveFuture != null) {
- return resolutionFailed= resolveFuture.isCompletedExceptionally();
- }
- return resolutionFailed;
+ return (resolveFuture != null && resolveFuture.isDone());
}
@Override
public void dispose() {
if (resolveFuture != null) {
- resolved= resolveFuture.isDone();
- resolutionFailed= resolveFuture.isCompletedExceptionally();
resolveFuture.cancel(true);
resolveFuture= null;
}
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 9355ea20f..4f8eb6284 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
@@ -10,7 +10,6 @@
*/
package org.eclipse.jface.text.codemining;
-import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
@@ -77,11 +76,6 @@ public interface ICodeMining {
* {{@link #resolve(ITextViewer, IProgressMonitor)}} will be invoked later, triggering the
* future to resolve content.
*
- * This method returns true if content mining is resolved even if there are some error (like
- * {@link CancellationException}). Use {{@link #isResolutionFailed()}} to know if mining was
- * resolved with an error.
- *
- * @see #isResolutionFailed()
* @return whether the content mining is resolved. If it is not resolved,
* {{@link #resolve(ITextViewer, IProgressMonitor)}} will be invoked later, triggering
* the future to resolve content.
@@ -89,15 +83,6 @@ public interface ICodeMining {
boolean isResolved();
/**
- * Returns true if resolved was done with an error (like {@link CancellationException}) and
- * false otherwise.
- *
- * @return true if resolved was done with an error (like {@link CancellationException}) and
- * false otherwise.
- */
- boolean isResolutionFailed();
-
- /**
* Draw the code mining.
*
* @param gc the graphics context

Back to the top