Skip to content

Move the semantics checks of Inheritance margin to OOP#61592

Merged
Cosifne merged 7 commits intodotnet:mainfrom
Cosifne:dev/shech/MoveOOP
Jun 1, 2022
Merged

Move the semantics checks of Inheritance margin to OOP#61592
Cosifne merged 7 commits intodotnet:mainfrom
Cosifne:dev/shech/MoveOOP

Conversation

@Cosifne
Copy link
Copy Markdown
Member

@Cosifne Cosifne commented May 31, 2022

This PR is a cleanup PR and a potential solution for https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1528673/

Currently, the inheritance margin service would first get the declared symbols for the given document in devenv, then send all the symbols to OOP, then call FAR services and get the result back.
And as Cyrus mentioned in the issue, somehow this 'GetDeclarationSymbol' call is using a lot of memory. (maybe it hits some cache miss issue I guess)
Also, this is a little bit different from the 'Global imports' features (which is just sending a document and text span to the OOP), so it introduces some similar code.

This PR moves the 'GetDeclaredSymbol' part also to OOP and solves both problems.

@Cosifne Cosifne requested a review from CyrusNajmabadi May 31, 2022 05:15
@Cosifne Cosifne requested review from a team as code owners May 31, 2022 05:15
@ghost ghost added the Area-IDE label May 31, 2022
@Cosifne Cosifne removed the request for review from a team May 31, 2022 05:15
internal interface IRemoteInheritanceMarginService
{
ValueTask<ImmutableArray<InheritanceMarginItem>> GetGlobalImportItemsAsync(
ValueTask<ImmutableArray<InheritanceMarginItem>> GetInheritanceMarginItemsAsync(
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.

This is the core part of the change.
For both features, just send a document and text span to the OOP, and do all the semantics work there.
So we only need one method in the remote interface.

Copy link
Copy Markdown
Member

@genlu genlu left a comment

Choose a reason for hiding this comment

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

I love this change. One fewer feature that needs symbols in proc!

Document document,
TextSpan spanToSearch,
bool includeGlobalImports,
bool frozenPartialSemantics,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why adding a parameter for frozen partial? I don't see this is set to false in the code. Does inheritance-margin need to operate on full semantic?

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.

This parameter is introduced in #61286
As Cyrus and Sam mentioned it is a strange pattern to indicate we are using the frozen partial semantics both in devenv and OOP.

Does inheritance-margin need to operate on full semantic?

See here https://sourceroslyn.io/#Microsoft.VisualStudio.LanguageServices/InheritanceMargin/InheritanceMarginTaggerProvider.cs,59
When the full semantic is ready the tagger would refresh all the tag again to make sure we get the latest semantics.
And we use the frozen partial one to make sure user could see it the glyph as early as possible

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was wondering if the feature needs to operate explicitly on full-semantic. My understanding is, when full semantic is available, using frozen partial would do nothing special. The callsite in the tagger also just set frozenPartialSemantics to true, which was what prompted my question :)

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 was wondering if the feature needs to operate explicitly on full-semantic

No, we generate the InheritanceMarginItems whenever a partial semantic is ready.
And later when the full semantic is ready InheritanceMarginItems are generated again.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

so one thing the old system did was remap from a MAS workpsace to the normal workspaec (presumbly so inheritnace margin works in MAS files). does that continue to work?

@Cosifne
Copy link
Copy Markdown
Member Author

Cosifne commented May 31, 2022

so one thing the old system did was remap from a MAS workpsace to the normal workspaec (presumbly so inheritnace margin works in MAS files). does that continue to work?

Are you asking this? https://sourceroslyn.io/#Microsoft.CodeAnalysis.Features/InheritanceMargin/AbstractInheritanceMarginService.cs,96

which is if a metadata symbol could be found in workspace, we should try to navigate to the 'in source' symbol?

Emm, I manually test it and there are some scenarios don't work.
But it is not regressed in this PR because it also exists in the preview channel.

I will open another PR to fix that.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

Do your tests exercise the OOP paths as well as the non-oop paths? Importantly, are tehy testing the MetadataAsSource scenario?

@Cosifne
Copy link
Copy Markdown
Member Author

Cosifne commented Jun 1, 2022

Do your tests exercise the OOP paths as well as the non-oop paths? Importantly, are tehy testing the MetadataAsSource scenario?

I have changed all the tests to cover both in-process and OOP.

For the MetadataAsSource regression, as we talked offline, it is a problem probably related to DocumentIdAndSpan, not related to this PR.
I am going to check in this PR first and fix that problem later.

@Cosifne Cosifne enabled auto-merge (squash) June 1, 2022 04:25
@Cosifne Cosifne merged commit ca780bb into dotnet:main Jun 1, 2022
@ghost ghost added this to the Next milestone Jun 1, 2022
@RikkiGibson RikkiGibson modified the milestones: Next, 17.3 P3 Jun 28, 2022
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.

4 participants