Represents either a syntax node or syntax token from TypeScript. NOTE: If you change the properties here, you must change the corresponding properties in the TypeScript tree builder or it won't deserialize correctly.
コード例 #1
0
        internal void UpdateWithSyntaxRoot(SyntaxNodeOrToken root, int position)
        {
            clear();
            TreeViewItem rootItem = null;
            rootItem = new TreeViewItem();
            TreeContainer.Items.Add(rootItem);

            rootItem.DataContext = root;
            generateSyntaxTreeView(root, rootItem);
            selectCorrespondingTreeViewItem(position);
        }
コード例 #2
0
        private void generateSyntaxTreeView(SyntaxNodeOrToken node, TreeViewItem item)
        {
            item.Header = node.Kind + " [" + node.StartPosition + ".." + node.End + ")";

            if (node.IsToken)
            {
                item.Foreground = Brushes.Green;
            }
            else
            {
                item.Foreground = Brushes.Blue;
            }

            foreach (var child in node.Children)
            {
                var childItem = new TreeViewItem();
                childItem.DataContext = child;
                item.Items.Add(childItem);
                generateSyntaxTreeView(child, childItem);
            }
        }