From 3354d29fe7733d6a3e7df8a7e5851a11271dc956 Mon Sep 17 00:00:00 2001 From: Egor Ushakov Date: Mon, 5 Aug 2019 12:43:10 +0300 Subject: [PATCH] IDEA-219765 'Smart step into' doesn't work in decompiled code GitOrigin-RevId: 3576b887239ebaae1e7bb6a244d9fe2e6de3f144 --- .../actions/JavaSmartStepIntoHandler.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/JavaSmartStepIntoHandler.java b/java/debugger/impl/src/com/intellij/debugger/actions/JavaSmartStepIntoHandler.java index 7485b9bfea33..0ba72812dda8 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/JavaSmartStepIntoHandler.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/JavaSmartStepIntoHandler.java @@ -16,6 +16,7 @@ import com.intellij.debugger.jdi.MethodBytecodeUtil; import com.intellij.debugger.jdi.StackFrameProxyImpl; import com.intellij.debugger.jdi.VirtualMachineProxyImpl; import com.intellij.debugger.settings.DebuggerSettings; +import com.intellij.execution.filters.LineNumbersMapping; import com.intellij.lang.java.JavaLanguage; import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.diagnostic.Logger; @@ -45,6 +46,7 @@ import org.jetbrains.org.objectweb.asm.MethodVisitor; import org.jetbrains.org.objectweb.asm.Opcodes; import java.util.*; +import java.util.stream.IntStream; public class JavaSmartStepIntoHandler extends JvmSmartStepIntoHandler { private static final Logger LOG = Logger.getInstance(JavaSmartStepIntoHandler.class); @@ -348,9 +350,16 @@ public class JavaSmartStepIntoHandler extends JvmSmartStepIntoHandler { sibling.accept(methodCollector); } - Range lines = + Range sourceLines = new Range<>(doc.getLineNumber(textRange.get().getStartOffset()), doc.getLineNumber(textRange.get().getEndOffset())); - targets.forEach(t -> t.setCallingExpressionLines(lines)); + targets.forEach(t -> t.setCallingExpressionLines(sourceLines)); + + Set lines = new HashSet<>(); + IntStream.rangeClosed(sourceLines.getFrom(), sourceLines.getTo()).forEach(lines::add); + LineNumbersMapping mapping = vFile.getUserData(LineNumbersMapping.LINE_NUMBERS_MAPPING_KEY); + if (mapping != null) { + lines = StreamEx.of(lines).map(l -> mapping.sourceToBytecode(l + 1) - 1).filter(l -> l >= 0).toSet(); + } if (!targets.isEmpty()) { StackFrameProxyImpl frameProxy = suspendContext != null ? suspendContext.getFrameProxy() : null; @@ -453,7 +462,7 @@ public class JavaSmartStepIntoHandler extends JvmSmartStepIntoHandler { default void visitCode() {} } - private static void visitLinesInstructions(Location location, boolean full, Range lines, MethodInsnVisitor visitor) { + private static void visitLinesInstructions(Location location, boolean full, Set lines, MethodInsnVisitor visitor) { TObjectIntHashMap myCounter = new TObjectIntHashMap<>(); MethodBytecodeUtil.visit(location.method(), full ? Long.MAX_VALUE : location.codeIndex(), new MethodVisitor(Opcodes.API_VERSION) { @@ -473,7 +482,7 @@ public class JavaSmartStepIntoHandler extends JvmSmartStepIntoHandler { @Override public void visitLineNumber(int line, Label start) { - myLineMatch = lines.isWithin(line - 1); + myLineMatch = lines.contains(line - 1); } @Override