提交 0fffd129 编写于 作者: H Heejae Chang

add marker to track perf

上级 e99baa77
...@@ -7,10 +7,9 @@ ...@@ -7,10 +7,9 @@
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeLens; using Microsoft.CodeAnalysis.CodeLens;
using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Remote; using Microsoft.CodeAnalysis.Remote;
using Microsoft.CodeAnalysis.Remote.Diagnostics; using Microsoft.CodeAnalysis.Remote.Diagnostics;
using Microsoft.VisualStudio.LanguageServices.Implementation.Extensions;
using Microsoft.VisualStudio.LanguageServices.Remote;
namespace Microsoft.VisualStudio.LanguageServices.CodeLens namespace Microsoft.VisualStudio.LanguageServices.CodeLens
{ {
...@@ -20,85 +19,97 @@ internal sealed class RemoteCodeLensReferencesService : ICodeLensReferencesServi ...@@ -20,85 +19,97 @@ internal sealed class RemoteCodeLensReferencesService : ICodeLensReferencesServi
public async Task<ReferenceCount> GetReferenceCountAsync(Solution solution, DocumentId documentId, SyntaxNode syntaxNode, int maxSearchResults, public async Task<ReferenceCount> GetReferenceCountAsync(Solution solution, DocumentId documentId, SyntaxNode syntaxNode, int maxSearchResults,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
if (syntaxNode == null) using (Logger.LogBlock(FunctionId.CodeLens_GetReferenceCountAsync, cancellationToken))
{ {
return null; if (syntaxNode == null)
} {
return null;
}
var remoteHostClient = await solution.Workspace.Services.GetService<IRemoteHostClientService>().TryGetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false); var remoteHostClient = await solution.Workspace.Services.GetService<IRemoteHostClientService>().TryGetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false);
if (remoteHostClient == null) if (remoteHostClient == null)
{ {
// remote host is not running. this can happen if remote host is disabled. // remote host is not running. this can happen if remote host is disabled.
return await CodeLensReferencesServiceFactory.Instance.GetReferenceCountAsync(solution, documentId, syntaxNode, maxSearchResults, cancellationToken).ConfigureAwait(false); return await CodeLensReferencesServiceFactory.Instance.GetReferenceCountAsync(solution, documentId, syntaxNode, maxSearchResults, cancellationToken).ConfigureAwait(false);
} }
// TODO: send telemetry on session // TODO: send telemetry on session
return await remoteHostClient.RunCodeAnalysisServiceOnRemoteHostAsync<ReferenceCount>( return await remoteHostClient.RunCodeAnalysisServiceOnRemoteHostAsync<ReferenceCount>(
solution, WellKnownServiceHubServices.CodeAnalysisService_GetReferenceCountAsync, solution, WellKnownServiceHubServices.CodeAnalysisService_GetReferenceCountAsync,
new object[] { new CodeLensArguments(documentId, syntaxNode), maxSearchResults }, cancellationToken).ConfigureAwait(false); new object[] { new CodeLensArguments(documentId, syntaxNode), maxSearchResults }, cancellationToken).ConfigureAwait(false);
}
} }
public async Task<IEnumerable<ReferenceLocationDescriptor>> FindReferenceLocationsAsync(Solution solution, DocumentId documentId, SyntaxNode syntaxNode, public async Task<IEnumerable<ReferenceLocationDescriptor>> FindReferenceLocationsAsync(Solution solution, DocumentId documentId, SyntaxNode syntaxNode,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
if (syntaxNode == null) using (Logger.LogBlock(FunctionId.CodeLens_FindReferenceLocationsAsync, cancellationToken))
{ {
return null; if (syntaxNode == null)
} {
return null;
}
var remoteHostClient = await solution.Workspace.Services.GetService<IRemoteHostClientService>().TryGetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false); var remoteHostClient = await solution.Workspace.Services.GetService<IRemoteHostClientService>().TryGetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false);
if (remoteHostClient == null) if (remoteHostClient == null)
{ {
// remote host is not running. this can happen if remote host is disabled. // remote host is not running. this can happen if remote host is disabled.
return await CodeLensReferencesServiceFactory.Instance.FindReferenceLocationsAsync(solution, documentId, syntaxNode, cancellationToken).ConfigureAwait(false); return await CodeLensReferencesServiceFactory.Instance.FindReferenceLocationsAsync(solution, documentId, syntaxNode, cancellationToken).ConfigureAwait(false);
} }
// TODO: send telemetry on session // TODO: send telemetry on session
return await remoteHostClient.RunCodeAnalysisServiceOnRemoteHostAsync<IEnumerable<ReferenceLocationDescriptor>>( return await remoteHostClient.RunCodeAnalysisServiceOnRemoteHostAsync<IEnumerable<ReferenceLocationDescriptor>>(
solution, WellKnownServiceHubServices.CodeAnalysisService_FindReferenceLocationsAsync, solution, WellKnownServiceHubServices.CodeAnalysisService_FindReferenceLocationsAsync,
new CodeLensArguments(documentId, syntaxNode), cancellationToken).ConfigureAwait(false); new CodeLensArguments(documentId, syntaxNode), cancellationToken).ConfigureAwait(false);
}
} }
public async Task<IEnumerable<ReferenceMethodDescriptor>> FindReferenceMethodsAsync(Solution solution, DocumentId documentId, SyntaxNode syntaxNode, public async Task<IEnumerable<ReferenceMethodDescriptor>> FindReferenceMethodsAsync(Solution solution, DocumentId documentId, SyntaxNode syntaxNode,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
if (syntaxNode == null) using (Logger.LogBlock(FunctionId.CodeLens_FindReferenceMethodsAsync, cancellationToken))
{ {
return null; if (syntaxNode == null)
} {
return null;
}
var remoteHostClient = await solution.Workspace.Services.GetService<IRemoteHostClientService>().TryGetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false); var remoteHostClient = await solution.Workspace.Services.GetService<IRemoteHostClientService>().TryGetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false);
if (remoteHostClient == null) if (remoteHostClient == null)
{ {
// remote host is not running. this can happen if remote host is disabled. // remote host is not running. this can happen if remote host is disabled.
return await CodeLensReferencesServiceFactory.Instance.FindReferenceMethodsAsync(solution, documentId, syntaxNode, cancellationToken).ConfigureAwait(false); return await CodeLensReferencesServiceFactory.Instance.FindReferenceMethodsAsync(solution, documentId, syntaxNode, cancellationToken).ConfigureAwait(false);
} }
// TODO: send telemetry on session // TODO: send telemetry on session
return await remoteHostClient.RunCodeAnalysisServiceOnRemoteHostAsync<IEnumerable<ReferenceMethodDescriptor>>( return await remoteHostClient.RunCodeAnalysisServiceOnRemoteHostAsync<IEnumerable<ReferenceMethodDescriptor>>(
solution, WellKnownServiceHubServices.CodeAnalysisService_FindReferenceMethodsAsync, solution, WellKnownServiceHubServices.CodeAnalysisService_FindReferenceMethodsAsync,
new CodeLensArguments(documentId, syntaxNode), cancellationToken).ConfigureAwait(false); new CodeLensArguments(documentId, syntaxNode), cancellationToken).ConfigureAwait(false);
}
} }
public async Task<string> GetFullyQualifiedName(Solution solution, DocumentId documentId, SyntaxNode syntaxNode, public async Task<string> GetFullyQualifiedName(Solution solution, DocumentId documentId, SyntaxNode syntaxNode,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
if (syntaxNode == null) using (Logger.LogBlock(FunctionId.CodeLens_GetFullyQualifiedName, cancellationToken))
{ {
return null; if (syntaxNode == null)
} {
return null;
}
var remoteHostClient = await solution.Workspace.Services.GetService<IRemoteHostClientService>().TryGetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false); var remoteHostClient = await solution.Workspace.Services.GetService<IRemoteHostClientService>().TryGetRemoteHostClientAsync(cancellationToken).ConfigureAwait(false);
if (remoteHostClient == null) if (remoteHostClient == null)
{ {
// remote host is not running. this can happen if remote host is disabled. // remote host is not running. this can happen if remote host is disabled.
return await CodeLensReferencesServiceFactory.Instance.GetFullyQualifiedName(solution, documentId, syntaxNode, cancellationToken).ConfigureAwait(false); return await CodeLensReferencesServiceFactory.Instance.GetFullyQualifiedName(solution, documentId, syntaxNode, cancellationToken).ConfigureAwait(false);
} }
// TODO: send telemetry on session // TODO: send telemetry on session
return await remoteHostClient.RunCodeAnalysisServiceOnRemoteHostAsync<string>( return await remoteHostClient.RunCodeAnalysisServiceOnRemoteHostAsync<string>(
solution, WellKnownServiceHubServices.CodeAnalysisService_GetFullyQualifiedName, solution, WellKnownServiceHubServices.CodeAnalysisService_GetFullyQualifiedName,
new CodeLensArguments(documentId, syntaxNode), cancellationToken).ConfigureAwait(false); new CodeLensArguments(documentId, syntaxNode), cancellationToken).ConfigureAwait(false);
}
} }
} }
} }
...@@ -366,5 +366,9 @@ internal enum FunctionId ...@@ -366,5 +366,9 @@ internal enum FunctionId
RemoteHost_Connect, RemoteHost_Connect,
RemoteHost_Disconnect, RemoteHost_Disconnect,
CodeAnalysisService_GetTodoCommentsAsync, CodeAnalysisService_GetTodoCommentsAsync,
CodeLens_GetReferenceCountAsync,
CodeLens_FindReferenceLocationsAsync,
CodeLens_FindReferenceMethodsAsync,
CodeLens_GetFullyQualifiedName,
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册