SSR: give script a different name from the var name, so it doesn't hide the var

This commit is contained in:
Bas Leijdekkers
2016-03-26 15:37:57 +01:00
parent ea99c348b0
commit f1f01b78ec
2 changed files with 4 additions and 3 deletions
@@ -41,7 +41,7 @@ public class ScriptSupport {
File scriptFile = new File(text);
GroovyShell shell = new GroovyShell();
try {
script = scriptFile.exists() ? shell.parse(scriptFile) : shell.parse(text, name);
script = scriptFile.exists() ? shell.parse(scriptFile) : shell.parse(text, name + "_script.groovy");
} catch (Exception ex) {
Logger.getInstance(getClass().getName()).error(ex);
throw new RuntimeException(ex);
@@ -1186,6 +1186,7 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
findMatchesCount(source2,
"[script(\"" +
"import com.intellij.psi.*\n" +
"__context__ instanceof PsiElement &&" +
"a instanceof PsiClass &&" +
"b instanceof PsiTypeElement &&" +
"c instanceof PsiField &&" +
@@ -1195,8 +1196,8 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
"g instanceof PsiTypeElement &&" +
"h instanceof PsiLocalVariable &&" +
"i instanceof PsiPolyadicExpression &&" +
"j instanceof PsiReferenceExpression" +
"\n\")]" +
"j instanceof PsiReferenceExpression\n" +
"\")]" +
"class '_a {" +
" '_b '_c = '_d;" +
" '_e '_f() {" +