From 0fc9f5ef99196a53b7956d55ef1991f26b3a2902 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Wed, 11 Dec 2013 14:37:20 +0100 Subject: [PATCH] IDEA-117936 IDEA13 fails to stop at breakpoint inside advised method --- .../ui/breakpoints/LineBreakpoint.java | 48 +++---------------- 1 file changed, 7 insertions(+), 41 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java index 19607665ec51..a78cb1315ea7 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/LineBreakpoint.java @@ -31,7 +31,6 @@ import com.intellij.debugger.engine.evaluation.EvaluationContextImpl; import com.intellij.debugger.impl.DebuggerUtilsEx; import com.intellij.debugger.jdi.StackFrameProxyImpl; import com.intellij.icons.AllIcons; -import com.intellij.lang.java.JavaLanguage; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; @@ -73,7 +72,7 @@ public class LineBreakpoint extends BreakpointWithHighlighter { private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.breakpoints.LineBreakpoint"); @Nullable - private OwnerMethod myOwnerMethod; + private String myOwnerMethodName; public static final @NonNls Key CATEGORY = BreakpointCategory.lookup("line_breakpoints"); protected LineBreakpoint(Project project) { @@ -138,7 +137,7 @@ public class LineBreakpoint extends BreakpointWithHighlighter { final RangeHighlighter highlighter = getHighlighter(); offset = highlighter != null? highlighter.getStartOffset() : -1; } - myOwnerMethod = findOwnerMethod(file, offset); + myOwnerMethodName = findOwnerMethod(file, offset); } @Override @@ -211,18 +210,6 @@ public class LineBreakpoint extends BreakpointWithHighlighter { } protected boolean acceptLocation(DebugProcessImpl debugProcess, ReferenceType classType, Location loc) { - final OwnerMethod owner = myOwnerMethod; - if (owner != null && owner.isJavaFile) { - // Additional filtering applicable to java files only. - // Consider: - // proc(()->{System.out.println("Task 1");}, ()->{System.out.println("Task 2");}); - // - // there will be 3 locations for this line: one corresponding to calling method, and two locations from - // the lambda expression implementation methods. - // Without additional filtering, breakpoint request will be set on each location, - // while we do not need to stop in lambda expressions here - return owner.matches(loc); - } return true; } @@ -438,16 +425,16 @@ public class LineBreakpoint extends BreakpointWithHighlighter { } @Nullable - private static OwnerMethod findOwnerMethod(final PsiFile file, final int offset) { + private static String findOwnerMethod(final PsiFile file, final int offset) { if (offset < 0 || file instanceof JspFile) { return null; } if (file instanceof PsiClassOwner) { - return ApplicationManager.getApplication().runReadAction(new Computable() { + return ApplicationManager.getApplication().runReadAction(new Computable() { @Override - public OwnerMethod compute() { + public String compute() { final PsiMethod method = DebuggerUtilsEx.findPsiMethod(file, offset); - return method != null? new OwnerMethod(method, file instanceof PsiJavaFile && JavaLanguage.INSTANCE.equals(file.getLanguage())) : null; + return method != null? method.getName() : null; } }); } @@ -577,28 +564,7 @@ public class LineBreakpoint extends BreakpointWithHighlighter { @Nullable public String getMethodName() { - final OwnerMethod owner = myOwnerMethod; - return owner != null? owner.name : null; + return myOwnerMethodName; } - private static final class OwnerMethod { - @NotNull - final String name; - final boolean isConstructor; - final boolean isJavaFile; - - OwnerMethod(@NotNull PsiMethod method, boolean isJavaFile) { - this(method.getName(), method.isConstructor(), isJavaFile); - } - - OwnerMethod(@NotNull String name, boolean isConstructor, boolean isJavaFile) { - this.name = name; - this.isConstructor = isConstructor; - this.isJavaFile = isJavaFile; - } - - boolean matches(Location loc) { - return isConstructor? loc.method().isConstructor() : name.equals(loc.method().name()); - } - } }