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

Avoid adding the CompletionItem when the alias type exists #49488

Merged
merged 14 commits into from
Feb 8, 2021

Conversation

Cosifne
Copy link
Member

@Cosifne Cosifne commented Nov 19, 2020

Linked Issue: #44366 and #39785

Right now if there is a type alias in the code, VS would still keep suggesting the item from unimported namespace.
image

After this PR, if there is an alias for the type, we won't provide this CompletionItem from TypeImportCompletionProvider
image

@Cosifne Cosifne requested a review from a team as a code owner November 19, 2020 01:52
@Cosifne Cosifne requested a review from genlu November 19, 2020 01:56
@Cosifne Cosifne force-pushed the dev/shech/nameAliasCompletion branch from 0412f0e to c38fd0c Compare November 19, 2020 05:13
@Cosifne
Copy link
Member Author

Cosifne commented Dec 3, 2020

Tag @genlu in case you didn't see this PR

@genlu
Copy link
Member

genlu commented Dec 3, 2020

Done with pass. Overall looks good. Let me know when it's ready for another look.
Also, looks like in the 2nd screenshot above it didn't have import completion enabled? :)

@genlu
Copy link
Member

genlu commented Jan 5, 2021

Any update on this? I'm just going through all PRs I've been involved to make sure I didn't miss anything, so no hurry :)

@Cosifne
Copy link
Member Author

Cosifne commented Jan 27, 2021

Any update on this? I'm just going through all PRs I've been involved to make sure I didn't miss anything, so no hurry :)

I just forgot this PR for a while. Working on that to get it done

@Cosifne Cosifne requested a review from genlu January 28, 2021 07:38
@Cosifne Cosifne requested a review from genlu January 29, 2021 01:01
{
public class Main
{
$$
Copy link
Member

Choose a reason for hiding this comment

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

I think to test attribute items, the trigger needs to be in attribute context. Otherwise, it's just behaves as regular types

// check if the type name is in the dictionary.
// It is done in this way to avoid calling ImportCompletionItem.GetTypeName for all the CompletionItems
if (!aliasTargetNamespaceToTypeNameMap.IsEmpty
&& aliasTargetNamespaceToTypeNameMap[containingNamespace].Contains(ImportCompletionItem.GetTypeName(item)))
Copy link
Member

Choose a reason for hiding this comment

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

nit: I guess we really don't care if it's a generic type, since no generic target will be in the dictionary.

Copy link
Member

Choose a reason for hiding this comment

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

why do you need the aliasTargetNamespaceToTypeNameMap.IsEmpty check?

Copy link
Member

Choose a reason for hiding this comment

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

Because it cheaper than indexing into the dictionary. We are dealing with large amount of item and it's very rare there's using alias in the document

Copy link
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.

:shipit:

@CyrusNajmabadi
Copy link
Member

do we have perf information around this? i ask because completion seems to feel much slower than it did a few months back. i'm worried that it may be because of import completion. when we try this while typing in roslyn, what sort of absolute time do we se taken up by import completion?

@Cosifne
Copy link
Member Author

Cosifne commented Feb 4, 2021

do we have perf information around this? i ask because completion seems to feel much slower than it did a few months back. i'm worried that it may be because of import completion. when we try this while typing in roslyn, what sort of absolute time do we se taken up by import completion?

I would have a perfView test report post here before I checked in.

@Cosifne
Copy link
Member Author

Cosifne commented Feb 5, 2021

do we have perf information around this? i ask because completion seems to feel much slower than it did a few months back. i'm worried that it may be because of import completion. when we try this while typing in roslyn, what sort of absolute time do we se taken up by import completion?

Collect 5 etls file in Roslyn repo at diffferent test project and the only trace I could see is AbstractTypeImportCompletionService.GetCachedEntriesAsync for TypeCompletionProvider.
I didn't see the call stack for the adding method 'GetAliasDecalrationNodes' and the local method 'ShouldAddItem' (maybe the local method is inlined)

So given the amount of alias type in each document should be very few(in Roslyn we only have 1-5 alias), I don't think this would have a big impact for the perf

@Cosifne Cosifne merged commit a3feecd into dotnet:master Feb 8, 2021
@ghost ghost added this to the Next milestone Feb 8, 2021
@RikkiGibson RikkiGibson modified the milestones: Next, 16.10.P1 Feb 17, 2021
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.

5 participants