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

Support CSharp Light Bulbs (FQN, Add Using) #2501

Merged
merged 35 commits into from
Sep 16, 2020

Conversation

TanayParikh
Copy link
Contributor

@TanayParikh TanayParikh commented Sep 15, 2020

Summary of the changes

  • Support for Fully Qualified Namespace C# Light Bulb
    FullyQualifiedCodeAction

  • Support for Add Using C# Light bulb
    AddUsingCodeAction

  • Abstraction Layer / Refactoring to create shared light bulb infrastructure between TSLanguageServer + HTMLCSharpLanguageServer.

  • This implementation doesn't have support for code actions which require resolving with Roslyn (ex. via textDocument/codeActionResolve). Working on an appropriate expansion for this, and will likely require changes in omnisharp-vscode.

  • Some general perf optimizations are possible, but wanted to avoid potential pre-optimizations. Will re-visit if we see issues.

  • Testing: TODO assuming no issues with the design.

Fixes: https://github.com/dotnet/aspnetcore/issues/24779
Fixes: https://github.com/dotnet/aspnetcore/issues/18173
Fixes: https://github.com/dotnet/aspnetcore/issues/24778
Fixes: https://github.com/dotnet/aspnetcore/issues/25144

}

private commandAsCodeAction(command: vscode.Command): RazorCodeAction {
return { title: command.title } as RazorCodeAction;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be expanded with the code action resolve implementation.

@TanayParikh TanayParikh changed the title *DO NOT REVIEW: WIP* Support CSharp Light Bulbs Support CSharp Light Bulbs (FQN, Add Using) Sep 15, 2020
@TanayParikh TanayParikh marked this pull request as ready for review September 15, 2020 21:02
{
get => true;
set { /* no-op */ }
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unrelated change from earlier PR feedback.

@@ -24,6 +24,7 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Test.CodeActions
{
public class CodeActionEndpointTest : LanguageServerTestBase
{
private readonly RazorDocumentMappingService DocumentMappingService = Mock.Of<RazorDocumentMappingService>();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests updated to a passing state. Testing of functionality introduced with this PR is to be done.

I'd like to get this merged first to ensure the PR isn't too large. I'll subsequently implement the resolve endpoint, and do the testing for it all together because there's likely to be a good deal of overlap.

Copy link
Contributor

@ajaybhargavb ajaybhargavb left a comment

Choose a reason for hiding this comment

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

LGTM from a quick skim. I'll look at it more in some time.

return namespaceName;
}

internal static RazorCodeAction CreateAddUsingCodeAction(string fullyQualifiedName, DocumentUri uri)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this functionality be in a base class instead of a helper class? We generally try to avoid helper methods if possible to keep it contained to where it is intended to be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's used in two separate providers RazorAddUsingsCodeActionProvider which implements RazorCodeActionProvider and CSharpAddUsingsCodeActionProvider which implements CSharpCodeActionProvider. So I don't think a base class would be possible without multiple-inheritance here.

Copy link
Contributor

@NTaylorMullen NTaylorMullen left a comment

Choose a reason for hiding this comment

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

Hot damn this is awesome to see land! 👏

Love where you're going with it. Had some suggestions and a few questions throughout.

@TanayParikh
Copy link
Contributor Author

TanayParikh commented Sep 16, 2020

Thanks @NTaylorMullen @ajaybhargavb. Addressed the feedback.

Noticing some issues where fully qualifying <Hello> results in <SomeComponent.Hello.Hello> despite the preview showing <SomeComponent.Hello>. Considering the preview is correct, I believe this is an external regression.

I'm also not getting any code actions with CTRL + . (shows no code actions found), but I do get them when I right click and select quick actions. I believe this is likely also an external regression.

Is anyone else seeing this on latest VS?

Edit: Seeing this in aspnetcore-tooling/master, so not blocking this PR. Created: https://github.com/dotnet/aspnetcore/issues/25964

Copy link
Contributor

@NTaylorMullen NTaylorMullen left a comment

Choose a reason for hiding this comment

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

Poifect!! Looks good to me!

Copy link
Contributor

@ajaybhargavb ajaybhargavb left a comment

Choose a reason for hiding this comment

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

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants