private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if ( currentEvent instanceof EvalExprEvent ) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if ( currentEvent instanceof EvalTemplateEvent ) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size()-1); } if ( templateEvent!=null ) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
private void updateCurrentST(STViewFrame m) { // System.out.println("updateCurrentST(): currentScope.st="+currentScope.st); // update all views according to currentScope.st updateStack(currentScope, m); // STACK updateAttributes(currentScope, m); // ATTRIBUTES setText(m.bytecode, currentScope.st.impl.disasm()); // BYTECODE DIS. setText(m.template, currentScope.st.impl.template); // TEMPLATE SRC JTreeASTModel astModel = new JTreeASTModel(new CommonTreeAdaptor(), currentScope.st.impl.ast); viewFrame.ast.setModel(astModel); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentScope.st; it's the event that captures ST eval if (currentEvent instanceof EvalExprEvent) { EvalExprEvent exprEvent = (EvalExprEvent)currentEvent; highlight(m.output, exprEvent.outputStartChar, exprEvent.outputStopChar); highlight(m.template, exprEvent.exprStartChar, exprEvent.exprStopChar); } else { EvalTemplateEvent templateEvent; if (currentEvent instanceof EvalTemplateEvent) { templateEvent = (EvalTemplateEvent)currentEvent; } else { List<InterpEvent> events = currentScope.events; templateEvent = (EvalTemplateEvent)events.get(events.size() - 1); } if (templateEvent != null) { highlight(m.output, templateEvent.outputStartChar, templateEvent.outputStopChar); } if ( currentScope.st.isAnonSubtemplate() ) { Interval r = currentScope.st.impl.getTemplateRange(); //System.out.println("currentScope.st src range="+r); //m.template.moveCaretPosition(r.a); highlight(m.template, r.a, r.b); } } }
private TemplateGroupRuleReturnScope buildAstForGroupTemplates(TemplateGroupWrapper group) { TreeAdaptor adaptor = new CommonTreeAdaptor(); Object tree = adaptor.nil(); for (CompiledST template : group.getCompiledTemplates()) { adaptor.addChild(tree, template.ast); } return new TemplateGroupRuleReturnScope(group, (CommonTree)tree); }
public JTreeASTModel(Object root) { this.adaptor = new CommonTreeAdaptor(); this.root = root; }