public override async Task ComputeRefactoringsAsync(CodeRefactoringContext context) { SyntaxNode root = await context.Document.GetSyntaxRootAsync(context.CancellationToken); SyntaxTrivia trivia = root.FindTrivia(context.Span.Start, findInsideTrivia: true); if (CommentRefactoring.CanRemove(trivia)) { context.RegisterRefactoring( "Remove comment", cancellationToken => CommentRefactoring.RemoveCommentAsync(context.Document, trivia, cancellationToken)); Debug.Assert(root.IsKind(SyntaxKind.CompilationUnit), root.Kind().ToString()); if (root.IsKind(SyntaxKind.CompilationUnit)) { context.RegisterRefactoring( "Remove all comments", cancellationToken => CommentRefactoring.RemoveAllCommentsAsync(context.Document, cancellationToken)); if (trivia.IsAnyKind(SyntaxKind.SingleLineCommentTrivia, SyntaxKind.MultiLineCommentTrivia)) { context.RegisterRefactoring( "Remove all comments (except xml comments)", cancellationToken => CommentRefactoring.RemoveAllCommentsExceptXmlCommentsAsync(context.Document, cancellationToken)); } } } }