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


C# SyntaxTrivia.CSharpKind方法代码示例

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


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

示例1: OnTouchedNoisyCharacter

            private bool OnTouchedNoisyCharacter(SyntaxTrivia trivia)
            {
                if (trivia.IsElastic() ||
                    trivia.CSharpKind() == SyntaxKind.WhitespaceTrivia ||
                    trivia.CSharpKind() == SyntaxKind.EndOfLineTrivia)
                {
                    return false;
                }

                this.touchedNoisyCharacterOnCurrentLine = true;
                this.hasTrailingSpace = false;

                return false;
            }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:14,代码来源:TriviaDataFactory.CodeShapeAnalyzer.cs

示例2: ClassifyPreprocessorTrivia

 private void ClassifyPreprocessorTrivia(SyntaxTrivia trivia, bool allowComments)
 {
     if (allowComments && trivia.CSharpKind() == SyntaxKind.SingleLineCommentTrivia)
     {
         AddClassification(trivia, ClassificationTypeNames.Comment);
     }
     else
     {
         AddClassification(trivia, ClassificationTypeNames.PreprocessorText);
     }
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:11,代码来源:Worker_Preprocesser.cs

示例3: OnRegion

            private bool OnRegion(SyntaxTrivia trivia, int currentIndex)
            {
                if (trivia.CSharpKind() != SyntaxKind.RegionDirectiveTrivia &&
                    trivia.CSharpKind() != SyntaxKind.EndRegionDirectiveTrivia)
                {
                    return false;
                }

                if (!this.UseIndentation)
                {
                    return true;
                }

                if (indentation != this.context.GetBaseIndentation(trivia.SpanStart))
                {
                    return true;
                }

                ResetStateAfterNewLine(currentIndex);
                return false;
            }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:21,代码来源:TriviaDataFactory.CodeShapeAnalyzer.cs

示例4: OnPreprocessor

            private bool OnPreprocessor(SyntaxTrivia trivia, int currentIndex)
            {
                if (!SyntaxFacts.IsPreprocessorDirective(trivia.CSharpKind()))
                {
                    return false;
                }

                if (!this.UseIndentation)
                {
                    return true;
                }

                // preprocessor must be at from column 0
                if (this.indentation != 0)
                {
                    return true;
                }

                ResetStateAfterNewLine(currentIndex);
                return false;
            }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:21,代码来源:TriviaDataFactory.CodeShapeAnalyzer.cs

示例5: OnEndOfLine

            private bool OnEndOfLine(SyntaxTrivia trivia, int currentIndex)
            {
                if (trivia.CSharpKind() != SyntaxKind.EndOfLineTrivia)
                {
                    return false;
                }

                // end of line trivia right after whitespace trivia
                if (this.hasTrailingSpace)
                {
                    // has trailing whitespace
                    return true;
                }

                // empty line with spaces. remove it.
                if (this.indentation > 0 && !this.touchedNoisyCharacterOnCurrentLine)
                {
                    return true;
                }

                ResetStateAfterNewLine(currentIndex);
                return false;
            }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:23,代码来源:TriviaDataFactory.CodeShapeAnalyzer.cs

示例6: OnSkippedTokensOrText

            private bool OnSkippedTokensOrText(SyntaxTrivia trivia)
            {
                if (trivia.CSharpKind() != SyntaxKind.SkippedTokensTrivia &&
                    trivia.CSharpKind() != SyntaxKind.PreprocessingMessageTrivia)
                {
                    return false;
                }

                return Contract.FailWithReturn<bool>("This can't happen");
            }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:10,代码来源:TriviaDataFactory.CodeShapeAnalyzer.cs

示例7: VisitTrivia

            public override void VisitTrivia(SyntaxTrivia trivia)
            {
                if (trivia.HasStructure)
                    Visit(trivia.GetStructure());

                switch (trivia.CSharpKind())
                {
                    case SyntaxKind.MultiLineCommentTrivia:
                    case SyntaxKind.SingleLineCommentTrivia:
                    case SyntaxKind.SingleLineDocumentationCommentTrivia:
                    case SyntaxKind.MultiLineDocumentationCommentTrivia:
                    case SyntaxKind.DocumentationCommentExteriorTrivia:
                        Mark(trivia, "comment"); break;

                    case SyntaxKind.EndOfLineTrivia:
                    case SyntaxKind.WhitespaceTrivia:
                        Mark(trivia, "whitespace"); break;

                    case SyntaxKind.RegionDirectiveTrivia:
                        Mark(trivia, "begin-region"); break;

                    case SyntaxKind.EndRegionDirectiveTrivia:
                        Mark(trivia, "end-region"); break;

                    case SyntaxKind.DisabledTextTrivia:
                        Mark(trivia, "disabled-text"); break;
                }
            }
开发者ID:Runt-Editor,项目名称:Runt,代码行数:28,代码来源:Highlighter.cs

示例8: OnWhitespace

            private bool OnWhitespace(SyntaxTrivia trivia)
            {
                if (trivia.CSharpKind() != SyntaxKind.WhitespaceTrivia)
                {
                    return false;
                }

                // there was noisy char after end of line trivia
                if (!this.UseIndentation || this.touchedNoisyCharacterOnCurrentLine)
                {
                    this.hasTrailingSpace = true;
                    return false;
                }

                // right after end of line trivia. calculate indentation for current line
                Debug.Assert(trivia.ToString() == trivia.ToFullString());
                var text = trivia.ToString();

                // if text contains tab, we will give up perf optimization and use more expensive one to see whether we need to replace this trivia
                if (text.IndexOf('\t') >= 0)
                {
                    return true;
                }

                this.indentation += text.ConvertTabToSpace(this.optionSet.GetOption(FormattingOptions.TabSize, LanguageNames.CSharp), this.indentation, text.Length);

                return false;
            }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:28,代码来源:TriviaDataFactory.CodeShapeAnalyzer.cs

示例9: VisitTrivia

        public override void VisitTrivia(SyntaxTrivia trivia)
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (IsSyntacticallyFilteredOut(trivia.FullSpan))
            {
                return;
            }

            if (!IsValidLocation && SyntaxFacts.IsDocumentationCommentTrivia(trivia.CSharpKind()))
            {
                int start = trivia.Position; // FullSpan start to include /** or ///
                const int length = 1; //Match dev11: span is just one character
                diagnostics.Add(ErrorCode.WRN_UnprocessedXMLComment, new SourceLocation(trivia.SyntaxTree, new TextSpan(start, length)));
            }
            base.VisitTrivia(trivia);
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:17,代码来源:UnprocessedDocumentationCommentFinder.cs

示例10: IsWhitespace

 private bool IsWhitespace(SyntaxTrivia trivia)
 {
     return trivia.CSharpKind() == SyntaxKind.WhitespaceTrivia
         || trivia.CSharpKind() == SyntaxKind.EndOfLineTrivia;
 }
开发者ID:riversky,项目名称:roslyn,代码行数:5,代码来源:ElasticTriviaFormattingRule.cs

示例11: ClassifyTrivia

 private void ClassifyTrivia(SyntaxTrivia trivia)
 {
     if (trivia.CSharpKind() == SyntaxKind.SingleLineCommentTrivia || trivia.CSharpKind() == SyntaxKind.MultiLineCommentTrivia)
     {
         AddClassification(trivia, ClassificationTypeNames.Comment);
     }
     else if (trivia.CSharpKind() == SyntaxKind.DisabledTextTrivia)
     {
         AddClassification(trivia, ClassificationTypeNames.ExcludedCode);
     }
     else if (trivia.CSharpKind() == SyntaxKind.SkippedTokensTrivia)
     {
         ClassifySkippedTokens((SkippedTokensTriviaSyntax)trivia.GetStructure());
     }
     else if (trivia.IsDocComment())
     {
         ClassifyDocumentationComment((DocumentationCommentTriviaSyntax)trivia.GetStructure());
     }
     else if (trivia.CSharpKind() == SyntaxKind.DocumentationCommentExteriorTrivia)
     {
         AddClassification(trivia, ClassificationTypeNames.XmlDocCommentDelimiter);
     }
     else if (SyntaxFacts.IsPreprocessorDirective(trivia.CSharpKind()))
     {
         ClassifyPreprocessorDirective((DirectiveTriviaSyntax)trivia.GetStructure());
     }
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:27,代码来源:Worker.cs

示例12: VisitTrivia

            public override void VisitTrivia(SyntaxTrivia trivia)
            {
                bool isDocComment = SyntaxFacts.IsDocumentationCommentTrivia(trivia.CSharpKind());
                if (isDocComment ||
                    trivia.CSharpKind() == SyntaxKind.SingleLineCommentTrivia ||
                    trivia.CSharpKind() == SyntaxKind.MultiLineCommentTrivia)
                {
                    Results.AppendLine();
                    Results.Append(trivia.ToFullString().Trim());
                    Results.Append(" (Parent Token: ");
                    Results.Append(trivia.Token.CSharpKind());
                    Results.Append(")");
                    if (isDocComment)
                    {
                        // Trivia for xml documentation comments have addditional 'structure'
                        // available under a child DocumentationCommentSyntax.
                        Assert.IsTrue(trivia.HasStructure);
                        var documentationComment =
                            (DocumentationCommentTriviaSyntax)trivia.GetStructure();
                        Assert.IsTrue(documentationComment.ParentTrivia == trivia);
                        Results.Append(" (Structured)");
                    }
                }

                base.VisitTrivia(trivia);
            }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:26,代码来源:FAQ.cs

示例13: VisitTrivia

		public override SyntaxTrivia VisitTrivia(SyntaxTrivia trivia)
		{
			var comment = trivia.ToString();
			if (trivia.CSharpKind() == SyntaxKind.MultiLineCommentTrivia)
			{
				if (!comment.StartsWith("/*uncomment"))
				{
					bool shouldCreateTextBlock = trivia.GetParents().Count(p => IsNestingParent(p, trivia)) <= 1;
					if (shouldCreateTextBlock)
						Blocks.Add(ExtractMarkDownFromComment(trivia));
				}
			}
			else if (trivia.CSharpKind() == SyntaxKind.SingleLineCommentTrivia)
			{
				if (comment.StartsWith("//#"))
				{
					var parts = comment.Split(new[] { ' ' }, 2);
					if (parts[0] == "//#video") EmbedVideo(parts[1]);
                    if (parts[0] == "//#include") EmbedCode(parts[1]);
                    if (parts[0] == "//#para") EmbedPara(parts[1]);
                    if (parts[0] == "//#gallery") EmbedGallery(parts[1]);
				}
			}
			return base.VisitTrivia(trivia);
		}
开发者ID:hexandr,项目名称:uLearn,代码行数:25,代码来源:BlocksBuilder.cs

示例14: AnalyzeWhitespacesInTrivia

            private static void AnalyzeWhitespacesInTrivia(SyntaxTrivia trivia, ref AnalysisResult result)
            {
                // trivia already has text. getting text should be noop
                Debug.Assert(trivia.CSharpKind() == SyntaxKind.WhitespaceTrivia);
                Debug.Assert(trivia.Width() == trivia.FullWidth());

                int space = 0;
                int tab = 0;
                int unknownWhitespace = 0;

                var text = trivia.ToString();
                for (int i = 0; i < trivia.Width(); i++)
                {
                    if (text[i] == ' ')
                    {
                        space++;
                    }
                    else if (text[i] == '\t')
                    {
                        if (result.Space > 0)
                        {
                            result.HasTabAfterSpace = true;
                        }

                        tab++;
                    }
                    else
                    {
                        unknownWhitespace++;
                    }
                }

                // set result
                result.Space += space;
                result.Tab += tab;
                result.HasUnknownWhitespace |= unknownWhitespace > 0;
                result.TreatAsElastic |= trivia.IsElastic();
            }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:38,代码来源:TriviaDataFactory.Analyzer.cs


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