-
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
Add LSP light bulb support for usings in Razor #5526
Comments
More generally here we've got two options for CodeActions edits where we need context (IE, create local function vs create class function):
Both of these options provide the same utility (giving us context about what an edit relates to), but have different levels of specificity. The choice between the too likely ends up lying with the Omnisharp folks. |
While we're at it we should re-examine our format a bit. Currently we aren't really using LSP, so we'll have to rewrite things a bunch of times. Because we need to go out to OmniSharp some of that is unavoidable (and we probably can't use the base codeactions endpoint from the spec |
The current thinking is to take the SyntaxTreeComparison structure from Roslyn EditAndContinue and apply it to this problem. We would take the EditScript produced by that and inspect it to see if the node modifications on it are handle-able by us (IE: "Create a using node with this parent node" would be add using, "Move function from parent class to parent statement" would be make function local). This means we'll have to create the syntax-tree that the edits would result in on the fly. Making those APIs public is non-trivial though, so they want us to try that out first using local copies of some of the relevant classes (like this and this) to make sure that the whole approach will work. |
Note, per discussion, the |
Blocked on: https://github.com/dotnet/aspnetcore/issues/25250 Prioritizing that and other tasks, pushing this to preview 4. |
### Summary of the changes - Support for Fully Qualified Namespace C# Light Bulb ![FullyQualifiedCodeAction](https://user-images.githubusercontent.com/14852843/93262976-f1da7f80-f759-11ea-9877-05e9df2ed88b.gif) - Support for Add Using C# Light bulb ![AddUsingCodeAction](https://user-images.githubusercontent.com/14852843/93263130-2d754980-f75a-11ea-890d-bfb07516a354.gif) - 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`. - Tracked here: https://github.com/dotnet/aspnetcore/issues/25918 - 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
This isn't totally straightforward because the C# using won't be offered today because of
#line hidden
directives. We can work around this by making design-time generated C# files have a#line default
around the using directives. This looks something like:Once we've done that we'll be able to create a Razor CodeAction which can translate the c# codeaction.
The text was updated successfully, but these errors were encountered: