From c7fcf6beca66191e69841e268c51326cc6fa6cab Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Tue, 3 Dec 2013 20:29:43 +0400 Subject: [PATCH] IDEA-117458 Conditional breakpoints in Grails debugging don't work --- .../debugger/GroovyCodeFragmentFactory.java | 49 ++++++++----------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java index 81d24d35256e..4e8862518519 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java @@ -97,41 +97,32 @@ public class GroovyCodeFragmentFactory extends CodeFragmentFactory { if (!isStatic) { javaText.append("java.lang.Object |thiz0;\n"); - String fileName; + PsiFile containingFile = context.getContainingFile(); - PsiElement originalContext = context.getContainingFile().getContext(); - if (originalContext == null) { - fileName = null; // The class is not reloaded by springloaded if context is in physical file. - } - else { - fileName = originalContext.getContainingFile().getOriginalFile().getName(); + if (containingFile.getContext() != null) { + containingFile = containingFile.getContext().getContainingFile(); } - if (fileName == null) { - // The class could not be reloaded by springloaded - javaText.append("|thiz0 = this;\n"); - } - else { - // Class could be reloaded by springloaded + String fileName = containingFile.getOriginalFile().getName(); - String s = StringUtil.escapeStringCharacters(Pattern.quote(fileName)); - // We believe what class is reloaded if stacktrace matches one of two patterns: - // 1.) [com.package.Foo$$ENLbVXwm.methodName(FileName.groovy:12), com.package.Foo$$DNLbVXwm.methodName(Unknown Source), * - // 2.) [com.package.Foo$$ENLbVXwm.methodName(FileName.groovy:12), * com.springsource.loaded. * - // Pattern below test this. + String s = StringUtil.escapeStringCharacters(Pattern.quote(fileName)); + // We believe what class is reloaded if stacktrace matches one of two patterns: + // 1.) [com.package.Foo$$ENLbVXwm.methodName(FileName.groovy:12), com.package.Foo$$DNLbVXwm.methodName(Unknown Source), * + // 2.) [com.package.Foo$$ENLbVXwm.methodName(FileName.groovy:12), * com.springsource.loaded. * + // Pattern below test this. - //javaText.append("System.out.println(java.util.Arrays.toString(new Exception().getStackTrace()));\n"); - //javaText.append("System.out.println(\"\\\\[([^,()]+\\\\$\\\\$)[A-Za-z0-9]{8}(\\\\.[^,()]+)\\\\(" + s + ":\\\\d+\\\\), (\\\\1[A-Za-z0-9]{8}\\\\2\\\\(Unknown Source\\\\), |.+(?:com|org)\\\\.springsource\\\\.loaded\\\\.).+\")\n"); + //javaText.append("System.out.println(java.util.Arrays.toString(new Exception().getStackTrace()));\n"); + //javaText.append("System.out.println(\"\\\\[([^,()]+\\\\$\\\\$)[A-Za-z0-9]{8}(\\\\.[^,()]+)\\\\(" + s + ":\\\\d+\\\\), (\\\\1[A-Za-z0-9]{8}\\\\2\\\\(Unknown Source\\\\), |.+(?:com|org)\\\\.springsource\\\\.loaded\\\\.).+\")\n"); - javaText.append( - "if (java.util.Arrays.toString(new Exception().getStackTrace()).matches(\"\\\\[([^,()]+\\\\$\\\\$)[A-Za-z0-9]{8}(\\\\.[^,()]+)\\\\(") - .append(s) - .append(":\\\\d+\\\\), (\\\\1[A-Za-z0-9]{8}\\\\2\\\\(Unknown Source\\\\), $OR$.+(?:com$OR$org)\\\\.springsource\\\\.loaded\\\\.).+\")) {\n"); - javaText.append(" |thiz0 = thiz;\n"); - javaText.append(" } else {\n"); - javaText.append(" |thiz0 = this;\n"); - javaText.append(" }\n"); - } + javaText.append( + "if (java.util.Arrays.toString(new Exception().getStackTrace()).matches(\"\\\\[([^,()]+\\\\$\\\\$)[A-Za-z0-9]{8}(\\\\.[^,()]+)\\\\(") + .append(s) + .append( + ":\\\\d+\\\\), (\\\\1[A-Za-z0-9]{8}\\\\2\\\\(Unknown Source\\\\), $OR$.+(?:com$OR$org)\\\\.springsource\\\\.loaded\\\\.).+\")) {\n"); + javaText.append(" |thiz0 = thiz;\n"); + javaText.append(" } else {\n"); + javaText.append(" |thiz0 = this;\n"); + javaText.append(" }\n"); } if (!isStatic) {