[groovy] console: disallow running temporary console file as a script
authorDaniil Ovchinnikov <daniil.ovchinnikov@jetbrains.com>
Thu, 13 Jul 2017 15:06:11 +0000 (18:06 +0300)
committerDaniil Ovchinnikov <daniil.ovchinnikov@jetbrains.com>
Thu, 13 Jul 2017 15:07:56 +0000 (18:07 +0300)
plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunConfigurationProducer.java

index b9cea3cefc7a36ea3bd16eee83017666605a2c36..273513fdf18626b4331b7e317449a97e75e3042d 100644 (file)
@@ -33,6 +33,7 @@ import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.*;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.console.GroovyConsoleStateService;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
 import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
 import org.jetbrains.plugins.groovy.lang.psi.util.GroovyRunnerPsiUtil;
@@ -61,6 +62,10 @@ public class GroovyScriptRunConfigurationProducer extends RuntimeConfigurationPr
     if (!(file instanceof GroovyFile)) {
       return null;
     }
+    final VirtualFile virtualFile = file.getVirtualFile();
+    if (GroovyConsoleStateService.getInstance(element.getProject()).isProjectConsole(virtualFile)) {
+      return null;
+    }
 
     GroovyFile groovyFile = (GroovyFile)file;
     final PsiClass aClass = GroovyRunnerPsiUtil.getRunningClass(location.getPsiElement());