public TemplateCallHierarchyViewModel(Interpreter interpreter, EvalTemplateEvent @event) { if (interpreter == null) { throw new ArgumentNullException("interpreter"); } if (@event == null) { throw new ArgumentNullException("event"); } this._interpreter = interpreter; this._event = @event; }
private int GetIndexOfChild(EvalTemplateEvent parent, EvalTemplateEvent child) { if (parent == null) { throw new ArgumentNullException("parent"); } if (child == null) { throw new ArgumentNullException("child"); } TemplateCallHierarchyViewModel hierarchy = new TemplateCallHierarchyViewModel(ViewModel.Visualizer.Interpreter, parent); List <TemplateCallHierarchyViewModel> children = hierarchy.Children; return(children.FindIndex(i => i.Event == child)); }
public List <EvalTemplateEvent> GetEvalTemplateEventStack(bool topdown) { List <EvalTemplateEvent> stack = new List <EvalTemplateEvent>(); for (TemplateFrame p = this; p != null; p = p.Parent) { EvalTemplateEvent eval = (EvalTemplateEvent)p.GetDebugState().Events[p.GetDebugState().Events.Count - 1]; stack.Add(eval); } if (topdown) { stack.Reverse(); } return(stack); }
public TemplateFrameAttributeViewModel(EvalTemplateEvent @event, HashSet <string> hiddenAttributes) { if (@event == null) { throw new ArgumentNullException("event"); } this._event = @event; Template template = _event.Frame.Template; IDictionary <string, object> attributes = template.GetAttributes(); if (attributes != null) { List <AttributeViewModel> attributesList = new List <AttributeViewModel>(); foreach (var attribute in attributes) { bool hidden = !hiddenAttributes.Add(attribute.Key); attributesList.Add(new AttributeViewModel(attribute.Key, attribute.Value, hidden, GetAttributeEvents(template, attribute.Key))); } _attributes = attributesList.AsReadOnly(); } }
private void UpdateCurrentTemplate() { var viewModel = ViewModel; if (viewModel == null) { return; } // update all views according to current template UpdateStack(); UpdateAttributes(); viewModel.Bytecode = _currentFrame.Template.impl.Disassemble(); TemplateTextBox.Document = new FlowDocument(new Paragraph(new Run(_currentFrame.Template.impl.Template) { FontFamily = new FontFamily("Consolas") })); viewModel.Ast = _currentFrame.Template.impl.Ast; #region new stuff // update tree view of template hierarchy and select assoc. text substring // compute path from root to currentST, create TreePath for tree widget // List<ST> pathST = currentST.getEnclosingInstanceStack(true); //// System.out.println("path="+pathST); // Object[] path = new Object[pathST.size()]; // int j = 0; // for (ST s : pathST) path[j++] = new JTreeSTModel.Node(s, interp.getDebugState(s)); // m.tree.setSelectionPath(new TreePath(path)); // highlight output text and, if {...} subtemplate, region in ST src // get last event for currentST; it's the event that captures ST eval EvalExprEvent exprEvent = _currentEvent as EvalExprEvent; if (exprEvent != null) { Highlight(OutputTextBox.Document, exprEvent.OutputInterval); Highlight(TemplateTextBox.Document, exprEvent.SourceInterval); } else { EvalTemplateEvent templateEvent = _currentEvent as EvalTemplateEvent; if (templateEvent == null) { List <InterpEvent> events = _currentFrame.GetDebugState().Events; templateEvent = events[events.Count - 1] as EvalTemplateEvent; } //m.output.moveCaretPosition(e.outputStartChar); if (templateEvent != null) { TextPointer position = Highlight(OutputTextBox.Document, templateEvent.OutputInterval); if (position != null) { Rect rect = position.GetCharacterRect(LogicalDirection.Forward); //OutputTextBox.ScrollToVerticalOffset(rect.Top); } } if (_currentFrame.Template.IsAnonymousSubtemplate) { Interval r = _currentFrame.Template.impl.TemplateRange; // System.out.println("currentST src range="+r); //m.template.moveCaretPosition(r.a); //TemplateTextBox.CaretPosition. Highlight(TemplateTextBox.Document, r); } } #endregion #if false // update tree view of template hierarchy and select assoc. text substring viewModel.Ast = currentTemplate.impl.ast; SetSelectionPath(viewModel.TemplateCallHierarchy[0], currentTemplate.GetEnclosingInstanceStack(true)); Interval r = currentTemplate.impl.TemplateRange; if (currentTemplate.EnclosingInstance != null) { int i = GetIndexOfChild(currentTemplate.EnclosingInstance, currentTemplate); if (i == -1) { Highlight(OutputTextBox.Document, null); Highlight(TemplateTextBox.Document, r); } else { InterpEvent e = ViewModel.Visualizer.Interpreter.GetEvents(currentTemplate.EnclosingInstance)[i]; if (e is EvalTemplateEvent) { if (currentTemplate.IsAnonymousSubtemplate) { Highlight(TemplateTextBox.Document, r); } Highlight(OutputTextBox.Document, e.OutputInterval); } } } else { Highlight(OutputTextBox.Document, null); Highlight(TemplateTextBox.Document, r); } #endif }