提交 9c892ae5 编写于 作者: D David Barbet

Add telemetry to toggle block comment.

上级 171b67c2
......@@ -9,6 +9,7 @@
using Microsoft.CodeAnalysis.CommentSelection;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Experiments;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
......@@ -30,6 +31,9 @@ internal abstract class AbstractToggleBlockCommentBase :
private static readonly CommentSelectionResult s_emptyCommentSelectionResult =
new CommentSelectionResult(new List<TextChange>(), new List<CommentTrackingSpan>(), Operation.Uncomment);
private const string ContentTypeString = "ContentType";
private const string SubjectBufferLengthString = "subjectBufferLength";
private readonly ITextStructureNavigatorSelectorService _navigatorSelectorService;
internal AbstractToggleBlockCommentBase(
......@@ -83,21 +87,28 @@ public bool ExecuteCommand(ToggleBlockCommentCommandArgs args, CommandExecutionC
internal async override Task<CommentSelectionResult> CollectEditsAsync(Document document, ICommentSelectionService service,
ITextBuffer subjectBuffer, NormalizedSnapshotSpanCollection selectedSpans, ValueTuple command, CancellationToken cancellationToken)
{
var experimentationService = document.Project.Solution.Workspace.Services.GetRequiredService<IExperimentationService>();
if (!experimentationService.IsExperimentEnabled(WellKnownExperimentNames.RoslynToggleBlockComment))
using (Logger.LogBlock(FunctionId.CommandHandler_ToggleBlockComment, KeyValueLogMessage.Create(LogType.UserAction, m =>
{
return s_emptyCommentSelectionResult;
}
m[ContentTypeString] = subjectBuffer.ContentType.DisplayName;
m[SubjectBufferLengthString] = subjectBuffer.CurrentSnapshot.Length;
}), cancellationToken))
{
var experimentationService = document.Project.Solution.Workspace.Services.GetRequiredService<IExperimentationService>();
if (!experimentationService.IsExperimentEnabled(WellKnownExperimentNames.RoslynToggleBlockComment))
{
return s_emptyCommentSelectionResult;
}
var navigator = _navigatorSelectorService.GetTextStructureNavigator(subjectBuffer);
var navigator = _navigatorSelectorService.GetTextStructureNavigator(subjectBuffer);
var commentInfo = await service.GetInfoAsync(document, selectedSpans.First().Span.ToTextSpan(), cancellationToken).ConfigureAwait(false);
if (commentInfo.SupportsBlockComment)
{
return await ToggleBlockCommentsAsync(document, commentInfo, navigator, selectedSpans, cancellationToken).ConfigureAwait(false);
}
var commentInfo = await service.GetInfoAsync(document, selectedSpans.First().Span.ToTextSpan(), cancellationToken).ConfigureAwait(false);
if (commentInfo.SupportsBlockComment)
{
return await ToggleBlockCommentsAsync(document, commentInfo, navigator, selectedSpans, cancellationToken).ConfigureAwait(false);
}
return s_emptyCommentSelectionResult;
return s_emptyCommentSelectionResult;
}
}
private async Task<CommentSelectionResult> ToggleBlockCommentsAsync(Document document, CommentSelectionInfo commentInfo,
......
......@@ -61,6 +61,7 @@ internal enum FunctionId
CommandHandler_GetCommandState,
CommandHandler_ExecuteHandlers,
CommandHandler_FormatCommand,
CommandHandler_ToggleBlockComment,
Workspace_SourceText_GetChangeRanges,
Workspace_Recoverable_RecoverRootAsync,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册