Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Melcher2018-09-21 08:44:07 +0000
committerTobias Melcher2018-09-21 10:38:28 +0000
commiteef6a58d93958ef187fbaa9bc56cce3ced1a5b80 (patch)
tree8ef446436ec85c6c3f0dc2681d665e57436de0ff
parent6bc4a74a0addb0b95bd497e2e9eee3444519e052 (diff)
downloadeclipse.platform.text-eef6a58d93958ef187fbaa9bc56cce3ced1a5b80.tar.gz
eclipse.platform.text-eef6a58d93958ef187fbaa9bc56cce3ced1a5b80.tar.xz
eclipse.platform.text-eef6a58d93958ef187fbaa9bc56cce3ced1a5b80.zip
Bug 539317: catch exception thrown by codeMiningProvider
Change-Id: I80377ca6706013ebbf4d50da666953ff3f4d2ed1 Signed-off-by: Tobias Melcher <Tobias.Melcher@sap.com>
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningManager.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningManager.java
index bf8039025..28f7d4bb0 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningManager.java
@@ -27,7 +27,11 @@ import java.util.stream.Collectors;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
@@ -143,6 +147,12 @@ public class CodeMiningManager implements Runnable {
}
}
+ private static void logCodeMiningProviderException(Throwable e) {
+ String PLUGIN_ID= "org.eclipse.jface.text"; //$NON-NLS-1$
+ ILog log= Platform.getLog(Platform.getBundle(PLUGIN_ID));
+ log.log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, e.getMessage(), e));
+ }
+
/**
* Return the list of {@link CompletableFuture} which provides the list of {@link ICodeMining}
* for the given <code>viewer</code> by using the given providers.
@@ -156,7 +166,12 @@ public class CodeMiningManager implements Runnable {
private static CompletableFuture<List<? extends ICodeMining>> getCodeMinings(ITextViewer viewer,
List<ICodeMiningProvider> providers, IProgressMonitor monitor) {
List<CompletableFuture<List<? extends ICodeMining>>> com= providers.stream()
- .map(provider -> provider.provideCodeMinings(viewer, monitor)).filter(c -> c != null)
+ .map(provider -> provider.provideCodeMinings(viewer, monitor))
+ .filter(c -> c != null)
+ .map(future -> future.exceptionally(e -> {
+ logCodeMiningProviderException(e);
+ return Collections.emptyList();
+ }))
.collect(Collectors.toList());
return CompletableFuture.allOf(com.toArray(new CompletableFuture[com.size()])).thenApply(
v -> com.stream().map(CompletableFuture::join).flatMap(l -> l.stream()).collect(Collectors.toList()));

Back to the top