コード例 #1
0
        public override void VisitTrivia(SyntaxTrivia trivia)
        {
            if (!_withTrivia)
            {
                return;
            }
            var indent = new string(' ', _indent * 4);

            if (IsInterestingTrivia(trivia.Kind()))
            {
                foreach (var annotation in trivia.GetAnnotations("MDK"))
                {
                    _writer.WriteLine($"{indent}[{annotation.Kind} {annotation.Data}]");
                }
                _writer.WriteLine($"{indent}[>>");
                _writer.WriteLine($"{indent}  {trivia.Kind()}");
                _indent++;
            }

            base.VisitTrivia(trivia);
            if (IsInterestingTrivia(trivia.Kind()))
            {
                _indent--;
                foreach (var annotation in trivia.GetAnnotations("MDK"))
                {
                    _writer.WriteLine($"{indent}[{annotation.Kind} {annotation.Data}]");
                }
                _writer.WriteLine($"{indent}>>]");
            }
        }
コード例 #2
0
ファイル: AnnotationTable.cs プロジェクト: stark-lang/stark
 public IEnumerable <TAnnotation> GetAnnotations(SyntaxTrivia trivia)
 {
     return(GetAnnotations(trivia.GetAnnotations(_annotationKind)));
 }
コード例 #3
0
 /// <summary>
 /// Determines whether the given syntax trivia should be preserved from major changes.
 /// </summary>
 /// <param name="syntaxTrivia"></param>
 /// <returns></returns>
 public static bool ShouldBePreserved(this SyntaxTrivia syntaxTrivia)
 {
     return(syntaxTrivia.GetAnnotations("MDK").Any(a => a.Data.Contains("preserve")));
 }