EA-703308 - IE: ConcreteMethodImpl.codeIndexToLineInfo

GitOrigin-RevId: ecfe8d7868a0665e44575e17c82e9f4ff1fb5447
This commit is contained in:
Egor Ushakov
2024-03-01 11:59:32 +01:00
committed by intellij-monorepo-bot
parent 2e4f00d222
commit 2d486a53ae
7 changed files with 21 additions and 21 deletions

View File

@@ -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) {

View File

@@ -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 -> {

View File

@@ -682,12 +682,18 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
}
}
public static String getSourceName(Location location, Function<? super Throwable, String> 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<? super Throwable, String> defaultNameProvider) {
try {
return location.sourceName();
}
catch (InternalError | AbsentInformationException | IllegalArgumentException e) {
return defaultName.apply(e);
return defaultNameProvider.apply(e);
}
}

View File

@@ -350,9 +350,9 @@ public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakp
return "";
}
private static @Nls String getEventMessage(boolean entry, Method method, Location location, String defaultFileName) {
private static @Nls String getEventMessage(boolean entry, Method method, Location location, @NotNull String defaultFileName) {
String locationQName = DebuggerUtilsEx.getLocationMethodQName(location);
String locationFileName = DebuggerUtilsEx.getSourceName(location, e -> 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() + "()",

View File

@@ -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();
}

View File

@@ -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 }

View File

@@ -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
}