From 9b1223e372bc17758feb82d90eeb94a9fe326980 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Fri, 9 Apr 2021 17:31:50 +0000 Subject: [PATCH 1/2] Fix goto types to include records --- .../NavigateToItemProvider.Callback.cs | 42 +------------------ ...stractNavigateToSearchService.InProcess.cs | 5 --- .../AbstractNavigateToSearchService.cs | 1 - .../Portable/NavigateTo/NavigateToItemKind.cs | 1 - .../NavigateTo/RoslynNavigateToItem.cs | 1 - .../NavigateTo/FSharpNavigateToItemKind.cs | 1 - .../CSharpDeclaredSymbolInfoFactoryService.cs | 2 +- .../FindSymbols/DeclaredSymbolInfo.cs | 1 - .../DependentTypeFinder_ProjectIndex.cs | 7 ++-- 9 files changed, 5 insertions(+), 56 deletions(-) diff --git a/src/EditorFeatures/Core.Wpf/NavigateTo/NavigateToItemProvider.Callback.cs b/src/EditorFeatures/Core.Wpf/NavigateTo/NavigateToItemProvider.Callback.cs index 4e1c1550397f7..59d9b9a83a53f 100644 --- a/src/EditorFeatures/Core.Wpf/NavigateTo/NavigateToItemProvider.Callback.cs +++ b/src/EditorFeatures/Core.Wpf/NavigateTo/NavigateToItemProvider.Callback.cs @@ -57,7 +57,7 @@ private void ReportMatchResult(Project project, INavigateToSearchResult result) var navigateToItem = new NavigateToItem( result.Name, - GetKind(result.Kind), + result.Kind, GetNavigateToLanguage(project.Language), result.SecondarySort, result, @@ -66,46 +66,6 @@ private void ReportMatchResult(Project project, INavigateToSearchResult result) _callback.AddItem(navigateToItem); } - private static string GetKind(string kind) - => kind switch - { - CodeAnalysis.NavigateTo.NavigateToItemKind.Class - => VisualStudio.Language.NavigateTo.Interfaces.NavigateToItemKind.Class, - CodeAnalysis.NavigateTo.NavigateToItemKind.Constant - => VisualStudio.Language.NavigateTo.Interfaces.NavigateToItemKind.Constant, - CodeAnalysis.NavigateTo.NavigateToItemKind.Delegate - => VisualStudio.Language.NavigateTo.Interfaces.NavigateToItemKind.Delegate, - CodeAnalysis.NavigateTo.NavigateToItemKind.Enum - => VisualStudio.Language.NavigateTo.Interfaces.NavigateToItemKind.Enum, - CodeAnalysis.NavigateTo.NavigateToItemKind.EnumItem - => VisualStudio.Language.NavigateTo.Interfaces.NavigateToItemKind.EnumItem, - CodeAnalysis.NavigateTo.NavigateToItemKind.Event - => VisualStudio.Language.NavigateTo.Interfaces.NavigateToItemKind.Event, - CodeAnalysis.NavigateTo.NavigateToItemKind.Field - => VisualStudio.Language.NavigateTo.Interfaces.NavigateToItemKind.Field, - CodeAnalysis.NavigateTo.NavigateToItemKind.File - => VisualStudio.Language.NavigateTo.Interfaces.NavigateToItemKind.File, - CodeAnalysis.NavigateTo.NavigateToItemKind.Interface - => VisualStudio.Language.NavigateTo.Interfaces.NavigateToItemKind.Interface, - CodeAnalysis.NavigateTo.NavigateToItemKind.Line - => VisualStudio.Language.NavigateTo.Interfaces.NavigateToItemKind.Line, - CodeAnalysis.NavigateTo.NavigateToItemKind.Method - => VisualStudio.Language.NavigateTo.Interfaces.NavigateToItemKind.Method, - CodeAnalysis.NavigateTo.NavigateToItemKind.Module - => VisualStudio.Language.NavigateTo.Interfaces.NavigateToItemKind.Module, - CodeAnalysis.NavigateTo.NavigateToItemKind.OtherSymbol - => VisualStudio.Language.NavigateTo.Interfaces.NavigateToItemKind.OtherSymbol, - CodeAnalysis.NavigateTo.NavigateToItemKind.Property - => VisualStudio.Language.NavigateTo.Interfaces.NavigateToItemKind.Property, - // VisualStudio.Language.NavigateTo.Interfaces.NavigateToItemKind doesn't have a record, fall back to class. - // This should be updated whenever NavigateToItemKind has a record. - CodeAnalysis.NavigateTo.NavigateToItemKind.Record - => VisualStudio.Language.NavigateTo.Interfaces.NavigateToItemKind.Class, - CodeAnalysis.NavigateTo.NavigateToItemKind.Structure - => VisualStudio.Language.NavigateTo.Interfaces.NavigateToItemKind.Structure, - _ => throw ExceptionUtilities.UnexpectedValue(kind) - }; - private static PatternMatchKind GetPatternMatchKind(NavigateToMatchKind matchKind) => matchKind switch { diff --git a/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.InProcess.cs b/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.InProcess.cs index be4b472ed866d..255802737b3a4 100644 --- a/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.InProcess.cs +++ b/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.InProcess.cs @@ -288,8 +288,6 @@ private static string GetItemKind(DeclaredSymbolInfo declaredSymbolInfo) { case DeclaredSymbolInfoKind.Class: return NavigateToItemKind.Class; - case DeclaredSymbolInfoKind.Record: - return NavigateToItemKind.Record; case DeclaredSymbolInfoKind.Constant: return NavigateToItemKind.Constant; case DeclaredSymbolInfoKind.Delegate: @@ -357,9 +355,6 @@ public DeclaredSymbolInfoKindSet(IEnumerable navigateToItemKinds) case NavigateToItemKind.Class: lookupTable[(int)DeclaredSymbolInfoKind.Class] = true; break; - case NavigateToItemKind.Record: - lookupTable[(int)DeclaredSymbolInfoKind.Record] = true; - break; case NavigateToItemKind.Constant: lookupTable[(int)DeclaredSymbolInfoKind.Constant] = true; break; diff --git a/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.cs b/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.cs index 139d21fe1d9bf..7f77e87431778 100644 --- a/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.cs +++ b/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.cs @@ -16,7 +16,6 @@ internal abstract partial class AbstractNavigateToSearchService : INavigateToSea { public IImmutableSet KindsProvided { get; } = ImmutableHashSet.Create( NavigateToItemKind.Class, - NavigateToItemKind.Record, NavigateToItemKind.Constant, NavigateToItemKind.Delegate, NavigateToItemKind.Enum, diff --git a/src/Features/Core/Portable/NavigateTo/NavigateToItemKind.cs b/src/Features/Core/Portable/NavigateTo/NavigateToItemKind.cs index d2e17e5e14446..8790ecb998ca8 100644 --- a/src/Features/Core/Portable/NavigateTo/NavigateToItemKind.cs +++ b/src/Features/Core/Portable/NavigateTo/NavigateToItemKind.cs @@ -11,7 +11,6 @@ internal static class NavigateToItemKind public const string Line = nameof(Line); public const string File = nameof(File); public const string Class = nameof(Class); - public const string Record = nameof(Record); public const string Structure = nameof(Structure); public const string Interface = nameof(Interface); public const string Delegate = nameof(Delegate); diff --git a/src/Features/Core/Portable/NavigateTo/RoslynNavigateToItem.cs b/src/Features/Core/Portable/NavigateTo/RoslynNavigateToItem.cs index 979ee6a3c5c4d..c1ad545aad308 100644 --- a/src/Features/Core/Portable/NavigateTo/RoslynNavigateToItem.cs +++ b/src/Features/Core/Portable/NavigateTo/RoslynNavigateToItem.cs @@ -167,7 +167,6 @@ private bool IsNamedType() switch (_item.DeclaredSymbolInfo.Kind) { case DeclaredSymbolInfoKind.Class: - case DeclaredSymbolInfoKind.Record: case DeclaredSymbolInfoKind.Enum: case DeclaredSymbolInfoKind.Interface: case DeclaredSymbolInfoKind.Module: diff --git a/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToItemKind.cs b/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToItemKind.cs index 0b5175a2cb4dc..123c14ebb4baa 100644 --- a/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToItemKind.cs +++ b/src/Tools/ExternalAccess/FSharp/NavigateTo/FSharpNavigateToItemKind.cs @@ -13,7 +13,6 @@ internal static class FSharpNavigateToItemKind public static string Line => NavigateToItemKind.Line; public static string File = NavigateToItemKind.File; public static string Class => NavigateToItemKind.Class; - public static string Record => NavigateToItemKind.Record; public static string Structure => NavigateToItemKind.Structure; public static string Interface => NavigateToItemKind.Interface; public static string Delegate => NavigateToItemKind.Delegate; diff --git a/src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs b/src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs index d3fa6a2825ce3..053c258bb462c 100644 --- a/src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs +++ b/src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs @@ -179,7 +179,7 @@ public override bool TryGetDeclaredSymbolInfo(StringTable stringTable, SyntaxNod node.Kind() switch { SyntaxKind.ClassDeclaration => DeclaredSymbolInfoKind.Class, - SyntaxKind.RecordDeclaration => DeclaredSymbolInfoKind.Record, + SyntaxKind.RecordDeclaration => DeclaredSymbolInfoKind.Class, SyntaxKind.InterfaceDeclaration => DeclaredSymbolInfoKind.Interface, SyntaxKind.StructDeclaration => DeclaredSymbolInfoKind.Struct, _ => throw ExceptionUtilities.UnexpectedValue(node.Kind()), diff --git a/src/Workspaces/Core/Portable/FindSymbols/DeclaredSymbolInfo.cs b/src/Workspaces/Core/Portable/FindSymbols/DeclaredSymbolInfo.cs index 52acb4f38e8c3..8665d5d59d8f0 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/DeclaredSymbolInfo.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/DeclaredSymbolInfo.cs @@ -30,7 +30,6 @@ internal enum DeclaredSymbolInfoKind : byte Method, Module, Property, - Record, Struct, } diff --git a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentTypeFinder_ProjectIndex.cs b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentTypeFinder_ProjectIndex.cs index 8141e0a29c731..bd76156755867 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentTypeFinder_ProjectIndex.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentTypeFinder_ProjectIndex.cs @@ -48,7 +48,7 @@ public static Task GetIndexAsync( private static async Task CreateIndexAsync(Project project, CancellationToken cancellationToken) { - var classesAndRecordsThatMayDeriveFromSystemObject = new MultiDictionary(); + var classesThatMayDeriveFromSystemObject = new MultiDictionary(); var valueTypes = new MultiDictionary(); var enums = new MultiDictionary(); var delegates = new MultiDictionary(); @@ -64,8 +64,7 @@ private static async Task CreateIndexAsync(Project project, Cancel switch (info.Kind) { case DeclaredSymbolInfoKind.Class: - case DeclaredSymbolInfoKind.Record: - classesAndRecordsThatMayDeriveFromSystemObject.Add(document, info); + classesThatMayDeriveFromSystemObject.Add(document, info); break; case DeclaredSymbolInfoKind.Enum: enums.Add(document, info); @@ -85,7 +84,7 @@ private static async Task CreateIndexAsync(Project project, Cancel } } - return new ProjectIndex(classesAndRecordsThatMayDeriveFromSystemObject, valueTypes, enums, delegates, namedTypes); + return new ProjectIndex(classesThatMayDeriveFromSystemObject, valueTypes, enums, delegates, namedTypes); } } } From d72004d856b06653c8beb63f19d9053c716fa2b9 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Sat, 10 Apr 2021 20:20:01 +0200 Subject: [PATCH 2/2] Add DeclaredSymbolInfoKind.Record back --- .../NavigateTo/AbstractNavigateToSearchService.InProcess.cs | 2 ++ src/Features/Core/Portable/NavigateTo/RoslynNavigateToItem.cs | 1 + .../FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs | 2 +- src/Workspaces/Core/Portable/FindSymbols/DeclaredSymbolInfo.cs | 1 + .../FindReferences/DependentTypeFinder_ProjectIndex.cs | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.InProcess.cs b/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.InProcess.cs index 255802737b3a4..62f63b5399cbd 100644 --- a/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.InProcess.cs +++ b/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.InProcess.cs @@ -287,6 +287,7 @@ private static string GetItemKind(DeclaredSymbolInfo declaredSymbolInfo) switch (declaredSymbolInfo.Kind) { case DeclaredSymbolInfoKind.Class: + case DeclaredSymbolInfoKind.Record: return NavigateToItemKind.Class; case DeclaredSymbolInfoKind.Constant: return NavigateToItemKind.Constant; @@ -354,6 +355,7 @@ public DeclaredSymbolInfoKindSet(IEnumerable navigateToItemKinds) { case NavigateToItemKind.Class: lookupTable[(int)DeclaredSymbolInfoKind.Class] = true; + lookupTable[(int)DeclaredSymbolInfoKind.Record] = true; break; case NavigateToItemKind.Constant: lookupTable[(int)DeclaredSymbolInfoKind.Constant] = true; diff --git a/src/Features/Core/Portable/NavigateTo/RoslynNavigateToItem.cs b/src/Features/Core/Portable/NavigateTo/RoslynNavigateToItem.cs index c1ad545aad308..979ee6a3c5c4d 100644 --- a/src/Features/Core/Portable/NavigateTo/RoslynNavigateToItem.cs +++ b/src/Features/Core/Portable/NavigateTo/RoslynNavigateToItem.cs @@ -167,6 +167,7 @@ private bool IsNamedType() switch (_item.DeclaredSymbolInfo.Kind) { case DeclaredSymbolInfoKind.Class: + case DeclaredSymbolInfoKind.Record: case DeclaredSymbolInfoKind.Enum: case DeclaredSymbolInfoKind.Interface: case DeclaredSymbolInfoKind.Module: diff --git a/src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs b/src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs index 053c258bb462c..d3fa6a2825ce3 100644 --- a/src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs +++ b/src/Workspaces/CSharp/Portable/FindSymbols/CSharpDeclaredSymbolInfoFactoryService.cs @@ -179,7 +179,7 @@ public override bool TryGetDeclaredSymbolInfo(StringTable stringTable, SyntaxNod node.Kind() switch { SyntaxKind.ClassDeclaration => DeclaredSymbolInfoKind.Class, - SyntaxKind.RecordDeclaration => DeclaredSymbolInfoKind.Class, + SyntaxKind.RecordDeclaration => DeclaredSymbolInfoKind.Record, SyntaxKind.InterfaceDeclaration => DeclaredSymbolInfoKind.Interface, SyntaxKind.StructDeclaration => DeclaredSymbolInfoKind.Struct, _ => throw ExceptionUtilities.UnexpectedValue(node.Kind()), diff --git a/src/Workspaces/Core/Portable/FindSymbols/DeclaredSymbolInfo.cs b/src/Workspaces/Core/Portable/FindSymbols/DeclaredSymbolInfo.cs index 8665d5d59d8f0..52acb4f38e8c3 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/DeclaredSymbolInfo.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/DeclaredSymbolInfo.cs @@ -30,6 +30,7 @@ internal enum DeclaredSymbolInfoKind : byte Method, Module, Property, + Record, Struct, } diff --git a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentTypeFinder_ProjectIndex.cs b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentTypeFinder_ProjectIndex.cs index bd76156755867..af301e97b1b92 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentTypeFinder_ProjectIndex.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentTypeFinder_ProjectIndex.cs @@ -64,6 +64,7 @@ private static async Task CreateIndexAsync(Project project, Cancel switch (info.Kind) { case DeclaredSymbolInfoKind.Class: + case DeclaredSymbolInfoKind.Record: classesThatMayDeriveFromSystemObject.Add(document, info); break; case DeclaredSymbolInfoKind.Enum: