Skip to content

Show linked symbol in Inheritance Margin#60225

Open
Cosifne wants to merge 21 commits intodotnet:mainfrom
Cosifne:dev/shech/GetLinkedSymbolsForInheritanceMargin
Open

Show linked symbol in Inheritance Margin#60225
Cosifne wants to merge 21 commits intodotnet:mainfrom
Cosifne:dev/shech/GetLinkedSymbolsForInheritanceMargin

Conversation

@Cosifne
Copy link
Copy Markdown
Member

@Cosifne Cosifne commented Mar 17, 2022

Inheritance margin now only shows the inheritance hierarchy within the current document.
For example:
If I open https://github.com/dotnet/roslyn/blob/main/src/EditorFeatures/Core/Tagging/AsynchronousViewTaggerProvider.cs
If I am in netcoreapp3.1
image
If I am in netstandard2.0
image

Note InheritanceMarginTaggerProvideris not shown in netcoreapp3.1.
This is because it is in LanguageServices project, and this project is only targeting net472, which is referencing the netstandard 2.0 version of AsynchronousViewTaggerProvider.

This behavior, is different from the 'Go To Implementation' command, which will show all the linked implementation symbols.
And this PR changes the inheritance margin's behavior to match what 'Go To Implementation' command does.

@Cosifne Cosifne requested a review from a team as a code owner March 17, 2022 07:18
@ghost ghost added the Area-IDE label Mar 17, 2022
@Cosifne
Copy link
Copy Markdown
Member Author

Cosifne commented Mar 24, 2022

@CyrusNajmabadi
Could you review this PR? (It looks like Sam is OOF)

@Cosifne Cosifne requested a review from CyrusNajmabadi March 29, 2022 02:07
@Cosifne
Copy link
Copy Markdown
Member Author

Cosifne commented Mar 29, 2022

@CyrusNajmabadi PTAL : )

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

Done with pass.

@Cosifne Cosifne requested a review from CyrusNajmabadi April 6, 2022 20:23
@Cosifne
Copy link
Copy Markdown
Member Author

Cosifne commented Apr 6, 2022

Tag @CyrusNajmabadi to revisit this : )

// And since interface can't have base class, the item before a baseClass is just the previous item in the array.
// e.g. 'baseClass2' could only be pointed by 'baseClass1'.
var baseType = baseTypes[i];
var incomingSymbolsSetForBaseType = s_symbolHashSetPool.Allocate();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

All Hashset usage of s_symbolHashSetPool.Allocate() is disposed in the using var _ = GetPooledHashSetDictionary(out var incomingSymbolsMapBuilder); (See SymbolSetDictionaryDisposer below)
If this pattern is not easy to understand I am also fine to use the traddtional try-finally block to free the PooledDicionary and the PooledHashSet in it

TestHostDocument testHostDocument,
TestInheritanceMemberItem[] memberItems,
CancellationToken cancellationToken)
CancellationToken cancellationToken = default)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

odd that we even have this parameter at all :)

if (baseInterfaceSymbolGroups.Any() || derivedTypeSymbolGroups.Any())
{
// Interface can only have base interfaces.
Debug.Assert(baseTypeSymbolGroups.IsEmpty);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this assert is ok. but it can be worrying as perhaps teh compiler might have other symbols in error conditions. but fine to keep for now as it's only a debug assert.

ImmutableArray<ISymbol> derivedTypesSymbols,
ImmutableArray<SymbolGroup> baseSymbolGroups,
ImmutableArray<SymbolGroup> derivedTypesSymbolGroups,
CancellationToken cancellationToken)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

aside, this member returns an Item?. is null actually possible to return here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

var location = locations[0];
return location.IsInMetadata || (location.IsInSource && location.IsVisibleSourceLocation());
}
return !locations.IsEmpty;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not sure i get the logic here. it's navigable if it's either got one location that hav esome property, or it has 2 or more locations total?


private static ImmutableArray<ISymbol> GetImplementedSymbolsForTypeMember(
ISymbol memberSymbol,
ImmutableArray<ISymbol> overriddenSymbols)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what happened with this guy? :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it has been replaced by ImplementedSymbolAndOverriddenSymbolsFinder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants