提交 2e86c751 编写于 作者: D David Barbet

Rename methods to async.

上级 a2870d50
......@@ -39,7 +39,7 @@ internal class CSharpToggleBlockCommentCommandHandler :
/// Retrieves block comments near the selection in the document.
/// Uses the CSharp syntax tree to find the commented spans.
/// </summary>
protected override async Task<ImmutableArray<TextSpan>> GetBlockCommentsInDocument(Document document, ITextSnapshot snapshot,
protected override async Task<ImmutableArray<TextSpan>> GetBlockCommentsInDocumentAsync(Document document, ITextSnapshot snapshot,
TextSpan linesContainingSelections, CommentSelectionInfo commentInfo, CancellationToken cancellationToken)
{
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
......
......@@ -142,11 +142,7 @@ internal bool ExecuteCommand(ITextView textView, ITextBuffer subjectBuffer, TCom
using (var transaction = new CaretPreservingEditTransaction(title, textView, _undoHistoryRegistry, _editorOperationsFactoryService))
{
var formattedDocument = Format(service, subjectBuffer.CurrentSnapshot, trackingSnapshotSpans, CancellationToken.None);
if (formattedDocument == null)
{
transaction.Cancel();
}
else
if (formattedDocument != null)
{
formattedDocument.Project.Solution.Workspace.ApplyDocumentChanges(formattedDocument, CancellationToken.None);
transaction.Complete();
......
......@@ -53,7 +53,7 @@ internal abstract class AbstractToggleBlockCommentBase :
/// <param name="commentInfo">the comment information for the document.</param>
/// <param name="cancellationToken">a cancellation token.</param>
/// <returns>any commented spans relevant to the selection in the document.</returns>
protected abstract Task<ImmutableArray<TextSpan>> GetBlockCommentsInDocument(Document document, ITextSnapshot snapshot,
protected abstract Task<ImmutableArray<TextSpan>> GetBlockCommentsInDocumentAsync(Document document, ITextSnapshot snapshot,
TextSpan linesContainingSelections, CommentSelectionInfo commentInfo, CancellationToken cancellationToken);
public VSCommanding.CommandState GetCommandState(ToggleBlockCommentCommandArgs args)
......@@ -94,19 +94,19 @@ public bool ExecuteCommand(ToggleBlockCommentCommandArgs args, CommandExecutionC
var commentInfo = await service.GetInfoAsync(document, selectedSpans.First().Span.ToTextSpan(), cancellationToken).ConfigureAwait(false);
if (commentInfo.SupportsBlockComment)
{
return await ToggleBlockComments(document, commentInfo, navigator, selectedSpans, cancellationToken).ConfigureAwait(false);
return await ToggleBlockCommentsAsync(document, commentInfo, navigator, selectedSpans, cancellationToken).ConfigureAwait(false);
}
return s_emptyCommentSelectionResult;
}
private async Task<CommentSelectionResult> ToggleBlockComments(Document document, CommentSelectionInfo commentInfo,
private async Task<CommentSelectionResult> ToggleBlockCommentsAsync(Document document, CommentSelectionInfo commentInfo,
ITextStructureNavigator navigator, NormalizedSnapshotSpanCollection selectedSpans, CancellationToken cancellationToken)
{
var firstLineAroundSelection = selectedSpans.First().Start.GetContainingLine().Start;
var lastLineAroundSelection = selectedSpans.Last().End.GetContainingLine().End;
var linesContainingSelection = TextSpan.FromBounds(firstLineAroundSelection, lastLineAroundSelection);
var blockCommentedSpans = await GetBlockCommentsInDocument(
var blockCommentedSpans = await GetBlockCommentsInDocumentAsync(
document, selectedSpans.First().Snapshot, linesContainingSelection, commentInfo, cancellationToken).ConfigureAwait(false);
var blockCommentSelections = selectedSpans.SelectAsArray(span => new BlockCommentSelectionHelper(blockCommentedSpans, span));
......
......@@ -36,7 +36,7 @@ internal class ToggleBlockCommentCommandHandler : AbstractToggleBlockCommentBase
/// <summary>
/// Gets block comments by parsing the text for comment markers.
/// </summary>
protected override Task<ImmutableArray<TextSpan>> GetBlockCommentsInDocument(Document document, ITextSnapshot snapshot,
protected override Task<ImmutableArray<TextSpan>> GetBlockCommentsInDocumentAsync(Document document, ITextSnapshot snapshot,
TextSpan linesContainingSelections, CommentSelectionInfo commentInfo, CancellationToken cancellationToken)
{
var allText = snapshot.AsText();
......
......@@ -115,7 +115,7 @@ class C
void M()
{
[|var i = 1;
string s = '/*';
string s = '*/';
var k = 3;|]
}
}";
......@@ -126,7 +126,7 @@ class C
void M()
{
[|/*var i = 1;
string s = '/*';
string s = '*/';
var k = 3;*/|]
}
}";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册