mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-13 15:52:01 +07:00
[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:
committed by
intellij-monorepo-bot
parent
f40e3cec5f
commit
4c5fca5bc6
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.debugger.streams.trace;
|
||||
|
||||
import com.intellij.debugger.engine.DebuggerUtils;
|
||||
import com.intellij.debugger.engine.JavaValue;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
|
||||
import com.intellij.debugger.streams.StreamDebuggerBundle;
|
||||
@@ -15,7 +16,6 @@ import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl;
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.XEvaluationCallbackBase;
|
||||
import com.sun.jdi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Vitaliy.Bibaev
|
||||
@@ -68,7 +68,7 @@ public class EvaluateExpressionTracer implements StreamTracer {
|
||||
}
|
||||
|
||||
if (classType != null) {
|
||||
final String exceptionMessage = tryExtractExceptionMessage((ObjectReference)reference);
|
||||
final String exceptionMessage = DebuggerUtils.tryExtractExceptionMessage((ObjectReference)reference);
|
||||
final String description = "Evaluation failed: " + type.name() + " exception thrown";
|
||||
final String descriptionWithReason = exceptionMessage == null ? description : description + ": " + exceptionMessage;
|
||||
callback.evaluationFailed(streamTraceExpression, descriptionWithReason);
|
||||
@@ -88,17 +88,4 @@ public class EvaluateExpressionTracer implements StreamTracer {
|
||||
}, stackFrame.getSourcePosition());
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user