From 2d486a53ae9fa43355a247a3f0f0525c0d61e5ed Mon Sep 17 00:00:00 2001 From: Egor Ushakov Date: Fri, 1 Mar 2024 11:59:32 +0100 Subject: [PATCH] EA-703308 - IE: ConcreteMethodImpl.codeIndexToLineInfo GitOrigin-RevId: ecfe8d7868a0665e44575e17c82e9f4ff1fb5447 --- .../debugger/actions/ThreadDumpAction.java | 4 ++-- .../debugger/engine/CompoundPositionManager.java | 4 ++-- .../intellij/debugger/impl/DebuggerUtilsEx.java | 10 ++++++++-- .../debugger/ui/breakpoints/MethodBreakpoint.java | 4 ++-- .../ui/impl/watch/StackFrameDescriptorImpl.java | 2 +- .../kotlin/idea/debugger/base/util/safeUtil.kt | 14 ++++---------- .../coroutine/view/SimpleColoredTextIcon.kt | 4 ++-- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.java index 4fbca1e7dd82..306a5bcbadd5 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.debugger.actions; @@ -261,7 +261,7 @@ public final class ThreadDumpAction extends DumbAwareAction { public static @NonNls String renderLocation(final Location location) { return "at " + DebuggerUtilsEx.getLocationMethodQName(location) + - "(" + DebuggerUtilsEx.getSourceName(location, e -> "Unknown Source") + ":" + DebuggerUtilsEx.getLineNumber(location, false) + ")"; + "(" + DebuggerUtilsEx.getSourceName(location, "Unknown Source") + ":" + DebuggerUtilsEx.getLineNumber(location, false) + ")"; } private static String threadName(ThreadReference threadReference) { diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java b/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java index 2333e76edfae..a18ee6ac1706 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/CompoundPositionManager.java @@ -1,4 +1,4 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.debugger.engine; import com.intellij.debugger.MultiRequestPositionManager; @@ -102,7 +102,7 @@ public class CompoundPositionManager implements PositionManagerWithConditionEval } if (checkCacheEntry(res, location)) return res; - String sourceName = DebuggerUtilsEx.getSourceName(location, e -> null); + String sourceName = DebuggerUtilsEx.getSourceName(location, (String)null); FileType fileType = sourceName != null ? FileTypeManager.getInstance().getFileTypeByFileName(sourceName) : null; return iterate(positionManager -> { diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java index 28b0c0f5d0cf..d29493f92d76 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java @@ -682,12 +682,18 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils { } } - public static String getSourceName(Location location, Function defaultName) { + @Nullable + public static String getSourceName(Location location, @Nullable String defaultName) { + return getSourceName(location, e -> defaultName); + } + + @Nullable + public static String getSourceName(Location location, @NotNull Function defaultNameProvider) { try { return location.sourceName(); } catch (InternalError | AbsentInformationException | IllegalArgumentException e) { - return defaultName.apply(e); + return defaultNameProvider.apply(e); } } diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java index 846cf2493904..85518bd238af 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/MethodBreakpoint.java @@ -350,9 +350,9 @@ public class MethodBreakpoint extends BreakpointWithHighlighter defaultFileName); + String locationFileName = DebuggerUtilsEx.getSourceName(location, defaultFileName); int locationLine = location.lineNumber(); return JavaDebuggerBundle.message(entry ? "status.method.entry.breakpoint.reached" : "status.method.exit.breakpoint.reached", method.declaringType().name() + "." + method.name() + "()", diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/StackFrameDescriptorImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/StackFrameDescriptorImpl.java index a1c0ff72d48e..5d0704caafb6 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/StackFrameDescriptorImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/StackFrameDescriptorImpl.java @@ -209,7 +209,7 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac } } if (settings.SHOW_SOURCE_NAME) { - label.append(", ").append(DebuggerUtilsEx.getSourceName(myLocation, e -> "Unknown Source")); + label.append(", ").append(DebuggerUtilsEx.getSourceName(myLocation, "Unknown Source")); } return label.toString(); } diff --git a/plugins/kotlin/jvm-debugger/base/util/src/org/jetbrains/kotlin/idea/debugger/base/util/safeUtil.kt b/plugins/kotlin/jvm-debugger/base/util/src/org/jetbrains/kotlin/idea/debugger/base/util/safeUtil.kt index 6c2d0a6ef698..5a1168238e00 100644 --- a/plugins/kotlin/jvm-debugger/base/util/src/org/jetbrains/kotlin/idea/debugger/base/util/safeUtil.kt +++ b/plugins/kotlin/jvm-debugger/base/util/src/org/jetbrains/kotlin/idea/debugger/base/util/safeUtil.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.debugger.base.util @@ -91,17 +91,13 @@ fun StackFrameProxyImpl.safeThisObject(): ObjectReference? { return wrapEvaluateException { thisObject() } } -fun Location.safeSourceName(): String? { - return wrapIllegalArgumentException { wrapAbsentInformationException { this.sourceName() } } -} +fun Location.safeSourceName(): String? = DebuggerUtilsEx.getSourceName(this, null) fun Location.safeSourceName(stratum: String): String? { return wrapIllegalArgumentException { wrapAbsentInformationException { this.sourceName(stratum) } } } -fun Location.safeLineNumber(): Int { - return wrapIllegalArgumentException { DebuggerUtilsEx.getLineNumber(this, false) } ?: -1 -} +fun Location.safeLineNumber(): Int = DebuggerUtilsEx.getLineNumber(this, false) fun Location.safeLineNumber(stratum: String): Int { return try { @@ -122,9 +118,7 @@ fun Location.safeKotlinPreferredLineNumber(): Int { return safeLineNumber(JAVA_STRATUM) } -fun Location.safeMethod(): Method? { - return DebuggerUtilsEx.getMethod(this) -} +fun Location.safeMethod(): Method? = DebuggerUtilsEx.getMethod(this) fun LocalVariableProxyImpl.safeType(): Type? { return wrapClassNotLoadedException { type } diff --git a/plugins/kotlin/jvm-debugger/coroutines/src/org/jetbrains/kotlin/idea/debugger/coroutine/view/SimpleColoredTextIcon.kt b/plugins/kotlin/jvm-debugger/coroutines/src/org/jetbrains/kotlin/idea/debugger/coroutine/view/SimpleColoredTextIcon.kt index 6b8f561b3b8d..c4a4c989817e 100644 --- a/plugins/kotlin/jvm-debugger/coroutines/src/org/jetbrains/kotlin/idea/debugger/coroutine/view/SimpleColoredTextIcon.kt +++ b/plugins/kotlin/jvm-debugger/coroutines/src/org/jetbrains/kotlin/idea/debugger/coroutine/view/SimpleColoredTextIcon.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.debugger.coroutine.view @@ -181,7 +181,7 @@ class SimpleColoredTextIconPresentationRenderer { log.error("Error while trying to resolve sourceName for location", e, location.toString()) "Unknown Source" } - label.append(sourceName) + label.append(sourceName!!) } return label }