mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
suppress exceptions from providers
This commit is contained in:
@@ -21,12 +21,12 @@ import com.intellij.debugger.PositionManager;
|
||||
import com.intellij.debugger.SourcePosition;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContext;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsImpl;
|
||||
import com.intellij.debugger.jdi.StackFrameProxyImpl;
|
||||
import com.intellij.debugger.requests.ClassPrepareRequestor;
|
||||
import com.intellij.execution.filters.LineNumbersMapping;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.ThreeState;
|
||||
@@ -69,19 +69,17 @@ public class CompoundPositionManager extends PositionManagerEx implements MultiR
|
||||
|
||||
private <T> T iterate(Processor<T> processor, T defaultValue, SourcePosition position) {
|
||||
for (PositionManager positionManager : myPositionManagers) {
|
||||
try {
|
||||
if (position != null) {
|
||||
Set<? extends FileType> types = positionManager.getAcceptedFileTypes();
|
||||
if (types != null && !types.contains(position.getFile().getFileType())) {
|
||||
continue;
|
||||
}
|
||||
if (position != null) {
|
||||
Set<? extends FileType> types = positionManager.getAcceptedFileTypes();
|
||||
if (types != null && !types.contains(position.getFile().getFileType())) {
|
||||
continue;
|
||||
}
|
||||
return processor.process(positionManager);
|
||||
}
|
||||
catch (NoDataException | ProcessCanceledException ignored) {}
|
||||
catch (VMDisconnectedException | ObjectCollectedException e) {throw e;}
|
||||
catch (InternalException e) {LOG.info(e);}
|
||||
catch (Exception | AssertionError e) {LOG.error(e);}
|
||||
try {
|
||||
return DebuggerUtilsImpl.suppressExceptions(() -> processor.process(positionManager), defaultValue, NoDataException.class);
|
||||
}
|
||||
catch (NoDataException ignored) {
|
||||
}
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@@ -222,7 +222,9 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
}
|
||||
|
||||
return myNodeRenderersMap.computeIfAbsent(type, t ->
|
||||
myRenderers.stream().filter(r -> r.isApplicable(type)).findFirst().orElseGet(() -> getDefaultRenderer(type)));
|
||||
myRenderers.stream().
|
||||
filter(r -> DebuggerUtilsImpl.suppressExceptions(() -> r.isApplicable(type), false)).
|
||||
findFirst().orElseGet(() -> getDefaultRenderer(type)));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.intellij.ide.util.TreeClassChooser;
|
||||
import com.intellij.ide.util.TreeClassChooserFactory;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.JDOMExternalizerUtil;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -45,6 +46,9 @@ import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import com.intellij.xdebugger.XExpression;
|
||||
import com.intellij.xdebugger.impl.breakpoints.XExpressionState;
|
||||
import com.sun.jdi.InternalException;
|
||||
import com.sun.jdi.ObjectCollectedException;
|
||||
import com.sun.jdi.VMDisconnectedException;
|
||||
import com.sun.jdi.Value;
|
||||
import com.sun.jdi.connect.spi.TransportService;
|
||||
import org.jdom.Element;
|
||||
@@ -212,4 +216,33 @@ public class DebuggerUtilsImpl extends DebuggerUtilsEx{
|
||||
public static boolean isRemote(DebugProcess debugProcess) {
|
||||
return Boolean.TRUE.equals(debugProcess.getUserData(BatchEvaluator.REMOTE_SESSION_KEY));
|
||||
}
|
||||
|
||||
public interface SupplierThrowing<T, E extends Throwable> {
|
||||
T get() throws E;
|
||||
}
|
||||
|
||||
public static <T, E extends Exception> T suppressExceptions(SupplierThrowing<T, E> supplier, T defaultValue) throws E {
|
||||
return suppressExceptions(supplier, defaultValue, null);
|
||||
}
|
||||
|
||||
public static <T, E extends Exception> T suppressExceptions(SupplierThrowing<T, E> supplier,
|
||||
T defaultValue,
|
||||
Class<E> rethrow) throws E {
|
||||
try {
|
||||
return supplier.get();
|
||||
}
|
||||
catch (ProcessCanceledException ignored) {}
|
||||
catch (VMDisconnectedException | ObjectCollectedException e) {throw e;}
|
||||
catch (InternalException e) {LOG.info(e);}
|
||||
catch (Exception | AssertionError e) {
|
||||
if (rethrow != null && rethrow.isInstance(e)) {
|
||||
throw e;
|
||||
}
|
||||
else {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user