public void ComputeRefactoringsForTrivia() { SyntaxTrivia trivia = Root.FindTrivia(Span.Start); Debug.WriteLine(trivia.Kind().ToString()); switch (trivia.Kind()) { case SyntaxKind.SingleLineCommentTrivia: { if (IsRefactoringEnabled(RefactoringIdentifiers.UncommentSingleLineComment)) { RegisterRefactoring( "Uncomment", cancellationToken => UncommentSingleLineCommentRefactoring.RefactorAsync(Document, trivia, cancellationToken), RefactoringIdentifiers.UncommentSingleLineComment); } if (IsRefactoringEnabled(RefactoringIdentifiers.ReplaceCommentWithDocumentationComment)) { TextSpan fixableSpan = ReplaceCommentWithDocumentationCommentAnalysis.GetFixableSpan(trivia); if (!fixableSpan.IsEmpty) { RegisterRefactoring( ReplaceCommentWithDocumentationCommentRefactoring.Title, cancellationToken => ReplaceCommentWithDocumentationCommentRefactoring.RefactorAsync(Document, (MemberDeclarationSyntax)trivia.Token.Parent, fixableSpan, cancellationToken), RefactoringIdentifiers.ReplaceCommentWithDocumentationComment); } } break; } case SyntaxKind.MultiLineCommentTrivia: { if (IsRefactoringEnabled(RefactoringIdentifiers.UncommentMultiLineComment)) { UncommentMultiLineCommentRefactoring.ComputeRefactoring(this, trivia); } break; } } if (!trivia.IsPartOfStructuredTrivia()) { CommentTriviaRefactoring.ComputeRefactorings(this, trivia); } }
public void ComputeRefactoringsForTrivia() { SyntaxTrivia trivia = Root.FindTrivia(Span.Start); SyntaxKind kind = trivia.Kind(); if (kind == SyntaxKind.SingleLineCommentTrivia) { if (IsRefactoringEnabled(RefactoringIdentifiers.UncommentSingleLineComment)) { RegisterRefactoring( "Uncomment", cancellationToken => UncommentSingleLineCommentRefactoring.RefactorAsync(Document, trivia, cancellationToken), RefactoringIdentifiers.UncommentSingleLineComment); } if (IsRefactoringEnabled(RefactoringIdentifiers.ConvertCommentToDocumentationComment)) { TextSpan fixableSpan = ConvertCommentToDocumentationCommentAnalysis.GetFixableSpan(trivia); if (!fixableSpan.IsEmpty) { RegisterRefactoring( ConvertCommentToDocumentationCommentRefactoring.Title, cancellationToken => ConvertCommentToDocumentationCommentRefactoring.RefactorAsync(Document, (MemberDeclarationSyntax)trivia.Token.Parent, fixableSpan, cancellationToken), RefactoringIdentifiers.ConvertCommentToDocumentationComment); } } } else if (kind == SyntaxKind.MultiLineCommentTrivia) { if (IsRefactoringEnabled(RefactoringIdentifiers.UncommentMultiLineComment)) { UncommentMultiLineCommentRefactoring.ComputeRefactoring(this, trivia); } } if (!trivia.IsPartOfStructuredTrivia()) { CommentTriviaRefactoring.ComputeRefactorings(this, trivia); } }