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}>>]"); } }
public IEnumerable <TAnnotation> GetAnnotations(SyntaxTrivia trivia) { return(GetAnnotations(trivia.GetAnnotations(_annotationKind))); }
/// <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"))); }