当前位置: 首页>>代码示例>>C#>>正文


C# SyntaxNodeOrToken.ChildNodesAndTokens方法代码示例

本文整理汇总了C#中SyntaxNodeOrToken.ChildNodesAndTokens方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxNodeOrToken.ChildNodesAndTokens方法的具体用法?C# SyntaxNodeOrToken.ChildNodesAndTokens怎么用?C# SyntaxNodeOrToken.ChildNodesAndTokens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SyntaxNodeOrToken的用法示例。


在下文中一共展示了SyntaxNodeOrToken.ChildNodesAndTokens方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GatherNodes

 private static void GatherNodes(SyntaxNodeOrToken node, HashSet<GreenNode> hashSet)
 {
     hashSet.Add(node.UnderlyingNode);
     foreach (var child in node.ChildNodesAndTokens())
     {
         GatherNodes(child, hashSet);
     }
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:8,代码来源:SyntaxDifferences.cs

示例2: GetRebuiltNodes

        private static void GetRebuiltNodes(SyntaxNodeOrToken newNode, HashSet<GreenNode> hashSet, ArrayBuilder<SyntaxNodeOrToken> nodes)
        {
            if (hashSet.Contains(newNode.UnderlyingNode))
            {
                return;
            }

            nodes.Add(newNode);

            foreach (var child in newNode.ChildNodesAndTokens())
            {
                GetRebuiltNodes(child, hashSet, nodes);
            }
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:14,代码来源:SyntaxDifferences.cs

示例3: CompareTreeEquivalence

        private static void CompareTreeEquivalence(SyntaxNodeOrToken parsedTreeNode, SyntaxNodeOrToken incrementalTreeNode)
        {
            Assert.Equal(parsedTreeNode.Kind(), incrementalTreeNode.Kind());

            Assert.Equal(parsedTreeNode.ChildNodesAndTokens().Count, incrementalTreeNode.ChildNodesAndTokens().Count);

            for (int i = 0; i < parsedTreeNode.ChildNodesAndTokens().Count; i++)
            {
                CompareTreeEquivalence(parsedTreeNode.ChildNodesAndTokens()[i], incrementalTreeNode.ChildNodesAndTokens()[i]);
            }
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:11,代码来源:IncrementalParsingTests.cs

示例4: WalkTreeAndVerify

        private void WalkTreeAndVerify(SyntaxNodeOrToken incNode, SyntaxNodeOrToken fullNode)
        {
            var incChildren = incNode.ChildNodesAndTokens();
            var fullChildren = fullNode.ChildNodesAndTokens();
            Assert.Equal(incChildren.Count, fullChildren.Count);

            for (int i = 0; i < incChildren.Count; i++)
            {
                var incChild = incChildren[i];
                var fullChild = fullChildren[i];

                WalkTreeAndVerify(incChild, fullChild);
            }
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:14,代码来源:IncrementalParsingTests.cs

示例5: AssertNodesAreEquivalent

        private void AssertNodesAreEquivalent(SyntaxNodeOrToken expectedNode, SyntaxNodeOrToken actualNode)
        {
            Assert.Equal(expectedNode.Kind(), actualNode.Kind());
            Assert.Equal(expectedNode.FullSpan, actualNode.FullSpan);
            Assert.Equal(expectedNode.ChildNodesAndTokens().Count, actualNode.ChildNodesAndTokens().Count);

            for (var i = 0; i < expectedNode.ChildNodesAndTokens().Count; i++)
            {
                AssertNodesAreEquivalent(expectedNode.ChildNodesAndTokens()[i],
                    actualNode.ChildNodesAndTokens()[i]);
            }
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:12,代码来源:GrammarAmbiguities.cs

示例6: GetSimilarity

        private int GetSimilarity(SyntaxNodeOrToken node1, SyntaxNodeOrToken node2)
        {
            // count the characters in the common/identical nodes
            int w = 0;
            _nodeSimilaritySet.Clear();
            _tokenTextSimilaritySet.Clear();

            if (node1.IsToken && node2.IsToken)
            {
                var text1 = node1.ToString();
                var text2 = node2.ToString();

                if (text1 == text2)
                {
                    // main text of token is the same
                    w += text1.Length;
                }

                foreach (var tr in node1.GetLeadingTrivia())
                {
                    _nodeSimilaritySet.Add(tr.UnderlyingNode);
                }

                foreach (var tr in node1.GetTrailingTrivia())
                {
                    _nodeSimilaritySet.Add(tr.UnderlyingNode);
                }

                foreach (var tr in node2.GetLeadingTrivia())
                {
                    if (_nodeSimilaritySet.Contains(tr.UnderlyingNode))
                    {
                        w += tr.FullSpan.Length;
                    }
                }

                foreach (var tr in node2.GetTrailingTrivia())
                {
                    if (_nodeSimilaritySet.Contains(tr.UnderlyingNode))
                    {
                        w += tr.FullSpan.Length;
                    }
                }
            }
            else
            {
                foreach (var n1 in node1.ChildNodesAndTokens())
                {
                    _nodeSimilaritySet.Add(n1.UnderlyingNode);

                    if (n1.IsToken)
                    {
                        _tokenTextSimilaritySet.Add(n1.ToString());
                    }
                }

                foreach (var n2 in node2.ChildNodesAndTokens())
                {
                    if (_nodeSimilaritySet.Contains(n2.UnderlyingNode))
                    {
                        w += n2.FullSpan.Length;
                    }
                    else if (n2.IsToken)
                    {
                        var tokenText = n2.ToString();
                        if (_tokenTextSimilaritySet.Contains(tokenText))
                        {
                            w += tokenText.Length;
                        }
                    }
                }
            }

            return w;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:75,代码来源:SyntaxDiffer.cs

示例7: GetDepth

 private static int GetDepth(SyntaxNodeOrToken syntax, int depth = 0)
 {
     if (syntax.IsNode)
     {
         return syntax.ChildNodesAndTokens().Count == 0 ? depth : syntax.ChildNodesAndTokens().Max(x => GetDepth(x, depth + 1));
     }
     return (syntax.AsToken().HasLeadingTrivia || syntax.AsToken().HasTrailingTrivia) ? depth + 1 : depth;
 }
开发者ID:modulexcite,项目名称:LINQPad.CodeAnalysis,代码行数:8,代码来源:SyntaxTreePanel.cs


注:本文中的SyntaxNodeOrToken.ChildNodesAndTokens方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。