Object (MatchResult result, PsiElement context) { try { Map<String, Object> variableMap = new HashMap<>(); myVariableNames.forEach(n -> variableMap.put(n, null)); variableMap.put(ScriptLog.SCRIPT_LOG_VAR_NAME, myScriptLog); if (result != null) { buildVariableMap(result.getRoot(), variableMap); if (context == null) { context = result.getMatch(); } } context = StructuralSearchUtil.getPresentableElement(context); variableMap.put(myName, context); variableMap.put(Configuration.CONTEXT_VAR_NAME, context); myScript.setBinding(new Binding(variableMap)); return myScript.run(); } catch (ThreadDeath | ProcessCanceledException t) { throw t; } catch (Throwable t) { Logger.getInstance(ScriptSupport.class).info("Exception thrown by Structural Search Groovy Script", t); throw new StructuralSearchScriptException(t); } finally { myScript.setBinding(null); } }