private void FindSourcePoints(IParseNode node, ref int start, ref int end) { foreach (IToken token in node.GetTokens()) { if (start == -1) { start = token.StartPosition.Position; } else { start = Math.Min(start, token.StartPosition.Position); } if (end == -1) { end = token.StopPosition.Position; } else { end = Math.Max(end, token.StopPosition.Position); } } foreach (IParseNode child in node.GetChildNodes()) { this.FindSourcePoints(child, ref start, ref end); } }
public Expression AddDebugInfo(Expression expression, IParseNode node) { if (this.DebugInfoService == null) { return(expression); } var tokens = node.GetTokens().Concat(node.GetChildNodes().SelectMany(n => n.GetTokens())); SourceLocation start = tokens.Min(t => t.StartPosition); SourceLocation end = tokens.Min(t => t.StopPosition); start = this.DebugInfoService.TranslateSourcePosition(start); end = this.DebugInfoService.TranslateSourcePosition(end); DebugInfoExpression debugInfo = Expression.DebugInfo(this.DebugInfoService.SymbolDocument, start.Line, start.Column, end.Line, end.Column); return(Expression.Block(debugInfo, expression)); }
private void VisitNode(IParseNode node, IParseNode parentNode, TreeNode parentTreeItem) { if (node == null) { throw new ArgumentNullException(); } TreeNode treeNode = new TreeNode(node.ToString()); treeNode.Tag = node; treeNode.ToolTipText = treeNode.Text; if (parentTreeItem == null) { this.treeParseNodes.Nodes.Add(treeNode); } else { parentTreeItem.Nodes.Add(treeNode); } if (this.Errors.ContainsKey(node)) { treeNode.ForeColor = Color.Red; TreeNode n = treeNode; while (n != null) { n.Expand(); n = n.Parent; } } foreach (IParseNode child in node.GetChildNodes()) { this.VisitNode(child, node, treeNode); } }
private void VisitNode(IParseNode node, IParseNode parentNode, TreeNode parentTreeItem) { if (node == null) throw new ArgumentNullException(); TreeNode treeNode = new TreeNode(node.ToString()); treeNode.Tag = node; treeNode.ToolTipText = treeNode.Text; if (parentTreeItem == null) this.treeParseNodes.Nodes.Add(treeNode); else parentTreeItem.Nodes.Add(treeNode); if (this.Errors.ContainsKey(node)) { treeNode.ForeColor = Color.Red; TreeNode n = treeNode; while (n != null) { n.Expand(); n = n.Parent; } } foreach (IParseNode child in node.GetChildNodes()) this.VisitNode(child, node, treeNode); }
private void FindSourcePoints(IParseNode node, ref int start, ref int end) { foreach (IToken token in node.GetTokens()) { if (start == -1) start = token.StartPosition.Position; else start = Math.Min(start, token.StartPosition.Position); if (end == -1) end = token.StopPosition.Position; else end = Math.Max(end, token.StopPosition.Position); } foreach (IParseNode child in node.GetChildNodes()) { this.FindSourcePoints(child, ref start, ref end); } }