public void endVisit(RutaElement element, ScriptApply result) {
// TODO create UIMA stuff here not later -> save memory!
if (element instanceof RutaStatement) {
RutaStatement stmt = (RutaStatement) element;
RutaBlock parent = stmt.getParent();
Stack<ScriptApply> stack = applies.get(stmt);
if (stack == null) {
stack = new Stack<ScriptApply>();
applies.put(stmt, stack);
}
// replace
if (!stack.isEmpty()) {
stack.pop();
}
stack.push(result);
applies.put(stmt, stack);
if (parent != null) {
Stack<ScriptApply> parentStack = applies.get(parent);
if (parentStack != null && !parentStack.isEmpty()) {
ScriptApply parentApply = parentStack.peek();
if (parentApply instanceof BlockApply) {
BlockApply blockApply = (BlockApply) parentApply;
if (element instanceof RutaRule && parent.getRule().equals(element)
&& result instanceof RuleApply) {
blockApply.setRuleApply((RuleApply) result);
// } else {
// blockApply.add(result);