From eefaffa8ece550c2b16f754822c968419b61269b Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Thu, 21 Jan 2016 20:22:13 +0300 Subject: [PATCH] IDEA-60932 Support Groovy expressions in debugger expression evaluation --- .../debugger/GroovyCodeFragmentFactory.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 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 c1f27061eca6..0fb1d3308803 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -25,6 +25,7 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; +import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.ClassUtil; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.Function; @@ -331,9 +332,20 @@ public class GroovyCodeFragmentFactory extends CodeFragmentFactory { @Override public boolean isContextAccepted(PsiElement context) { - return context != null && context.getLanguage().equals(GroovyLanguage.INSTANCE); + if (context != null) { + if (context.getLanguage().equals(GroovyLanguage.INSTANCE)) { + return true; + } + Project project = context.getProject(); + if (JavaPsiFacade.getInstance(project) + .findClass("org.codehaus.groovy.control.CompilationUnit", GlobalSearchScope.allScope(project)) != null) { + return true; + } + } + return false; } + @NotNull @Override public LanguageFileType getFileType() { return GroovyFileType.GROOVY_FILE_TYPE;