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


C# SyntaxNode.DescendantTrivia方法代码示例

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


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

示例1: GetLastDocumentationCommentExteriorTrivia

 private static SyntaxTrivia GetLastDocumentationCommentExteriorTrivia(SyntaxNode node)
 {
     return node
         .DescendantTrivia(descendIntoTrivia: true)
         .Where(trivia => trivia.IsKind(SyntaxKind.DocumentationCommentExteriorTrivia))
         .LastOrDefault();
 }
开发者ID:BeeFrog,项目名称:StyleCopAnalyzers,代码行数:7,代码来源:SA1609SA1610CodeFixProvider.cs

示例2: RemoveImproperDocumentationTrivia

 private static SyntaxNode RemoveImproperDocumentationTrivia(SyntaxNode node)
 {
     IEnumerable<SyntaxTrivia> commentTrivia = from t in node.DescendantTrivia()
                                               where t.Kind() == SyntaxKind.DocumentationCommentTrivia
                                               select t;
     SyntaxNode newRoot = node.ReplaceTrivia(commentTrivia, (t1, t2) => default(SyntaxTrivia));
     return newRoot;
 }
开发者ID:joymon,项目名称:joyful-visualstudio,代码行数:8,代码来源:VBCommentedCodeRemover.cs

示例3: GetUncomment

		private string GetUncomment(SyntaxNode root)
		{
			var comment = 
				from c in root.DescendantTrivia()
				where c.Kind() == SyntaxKind.MultiLineCommentTrivia
				where c.ToString().StartsWith(uncommentPrefix)
				select GetUncommentBody(c);
			return comment.FirstOrDefault();
		}
开发者ID:kontur-edu,项目名称:uLearn,代码行数:9,代码来源:ExerciseBuilder.cs

示例4: HasImplementation

        private static bool HasImplementation(SyntaxNode syntaxRoot)
        {
            bool hasImplementation = true;
            foreach (var trivia in syntaxRoot.DescendantTrivia())
            {
                if (trivia.IsKind(SyntaxKind.SingleLineCommentTrivia))
                {
                    if (trivia.ToFullString().Contains("TODO: Implement analysis"))
                    {
                        hasImplementation = false;
                    }
                }
            }

            return hasImplementation;
        }
开发者ID:pdelvo,项目名称:StyleCopAnalyzersStatus,代码行数:16,代码来源:SolutionReader.cs

示例5: LocateExcludedSpans

        private static bool LocateExcludedSpans(SyntaxNode root, out ImmutableArray<TextSpan> excludedSpans)
        {
            ImmutableArray<TextSpan>.Builder builder = ImmutableArray.CreateBuilder<TextSpan>();

            // Locate disabled text
            foreach (var trivia in root.DescendantTrivia(descendIntoTrivia: true))
            {
                if (trivia.IsKind(SyntaxKind.DisabledTextTrivia))
                {
                    builder.Add(trivia.Span);
                }
                else if (trivia.IsKind(SyntaxKind.SingleLineCommentTrivia))
                {
                    if (trivia.ToString().StartsWith("////"))
                    {
                        // Exclude comments starting with //// because they could contain commented code which contains
                        // string or character literals, and we don't want to change the contents of those strings.
                        builder.Add(trivia.Span);
                    }
                }
            }

            // Locate string literals
            foreach (var token in root.DescendantTokens(descendIntoTrivia: true))
            {
                switch (token.Kind())
                {
                case SyntaxKind.XmlTextLiteralToken:
                    if (token.Parent.IsKind(SyntaxKind.XmlCDataSection))
                    {
                        builder.Add(token.Span);
                    }

                    break;

                case SyntaxKind.CharacterLiteralToken:
                case SyntaxKind.StringLiteralToken:
                case SyntaxKind.InterpolatedStringTextToken:
                    builder.Add(token.Span);
                    break;

                default:
                    break;
                }
            }

            // Sort the results
            builder.Sort();

            // Combine adjacent and overlapping spans
            ReduceTextSpans(builder);

            excludedSpans = builder.ToImmutable();
            return true;
        }
开发者ID:gkappen,项目名称:StyleCopAnalyzers,代码行数:55,代码来源:SA1027UseTabsCorrectly.cs


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