Object (Expression[] params, ExpressionContext context) { Editor editor = context.getEditor(); Language language = editor == null ? null : PsiUtilBase.getLanguageInEditor(editor, context.getProject()); try { Result result = params[0].calculateResult(context); if (result == null) return null; String text = result.toString(); GroovyShell shell = new GroovyShell(language == null ? null : language.getClass().getClassLoader()); File possibleFile = new File(text); Script script = possibleFile.exists() ? shell.parse(possibleFile) : shell.parse(text); Binding binding = new Binding(); for(int i = 1; i < params.length; ++i) { Result paramResult = params[i].calculateResult(context); Object value = null; if (paramResult instanceof ListResult) { value = ContainerUtil.map(((ListResult)paramResult).getComponents(), result1 -> result1.toString()); } else if (paramResult != null) { value = paramResult.toString(); } binding.setVariable("_"+i, value); } binding.setVariable("_editor", editor); script.setBinding(binding); return script.run(); } catch (Exception | Error e) { LOG.info(e); return StringUtil.convertLineSeparators(e.getLocalizedMessage()); } }