roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

Filter only valid symbols for inheritance completions

Open DoctorKrolic opened this issue 2 years ago • 10 comments

I was a bit surprised, but there already was symbol filtering, but only for VB. I utilized this behaviour and made it shared between C# and VB. Also transfered some technics to other special case symbol filtering, like getting an underlying symbol form an alias or checking a namespace for valid members. Currently this PR implements:

  • Shared SyntaxContext flags, that allow to utilize inheritance completion behaviour between both languages
  • Correct handling for C# inheritance of classes (provides both classes and interfaces)
  • Correct handling for VB Inherits/Implements
  • Correct handling of interface inheritance in both languages
  • Correct handling of structs when implementing interfaces
  • Correct handling of self-reference both for classes and interfaces (https://github.com/dotnet/roslyn/issues/60935)
  • Correct handling of C# keywords

After review:

  • Added handling of records
  • Do not show classes/records when there is already one item in the base list

As a side result: Fixes: https://github.com/dotnet/roslyn/issues/60935

Example of how it works for basic C# case:

Before: devenv_PyAlypmSS3

After: devenv_65EJMayHB3

DoctorKrolic avatar Jun 19 '22 14:06 DoctorKrolic

Are there vb tests?

CyrusNajmabadi avatar Jun 19 '22 16:06 CyrusNajmabadi

Are there tests for aliases?

CyrusNajmabadi avatar Jun 19 '22 16:06 CyrusNajmabadi

One thing that seemed odd to me is that I didn't see any distinction on c# between being on the first base type of a class/record or the second onwards. The latter must be an interface.

CyrusNajmabadi avatar Jun 19 '22 16:06 CyrusNajmabadi

Are there vb tests?

As I said, VB was there before. So did tests for VB

Are there tests for aliases?

Currently only in VB. Will implement for C#

One thing that seemed odd to me is that I didn't see any distinction on c# between being on the first base type of a class/record or the second onwards. The latter must be an interface.

Yes, I forgot about records and didn't even thought about disabling classes for C# when there is one. Will introduce later as well

DoctorKrolic avatar Jun 19 '22 16:06 DoctorKrolic

@DoctorKrolic The summary of this PR is long, but it doesn't appear to describe the actual change. I'm not sure what I'm supposed to be reviewing, or how it's supposed to be better than what's already there.

sharwell avatar Jun 21 '22 23:06 sharwell

@DoctorKrolic can you revise the title of htis PR to reflect what change is happening?

CyrusNajmabadi avatar Jun 27 '22 21:06 CyrusNajmabadi

@CyrusNajmabadi It seems that I adressed all your feedback, so I would like a review pass again!

DoctorKrolic avatar Jul 13 '22 12:07 DoctorKrolic

Note: enum base completions where already supported in VB, and it was not some explicit check for this case, but because of VB's symbol recommender structure: it checks for all valid cases and else returns empty list. So I thought, that there was no point in all scaffolding required if I want it to be in s shared layer and added just a simple chick in C#-specific code.

DoctorKrolic avatar Jul 13 '22 13:07 DoctorKrolic

Done with pass.

CyrusNajmabadi avatar Jul 14 '22 21:07 CyrusNajmabadi

@CyrusNajmabadi PTAL

DoctorKrolic avatar Aug 11 '22 19:08 DoctorKrolic

On vacation. Will do so when I get back :-)

CyrusNajmabadi avatar Aug 11 '22 21:08 CyrusNajmabadi

@CyrusNajmabadi PTAL!

DoctorKrolic avatar Sep 06 '22 19:09 DoctorKrolic

@DoctorKrolic I've got a lot of critical things i'm looking at right now. This is on my list, but i likely can't get to it for a bit. Thank you for your patience.

CyrusNajmabadi avatar Sep 06 '22 19:09 CyrusNajmabadi