提交 ccc3faa4 编写于 作者: G Gen Lu

Remove debug code

上级 e9e030f1
......@@ -7,6 +7,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Extensions.ContextQuery;
......@@ -27,18 +28,21 @@ protected override bool ShouldProvideCompletion(Document document, SyntaxContext
bool isExpandedCompletion,
CancellationToken cancellationToken)
{
var syntaxFacts = completionContext.Document.GetRequiredLanguageService<ISyntaxFactsService>();
if (TryGetReceiverTypeSymbol(syntaxContext, syntaxFacts, out var receiverTypeSymbol))
using (Logger.LogBlock(FunctionId.Completion_ExtensionMethodImportCompletionProvider_GetCompletionItemsAsync, cancellationToken))
{
var items = await ExtensionMethodImportCompletionHelper.GetUnimportExtensionMethodsAsync(
completionContext.Document,
completionContext.Position,
receiverTypeSymbol,
namespaceInScope,
isExpandedCompletion,
cancellationToken).ConfigureAwait(false);
var syntaxFacts = completionContext.Document.GetRequiredLanguageService<ISyntaxFactsService>();
if (TryGetReceiverTypeSymbol(syntaxContext, syntaxFacts, out var receiverTypeSymbol))
{
var items = await ExtensionMethodImportCompletionHelper.GetUnimportExtensionMethodsAsync(
completionContext.Document,
completionContext.Position,
receiverTypeSymbol,
namespaceInScope,
isExpandedCompletion,
cancellationToken).ConfigureAwait(false);
completionContext.AddItems(items.Select(Convert));
completionContext.AddItems(items.Select(Convert));
}
}
}
......
......@@ -11,7 +11,6 @@
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Experiments;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared;
......@@ -73,13 +72,10 @@ public override async Task ProvideCompletionsAsync(CompletionContext completionC
}
}
using (Logger.LogBlock(FunctionId.Completion_TypeImportCompletionProvider_GetCompletionItemsAsync, cancellationToken))
{
// Find all namespaces in scope at current cursor location,
// which will be used to filter so the provider only returns out-of-scope types.
var namespacesInScope = GetNamespacesInScope(document, syntaxContext, cancellationToken);
await AddCompletionItemsAsync(completionContext, syntaxContext, namespacesInScope, isExpandedCompletion, cancellationToken).ConfigureAwait(false);
}
// Find all namespaces in scope at current cursor location,
// which will be used to filter so the provider only returns out-of-scope types.
var namespacesInScope = GetNamespacesInScope(document, syntaxContext, cancellationToken);
await AddCompletionItemsAsync(completionContext, syntaxContext, namespacesInScope, isExpandedCompletion, cancellationToken).ConfigureAwait(false);
}
private HashSet<string> GetNamespacesInScope(Document document, SyntaxContext syntaxContext, CancellationToken cancellationToken)
......
......@@ -10,6 +10,7 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Completion.Log;
using Microsoft.CodeAnalysis.Completion.Providers.ImportCompletion;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Extensions.ContextQuery;
......@@ -23,7 +24,8 @@ protected override bool ShouldProvideCompletion(Document document, SyntaxContext
protected override async Task AddCompletionItemsAsync(CompletionContext completionContext, SyntaxContext syntaxContext, HashSet<string> namespacesInScope, bool isExpandedCompletion, CancellationToken cancellationToken)
{
using var telemetryCounter = new TelemetryCounter();
using var _ = Logger.LogBlock(FunctionId.Completion_TypeImportCompletionProvider_GetCompletionItemsAsync, cancellationToken);
var telemetryCounter = new TelemetryCounter();
var document = completionContext.Document;
var project = document.Project;
......@@ -77,6 +79,7 @@ protected override async Task AddCompletionItemsAsync(CompletionContext completi
}
telemetryCounter.ReferenceCount = referencedAssemblySymbols.Length;
telemetryCounter.Report();
return;
......@@ -132,7 +135,7 @@ static void AddItems(ImmutableArray<CompletionItem> items, CompletionContext com
}
}
private class TelemetryCounter : IDisposable
private class TelemetryCounter
{
protected int Tick { get; }
public int ItemsCount { get; set; }
......@@ -144,7 +147,7 @@ public TelemetryCounter()
Tick = Environment.TickCount;
}
public void Dispose()
public void Report()
{
var delta = Environment.TickCount - Tick;
CompletionProvidersLogger.LogTypeImportCompletionTicksDataPoint(delta);
......
......@@ -54,12 +54,6 @@ internal static partial class ExtensionMethodImportCompletionHelper
counter.TotalExtensionMethodsProvided = serializableItems.Length;
counter.Report();
// TODO: remove this
Internal.Log.Logger.Log(Internal.Log.FunctionId.Completion_ExtensionMethodImportCompletionProvider_GetCompletionItemsAsync, Internal.Log.KeyValueLogMessage.Create(m =>
{
m["ExtMethodData"] = counter.ToString();
}));
return serializableItems;
}
......@@ -469,24 +463,6 @@ internal sealed class StatisticCounter
public int TotalTypesChecked;
public int TotalExtensionMethodsChecked;
// TODO: remove
public override string ToString()
{
return
$@"
NoFilter : {NoFilter}
TotalTicks: {TotalTicks}
GetFilterTicks : {GetFilterTicks}
GetSymbolTicks : {GetSymbolTicks}
GetSymbolExtraTicks : {GetSymbolExtraTicks}
TotalTypesChecked : {TotalTypesChecked}
TotalExtensionMethodsChecked : {TotalExtensionMethodsChecked}
TotalExtensionMethodsProvided : {TotalExtensionMethodsProvided}
";
}
public void Report()
{
if (NoFilter)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册