[debugger] Refactoring: move utility method to common debugger module

(cherry picked from commit 6f6e50e992fe534f44636136d36c1e53067329b4)


IJ-CR-151042

GitOrigin-RevId: 80c7d32c3b8b297a01e46ed4170a4abe0f2adf0f
This commit is contained in:
Alexey.Merkulov
2024-12-09 18:30:49 +00:00
committed by intellij-monorepo-bot
parent f40e3cec5f
commit 4c5fca5bc6
2 changed files with 20 additions and 16 deletions
@@ -39,7 +39,10 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.function.Function;
public abstract class DebuggerUtils {
@@ -590,6 +593,20 @@ public abstract class DebuggerUtils {
protected record ArrayClass(String className, int dims) {
}
@ApiStatus.Internal
public static @Nullable String tryExtractExceptionMessage(@NotNull ObjectReference exception) {
final ReferenceType type = exception.referenceType();
final Field messageField = type.fieldByName("detailMessage");
if (messageField == null) return null;
final Value message = exception.getValue(messageField);
if (message instanceof StringReference) {
return ((StringReference)message).value();
}
return null;
}
public static DebuggerUtils getInstance() {
return ApplicationManager.getApplication().getService(DebuggerUtils.class);
}