-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Go to base: support metadata references and bug fixes #39055
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e989b79
extend test classes to support goto metadata locations
ivanbasov db422b2
tests for goto base to metadata locations
ivanbasov 24369eb
tests for overloads
ivanbasov e57c789
correcting tests for new/shadow
ivanbasov 5432766
gotobase - fixing bugs
ivanbasov e17e82f
fix test harness for metadata references in gotobase
ivanbasov b37b94b
support bases for classes and structs in tests
ivanbasov d88b0fa
refactoring
ivanbasov dcb65ae
UI support for displaying metadata references
ivanbasov fdf4947
Merge branch 'master' into GoToBase
ivanbasov a966c1f
code review feedback
ivanbasov 2c13e88
refactiring item entries
ivanbasov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.CodeAnalysis.Editor.FindUsages; | ||
| using Microsoft.CodeAnalysis.FindSymbols; | ||
|
|
@@ -12,34 +13,60 @@ internal abstract partial class AbstractGoToBaseService : IGoToBaseService | |
| public async Task FindBasesAsync(Document document, int position, IFindUsagesContext context) | ||
| { | ||
| var cancellationToken = context.CancellationToken; | ||
| var tuple = await FindBaseHelpers.FindBasesAsync(document, position, cancellationToken).ConfigureAwait(false); | ||
| if (tuple == null) | ||
| var symbolAndProject = await FindUsagesHelpers.GetRelevantSymbolAndProjectAtPositionAsync( | ||
| document, position, cancellationToken).ConfigureAwait(false); | ||
|
|
||
| if (symbolAndProject == default) | ||
| { | ||
| await context.ReportMessageAsync( | ||
| EditorFeaturesResources.Cannot_navigate_to_the_symbol_under_the_caret).ConfigureAwait(false); | ||
| return; | ||
| } | ||
|
|
||
| var (symbol, implementations, message) = tuple.Value; | ||
|
|
||
| if (message != null) | ||
| { | ||
| await context.ReportMessageAsync(message).ConfigureAwait(false); | ||
| return; | ||
| } | ||
| var symbol = symbolAndProject.Value.symbol; | ||
| var bases = FindBaseHelpers.FindBases( | ||
| symbol, symbolAndProject.Value.project, cancellationToken); | ||
|
|
||
| await context.SetSearchTitleAsync( | ||
| string.Format(EditorFeaturesResources._0_bases, | ||
| FindUsagesHelpers.GetDisplayName(symbol))).ConfigureAwait(false); | ||
|
|
||
| var solution = document.Project.Solution; | ||
| var project = document.Project; | ||
| var solution = project.Solution; | ||
| var projectId = project.Id; | ||
|
|
||
| var found = false; | ||
|
|
||
| // For each potential base, try to find its definition in sources. | ||
| // If found, add its' definitionItem to the context. | ||
| // If not found but the symbol is from metadata, create its' definition item from metadata and add to the context. | ||
| foreach (var baseSymbol in bases) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doc what this is doing. #Resolved |
||
| { | ||
| var sourceDefinition = await SymbolFinder.FindSourceDefinitionAsync( | ||
| SymbolAndProjectId.Create(baseSymbol, projectId), solution, cancellationToken).ConfigureAwait(false); | ||
| if (sourceDefinition.Symbol != null && | ||
| sourceDefinition.Symbol.Locations.Any(l => l.IsInSource)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FindSourceDefinitionAsync should only be returning symbols from source in the first place... #Resolved |
||
| { | ||
| var definitionItem = await sourceDefinition.Symbol.ToClassifiedDefinitionItemAsync( | ||
| solution.GetProject(sourceDefinition.ProjectId), includeHiddenLocations: false, | ||
| FindReferencesSearchOptions.Default, cancellationToken: cancellationToken) | ||
| .ConfigureAwait(false); | ||
| await context.OnDefinitionFoundAsync(definitionItem).ConfigureAwait(false); | ||
| found = true; | ||
| } | ||
| else if (baseSymbol.Locations.Any(l => l.IsInMetadata)) | ||
| { | ||
| var definitionItem = baseSymbol.ToNonClassifiedDefinitionItem( | ||
| project, includeHiddenLocations: true); | ||
| await context.OnDefinitionFoundAsync(definitionItem).ConfigureAwait(false); | ||
| found = true; | ||
| } | ||
| } | ||
|
|
||
| foreach (var implementation in implementations) | ||
| if (!found) | ||
| { | ||
| var definitionItem = await implementation.Symbol.ToClassifiedDefinitionItemAsync( | ||
| solution.GetProject(implementation.ProjectId), includeHiddenLocations: false, | ||
| FindReferencesSearchOptions.Default, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
| await context.OnDefinitionFoundAsync(definitionItem).ConfigureAwait(false); | ||
| await context.ReportMessageAsync(EditorFeaturesResources.The_symbol_has_no_base) | ||
| .ConfigureAwait(false); | ||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"it's" (and everywhere else) #Resolved