From 4bd01a1dcf5314255ec66d73fd47d23c16dca4f6 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Fri, 2 Oct 2015 13:07:47 +0300 Subject: [PATCH] do not add slot variable names that declared after the current position --- .../debugger/jdi/LocalVariablesUtil.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariablesUtil.java b/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariablesUtil.java index 134408c669c9..40e8e52c9cf5 100644 --- a/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariablesUtil.java +++ b/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariablesUtil.java @@ -309,22 +309,36 @@ public class LocalVariablesUtil { private int myCurrentSlotIndex; private final PsiElement myElement; private final Stack myIndexStack; + private boolean myReached = false; public LocalVariableNameFinder(int startSlot, MultiMap names, PsiElement element) { myNames = names; myCurrentSlotIndex = startSlot; myElement = element; myIndexStack = new Stack(); + } private boolean shouldVisit(PsiElement scope) { - return PsiTreeUtil.isContextAncestor(scope, myElement, false); + return !myReached && PsiTreeUtil.isContextAncestor(scope, myElement, false); + } + + @Override + public void visitElement(PsiElement element) { + if (element == myElement) { + myReached = true; + } + else { + super.visitElement(element); + } } @Override public void visitLocalVariable(PsiLocalVariable variable) { - appendName(variable.getName()); - myCurrentSlotIndex += getTypeSlotSize(variable.getType()); + if (!myReached) { + appendName(variable.getName()); + myCurrentSlotIndex += getTypeSlotSize(variable.getType()); + } } public void visitSynchronizedStatement(PsiSynchronizedStatement statement) {