-
Notifications
You must be signed in to change notification settings - Fork 196
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
Conversation
…/aspnetcore-tooling into taparik/csharp_lightbulbs
} | ||
|
||
private commandAsCodeAction(command: vscode.Command): RazorCodeAction { | ||
return { title: command.title } as RazorCodeAction; |
There was a problem hiding this comment.
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.
...c/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/AddUsingsCodeActionProviderHelper.cs
Outdated
Show resolved
Hide resolved
{ | ||
get => true; | ||
set { /* no-op */ } | ||
} |
There was a problem hiding this comment.
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.
...oft.VisualStudio.LanguageServer.ContainedLanguage.Test/DefaultLSPDocumentSynchronizerTest.cs
Outdated
Show resolved
Hide resolved
@@ -24,6 +24,7 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.Test.CodeActions | |||
{ | |||
public class CodeActionEndpointTest : LanguageServerTestBase | |||
{ | |||
private readonly RazorDocumentMappingService DocumentMappingService = Mock.Of<RazorDocumentMappingService>(); |
There was a problem hiding this comment.
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.
There was a problem hiding this 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/CodeActionEndpoint.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/CodeActionEndpoint.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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.
...c/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/AddUsingsCodeActionProviderHelper.cs
Outdated
Show resolved
Hide resolved
...c/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/AddUsingsCodeActionProviderHelper.cs
Outdated
Show resolved
Hide resolved
...c/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/AddUsingsCodeActionProviderHelper.cs
Outdated
Show resolved
Hide resolved
...c/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/AddUsingsCodeActionProviderHelper.cs
Outdated
Show resolved
Hide resolved
...c/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/AddUsingsCodeActionProviderHelper.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.VSCode/src/CodeActions/CodeActionsHandler.ts
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DynamicDocumentContainer.cs
Show resolved
Hide resolved
...oft.VisualStudio.LanguageServerClient.Razor/DefaultRazorLanguageServerCustomMessageTarget.cs
Outdated
Show resolved
Hide resolved
.../Microsoft.VisualStudio.LanguageServerClient.Razor/RazorLanguageServerCustomMessageTarget.cs
Show resolved
Hide resolved
...oft.VisualStudio.LanguageServer.ContainedLanguage.Test/DefaultLSPDocumentSynchronizerTest.cs
Outdated
Show resolved
Hide resolved
Thanks @NTaylorMullen @ajaybhargavb. Addressed the feedback. Noticing some issues where fully qualifying I'm also not getting any code actions with 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 |
There was a problem hiding this 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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Summary of the changes
Support for Fully Qualified Namespace C# Light Bulb
Support for Add Using C# Light bulb
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 inomnisharp-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