Example #1
0
        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);
            }
        }
Example #2
0
        private void treeParseNodes_AfterSelect(object sender, TreeViewEventArgs e)
        {
            this.listProperties.Items.Clear();

            if (this.treeParseNodes.SelectedNode == null)
            {
                return;
            }
            IParseNode node = this.treeParseNodes.SelectedNode.Tag as IParseNode;

            if (node == null)
            {
                return;
            }

            this.SelectNodeSource(node);

            Type t = node.GetType();

            PropertyInfo[] infos = t.GetProperties(BindingFlags.FlattenHierarchy | BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public);
            foreach (PropertyInfo info in infos)
            {
                if (!(new string[] { "Tokens", "Comments" }).Contains(info.Name))
                {
                    object value = info.GetValue(node, null);
                    if (value == null)
                    {
                        value = "<null>";
                    }
                    this.listProperties.Items.Add(info.Name).SubItems.Add(String.Format("{0}", value));
                }
            }

            foreach (IToken token in node.GetTokens())
            {
                this.listProperties.Items.Add(String.Format("Token: {0}", token.GetType().Name))
                .SubItems.Add(String.Format("{0}{1} - {2}: {3}",
                                            (token.IsValid ? "" : "ERROR: "), token.StartPosition, token.StopPosition,
                                            this.GetTokenValue(token)));
            }

            if (this.Errors.ContainsKey(node))
            {
                foreach (string err in this.Errors[node])
                {
                    ListViewItem lvi = this.listProperties.Items.Add("Error:");
                    lvi.SubItems.Add(err).ForeColor = Color.Red;
                    lvi.ForeColor = Color.Red;
                }
            }
        }
        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));
        }
Example #4
0
        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);
            }
        }