Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorangelozerr2018-11-05 04:02:11 -0500
committerMickael Istria2018-11-08 08:14:27 -0500
commit6a5ee7545b2018fece5e4b4ee8b2d1879c7275c5 (patch)
tree89bbe9e62fabe4250735191ee1fd6e938ca157a9
parentedddd72456423aaf82929282163368f04ca808c9 (diff)
downloadeclipse.platform.text-6a5ee7545b2018fece5e4b4ee8b2d1879c7275c5.tar.gz
eclipse.platform.text-6a5ee7545b2018fece5e4b4ee8b2d1879c7275c5.tar.xz
eclipse.platform.text-6a5ee7545b2018fece5e4b4ee8b2d1879c7275c5.zip
Bug 540779 - [code mining] Log error only if needed
Change-Id: I2ba19d304f729bf06bb8adf783b7bf47a2c6bade Signed-off-by: angelozerr <angelo.zerr@gmail.com>
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningManager.java17
1 files changed, 15 insertions, 2 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 91b689b3a..0e9cc07fb 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
@@ -20,10 +20,13 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import java.util.stream.Collectors;
+import org.osgi.framework.Bundle;
+
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.core.runtime.Assert;
@@ -151,9 +154,19 @@ public class CodeMiningManager implements Runnable {
}
private static void logCodeMiningProviderException(Throwable e) {
+ if (e != null && (e instanceof CancellationException || (e.getCause() != null && e.getCause() instanceof CancellationException))) {
+ return;
+ }
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));
+ Bundle plugin= Platform.getBundle(PLUGIN_ID);
+ if (plugin != null) {
+ // In OSGi context, uses Platform Text log
+ ILog log= Platform.getLog(plugin);
+ log.log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, e.getMessage(), e));
+ } else {
+ // In java main context, print stack trace
+ System.err.println("Error while code mining process: " + e.getMessage()); //$NON-NLS-1$
+ }
}
/**

Back to the top