-
Notifications
You must be signed in to change notification settings - Fork 416
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 support for code actions besides ApplyChangesOperation's #1724
Add support for code actions besides ApplyChangesOperation's #1724
Conversation
thanks a lot, can you please describe the scenario that you are trying to fix? due to some complexities of how to deal with editor state in such cases, the other code action types have been excluded by design. also, in addition to that, is there some test that you can add to demonstrate what is now working better? |
@filipw Thanks for the review. I have an analyzer with a non-ApplyChangesOperation code fix. Currently the behavior is that there's a little button that says 'fix it' and you click it and it just does nothing with no error. If these really aren't supported than they shouldn't show up in the UI, or they should generate an error when you try to use them. With this change, the code fix works, although I do have to edit code to get it to refresh the state. Still a much better experience. It seems like I should be able to add tests for this. Please confirm if you want the change, and I'll do it. |
I am more worried about creating a corrupt state between editor and server. can you show which analyzer exactly you are using? there are analyzer tests here too, so it should be possible for you to add it as well - thanks! |
@filipw Analyzer I was trying to get working is here: Not open source, but maybe you can see it. |
If it's dangerous to do arbitrary code fixes without signaling what's changed, maybe this should emit some kind of error message instead? In any case silently ignoring the request seems like a bug. The particular code fixes I was trying to fix could probably be made into ApplyChangesOperation's if they need to. I'm curious what kind of state corruption could occur, though. As far as I can tell, there's no feedback to either the editor or Omnisharp when random code fixes are applied. So it should be no different than opening up notepad and applying the code fix manually or something :). |
unfortunately I get 401 when accessing this. Can you please post the analyzer here? what is its type? In either case we will likely have to special case this - many of the |
@filipw We've got an analyzer that requires certain code patterns to be registered in files, and then we've got a code action which adds them to the file. The code for the operation is just implemented as a custom operation, and is pretty straightforward. Since these 'registration' files are not part of the solution, it's not an ApplyChangesOperation, but it works fine to run from omnisharp.
|
@filipw Any more thoughts on this change? I don't know what other operations people have, but in my case, the operation is safe to apply even though it is not an ApplyChangesOperation. If it isn't going to get merged, though, I will abandon the PR. However, I think we could instead add some logic to filter out these operations from appearing in VS Code or, if this is difficult, some messaging to tell people that their code fix is not being applied. Currently you click the apply code fix button and it does nothing. I'd be happy to stick an error notification or something there. |
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.
@Samirat thanks, let's merge this for the time being, I think your reasoning makes sense
@filipw Doesn't look like I can merge this myself. |
No description provided.