From 3c6b60ea3d8972342a536b27cddf7fb5161f38dd Mon Sep 17 00:00:00 2001 From: Allison Chou Date: Thu, 14 May 2020 13:27:18 -0700 Subject: [PATCH] Fix for assertion error --- .../AbstractFindUsagesService_FindReferences.cs | 14 +++++++++++++- .../CustomProtocol/FindUsagesLSPContext.cs | 1 - .../Handler/References/FindAllReferencesHandler.cs | 1 - 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService_FindReferences.cs b/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService_FindReferences.cs index 22476750802..0eaa67a2a4a 100644 --- a/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService_FindReferences.cs +++ b/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService_FindReferences.cs @@ -20,7 +20,7 @@ namespace Microsoft.CodeAnalysis.Editor.FindUsages { internal abstract partial class AbstractFindUsagesService { - public async Task FindReferencesAsync( + async Task IFindUsagesService.FindReferencesAsync( Document document, int position, IFindUsagesContext context) { var definitionTrackingContext = new DefinitionTrackingContext(context); @@ -48,6 +48,18 @@ internal abstract partial class AbstractFindUsagesService } } + async Task IFindUsagesLSPService.FindReferencesAsync( + Document document, int position, IFindUsagesContext context) + { + // We don't need to get third party definitions when finding references in LSP. + // Currently, 3rd party definitions = XAML definitions, and XAML will provide + // references via LSP instead of hooking into Roslyn. + // This also means that we don't need to be on the UI thread. + var definitionTrackingContext = new DefinitionTrackingContext(context); + await FindLiteralOrSymbolReferencesAsync( + document, position, definitionTrackingContext).ConfigureAwait(false); + } + private async Task FindLiteralOrSymbolReferencesAsync( Document document, int position, IFindUsagesContext context) { diff --git a/src/Features/LanguageServer/Protocol/CustomProtocol/FindUsagesLSPContext.cs b/src/Features/LanguageServer/Protocol/CustomProtocol/FindUsagesLSPContext.cs index 4b46052e334..c2cbe9905a9 100644 --- a/src/Features/LanguageServer/Protocol/CustomProtocol/FindUsagesLSPContext.cs +++ b/src/Features/LanguageServer/Protocol/CustomProtocol/FindUsagesLSPContext.cs @@ -12,7 +12,6 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Classification; -using Microsoft.CodeAnalysis.Editor; using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.FindSymbols; using Microsoft.CodeAnalysis.FindSymbols.Finders; diff --git a/src/Features/LanguageServer/Protocol/Handler/References/FindAllReferencesHandler.cs b/src/Features/LanguageServer/Protocol/Handler/References/FindAllReferencesHandler.cs index 4d67cb49eea..f534b6f1343 100644 --- a/src/Features/LanguageServer/Protocol/Handler/References/FindAllReferencesHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/References/FindAllReferencesHandler.cs @@ -9,7 +9,6 @@ using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using Microsoft.CodeAnalysis.Editor; using Microsoft.CodeAnalysis.Editor.FindUsages; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.CustomProtocol; -- GitLab