mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use util ThrowableComputable
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user