use util ThrowableComputable

This commit is contained in:
Egor.Ushakov
2017-03-30 16:09:07 +03:00
parent dee2f63b7f
commit 340911261a
2 changed files with 6 additions and 10 deletions
@@ -226,20 +226,16 @@ public class DebuggerUtilsImpl extends DebuggerUtilsEx{
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 {
public static <T, E extends Exception> T suppressExceptions(ThrowableComputable<T, E> supplier, T defaultValue) throws E {
return suppressExceptions(supplier, defaultValue, true, null);
}
public static <T, E extends Exception> T suppressExceptions(SupplierThrowing<T, E> supplier,
public static <T, E extends Exception> T suppressExceptions(ThrowableComputable<T, E> supplier,
T defaultValue,
boolean ignorePCE,
Class<E> rethrow) throws E {
try {
return supplier.get();
return supplier.compute();
}
catch (ProcessCanceledException e) {
if (!ignorePCE) {
@@ -25,8 +25,8 @@ import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.jdi.VirtualMachineProxy;
import com.intellij.debugger.impl.DebuggerUtilsImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.ThrowableComputable;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ReflectionUtil;
import com.intellij.util.ThreeState;
@@ -357,13 +357,13 @@ public class VirtualMachineProxyImpl implements JdiTimer, VirtualMachineProxy {
return myVirtualMachine.mirrorOf(s);
}
public StringReference mirrorOfStringLiteral(String s, DebuggerUtilsImpl.SupplierThrowing<StringReference, EvaluateException> generator)
public StringReference mirrorOfStringLiteral(String s, ThrowableComputable<StringReference, EvaluateException> generator)
throws EvaluateException {
StringReference reference = myStringLiteralCache.get(s);
if (reference != null && !reference.isCollected()) {
return reference;
}
reference = generator.get();
reference = generator.compute();
myStringLiteralCache.put(s, reference);
return reference;
}