Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix goto types to include records #52523

Merged
merged 2 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,8 @@ private static string GetItemKind(DeclaredSymbolInfo declaredSymbolInfo)
switch (declaredSymbolInfo.Kind)
{
case DeclaredSymbolInfoKind.Class:
return NavigateToItemKind.Class;
case DeclaredSymbolInfoKind.Record:
return NavigateToItemKind.Record;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm a little confused how this works. if you remove this entry, and we do run into a record, won't we crash in this switch?

return NavigateToItemKind.Class;
case DeclaredSymbolInfoKind.Constant:
return NavigateToItemKind.Constant;
case DeclaredSymbolInfoKind.Delegate:
Expand Down Expand Up @@ -356,8 +355,6 @@ public DeclaredSymbolInfoKindSet(IEnumerable<string> navigateToItemKinds)
{
case NavigateToItemKind.Class:
lookupTable[(int)DeclaredSymbolInfoKind.Class] = true;
break;
case NavigateToItemKind.Record:
lookupTable[(int)DeclaredSymbolInfoKind.Record] = true;
break;
case NavigateToItemKind.Constant:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ internal abstract partial class AbstractNavigateToSearchService : INavigateToSea
{
public IImmutableSet<string> KindsProvided { get; } = ImmutableHashSet.Create(
NavigateToItemKind.Class,
NavigateToItemKind.Record,
NavigateToItemKind.Constant,
NavigateToItemKind.Delegate,
NavigateToItemKind.Enum,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public static string Structure => NavigateToItemKind.Structure;
public static string Interface => NavigateToItemKind.Interface;
public static string Delegate => NavigateToItemKind.Delegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static Task<ProjectIndex> GetIndexAsync(

private static async Task<ProjectIndex> CreateIndexAsync(Project project, CancellationToken cancellationToken)
{
var classesAndRecordsThatMayDeriveFromSystemObject = new MultiDictionary<Document, DeclaredSymbolInfo>();
var classesThatMayDeriveFromSystemObject = new MultiDictionary<Document, DeclaredSymbolInfo>();
var valueTypes = new MultiDictionary<Document, DeclaredSymbolInfo>();
var enums = new MultiDictionary<Document, DeclaredSymbolInfo>();
var delegates = new MultiDictionary<Document, DeclaredSymbolInfo>();
Expand All @@ -65,7 +65,7 @@ private static async Task<ProjectIndex> CreateIndexAsync(Project project, Cancel
{
case DeclaredSymbolInfoKind.Class:
case DeclaredSymbolInfoKind.Record:
classesAndRecordsThatMayDeriveFromSystemObject.Add(document, info);
classesThatMayDeriveFromSystemObject.Add(document, info);
break;
case DeclaredSymbolInfoKind.Enum:
enums.Add(document, info);
Expand All @@ -85,7 +85,7 @@ private static async Task<ProjectIndex> CreateIndexAsync(Project project, Cancel
}
}

return new ProjectIndex(classesAndRecordsThatMayDeriveFromSystemObject, valueTypes, enums, delegates, namedTypes);
return new ProjectIndex(classesThatMayDeriveFromSystemObject, valueTypes, enums, delegates, namedTypes);
}
}
}
Expand Down