From ece87efccace6368ac24b8dc7320f3656fe6a01e Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Fri, 10 Feb 2017 12:56:10 +0300 Subject: [PATCH] EA-94729 - IE: StackFrameItem.lambda$createFrames$ --- .../intellij/debugger/actions/ThreadDumpAction.java | 12 +++--------- .../debugger/engine/PositionManagerImpl.java | 8 +------- .../com/intellij/debugger/impl/DebuggerUtilsEx.java | 9 +++++++++ .../debugger/memory/utils/StackFrameItem.java | 2 +- .../groovy/debugger/GroovyPositionManager.java | 11 +++-------- 5 files changed, 17 insertions(+), 25 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 0a36f8b13a56..f79e53e9c899 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/ThreadDumpAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -305,14 +305,8 @@ public class ThreadDumpAction extends AnAction implements AnAction.TransparentUp methodName.append(e.getMessage()); } - int lineNumber; - try { - lineNumber = location.lineNumber(); - } - catch (Throwable e) { - lineNumber = -1; - } - return DebuggerBundle.message("export.threads.stackframe.format", methodName.toString(), sourceName, lineNumber); + return DebuggerBundle.message("export.threads.stackframe.format", methodName.toString(), sourceName, + DebuggerUtilsEx.getLineNumber(location, false)); } private static String threadName(ThreadReference threadReference) { diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java index 031d5d25d8a6..e252c891c6fa 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java @@ -141,13 +141,7 @@ public class PositionManagerImpl implements PositionManager, MultiRequestPositio LOG.assertTrue(myDebugProcess != null); - int lineNumber; - try { - lineNumber = location.lineNumber() - 1; - } - catch (InternalError e) { - lineNumber = -1; - } + int lineNumber = DebuggerUtilsEx.getLineNumber(location, true); String qName = location.declaringType().name(); 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 793a6eafc160..e860d28ff362 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java @@ -600,6 +600,15 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils { } } + public static int getLineNumber(Location location, boolean zeroBased) { + try { + return location.lineNumber() - (zeroBased ? 1 : 0); + } + catch (InternalError e) { + return -1; + } + } + public static Value createValue(VirtualMachineProxyImpl vm, String expectedType, double value) { if (PsiType.DOUBLE.getPresentableText().equals(expectedType)) { return vm.mirrorOf(value); diff --git a/java/debugger/impl/src/com/intellij/debugger/memory/utils/StackFrameItem.java b/java/debugger/impl/src/com/intellij/debugger/memory/utils/StackFrameItem.java index 5b4636c62de3..c2cdbc8892be 100644 --- a/java/debugger/impl/src/com/intellij/debugger/memory/utils/StackFrameItem.java +++ b/java/debugger/impl/src/com/intellij/debugger/memory/utils/StackFrameItem.java @@ -66,7 +66,7 @@ public class StackFrameItem { } public int line() { - return myLocation.lineNumber(); + return DebuggerUtilsEx.getLineNumber(myLocation, false); } @NotNull diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyPositionManager.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyPositionManager.java index e65c07045b86..19f2d1a65f55 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyPositionManager.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyPositionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import com.intellij.debugger.engine.CompoundPositionManager; import com.intellij.debugger.engine.DebugProcess; import com.intellij.debugger.engine.DebugProcessImpl; import com.intellij.debugger.engine.jdi.VirtualMachineProxy; +import com.intellij.debugger.impl.DebuggerUtilsEx; import com.intellij.debugger.requests.ClassPrepareRequestor; import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.ApplicationManager; @@ -240,13 +241,7 @@ public class GroovyPositionManager implements PositionManager { private int calcLineIndex(Location location) { LOG.assertTrue(myDebugProcess != null); if (location == null) return -1; - - try { - return location.lineNumber() - 1; - } - catch (InternalError e) { - return -1; - } + return DebuggerUtilsEx.getLineNumber(location, true); } @Nullable