mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SSR: catch runtime exceptions from Groovy shell (IDEA-187725)
This commit is contained in:
+1
-2
@@ -11,7 +11,6 @@ import com.intellij.structuralsearch.StructuralSearchException;
|
||||
import com.intellij.structuralsearch.StructuralSearchUtil;
|
||||
import com.intellij.structuralsearch.plugin.ui.Configuration;
|
||||
import groovy.lang.Binding;
|
||||
import groovy.lang.GroovyRuntimeException;
|
||||
import groovy.lang.GroovyShell;
|
||||
import groovy.lang.Script;
|
||||
import org.codehaus.groovy.control.CompilationFailedException;
|
||||
@@ -105,7 +104,7 @@ public class ScriptSupport {
|
||||
|
||||
final Object o = script.run();
|
||||
return String.valueOf(o);
|
||||
} catch (GroovyRuntimeException ex) {
|
||||
} catch (RuntimeException ex) {
|
||||
throw new StructuralSearchException(SSRBundle.message("groovy.script.error", StringUtil.replace(ex.getMessage(), UUID, "")));
|
||||
} finally {
|
||||
script.setBinding(null);
|
||||
|
||||
+10
@@ -905,6 +905,16 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
|
||||
"import static com.intellij.psi.util.PsiUtil.*\n" +
|
||||
"Symbol instanceof PsiExpression && isAccessedForWriting(Symbol) ||\n" +
|
||||
" Symbol instanceof PsiVariable && Symbol.getInitializer() != null\")]"));
|
||||
|
||||
try {
|
||||
findMatchesCount(in, "[script( com.intellij.psi.PsiField field = __context__; true; )]" +
|
||||
"int i;");
|
||||
fail("Catch RuntimeExceptions from Groovy runtime");
|
||||
} catch (StructuralSearchException ignore) {
|
||||
} catch (Throwable t) {
|
||||
fail("Catch RuntimeExceptions from Groovy runtime");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void testCheckScriptValidation() {
|
||||
|
||||
Reference in New Issue
Block a user