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


C# SyntaxNodeOrToken.ToString方法代码示例

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


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

示例1: SyntaxNodeOrTokenListItem

        public SyntaxNodeOrTokenListItem(SyntaxNodeOrToken syntaxNodeOrToken)
        {
            _lineSpan = syntaxNodeOrToken.GetLocation().GetLineSpan();

            Content = $"{_lineSpan}: {syntaxNodeOrToken.Kind()} {Truncate(syntaxNodeOrToken.ToString())}";
            ToolTip = syntaxNodeOrToken.ToString();
        }
开发者ID:FrankBakkerNl,项目名称:IntelliFind,代码行数:7,代码来源:SyntaxNodeOrTokenListItem.cs

示例2: SourceLabelSymbol

 public SourceLabelSymbol(
     MethodSymbol containingMethod,
     SyntaxNodeOrToken identifierNodeOrToken,
     ConstantValue switchCaseLabelConstant = null)
     : base(identifierNodeOrToken.IsToken ? identifierNodeOrToken.AsToken().ValueText : identifierNodeOrToken.ToString())
 {
     this.containingMethod = containingMethod;
     this.identifierNodeOrToken = identifierNodeOrToken;
     this.switchCaseLabelConstant = switchCaseLabelConstant;
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:10,代码来源:SourceLabelSymbol.cs

示例3: FindMatchingSwitchCaseLabels

        private List<SourceLabelSymbol> FindMatchingSwitchCaseLabels(ConstantValue constantValue, SyntaxNodeOrToken labelSyntax = default(SyntaxNodeOrToken))
        {
            // SwitchLabelsMap: Dictionary for the switch case/default labels.
            // Case labels with a non-null constant value are indexed on their ConstantValue.
            // Invalid case labels with null constant value are indexed on the labelName.

            object key;
            if (constantValue != null)
            {
                key = constantValue;
            }
            else
            {
                key = labelSyntax.ToString();
            }

            return FindMatchingSwitchLabels(key);
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:18,代码来源:SwitchBinder.cs

示例4: 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

示例5: Print

 private static void Print(SyntaxNodeOrToken node)
 {
     if (node.Kind() == SyntaxKind.IdentifierToken && !node.IsMissing)
     {
         Debug.WriteLine(@"N(SyntaxKind.{0}, ""{1}"");", node.Kind(), node.ToString());
     }
     else
     {
         Debug.WriteLine("{0}(SyntaxKind.{1});", node.IsMissing ? "M" : "N", node.Kind());
     }
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:11,代码来源:ParsingTests.cs

示例6: Print

 private static void Print(SyntaxNodeOrToken node)
 {
     switch (node.Kind())
     {
         case SyntaxKind.IdentifierToken:
         case SyntaxKind.NumericLiteralToken:
             if (node.IsMissing)
             {
                 goto default;
             }
             Debug.WriteLine(@"N(SyntaxKind.{0}, ""{1}"");", node.Kind(), node.ToString());
             break;
         default:
             Debug.WriteLine("{0}(SyntaxKind.{1});", node.IsMissing ? "M" : "N", node.Kind());
             break;
     }
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:17,代码来源:ParsingTests.cs


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