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

LanguageServerCodeTransformExtension: allow query class new variants #2645

Closed

Conversation

przepompownia
Copy link
Contributor

No description provided.

@przepompownia
Copy link
Contributor Author

przepompownia commented Apr 22, 2024

I didn't found any similar method on the LSP side. If such one exist, please close this PR.

Up until now, I was manually creating a list of variants for each project and had overlooked that Phpactor provides more generators than it did about four years ago.

image

Usage from Neovim:
https://github.com/przepompownia/nvim-arctgx/blob/f2c65759b36ca036d740b540ef0bde508c2166f8/lua/arctgx/lsp/serverConfigs/phpactor.lua#L5-L74

@dantleech
Copy link
Collaborator

There's a code action for creating new classes? What's the use case here?

@przepompownia
Copy link
Contributor Author

No, there is LSP command create_class used in the client-side example.

@przepompownia
Copy link
Contributor Author

class CreateClassCommand implements Command
{
public const NAME = 'create_class';

@dantleech
Copy link
Collaborator

there is a code action to create classes. create an empty file and invoke code actions on it. You will get to select from the variants

@przepompownia
Copy link
Contributor Author

I found CreateClassProvider. Is that what you had in mind? It turns out that I use both ways to create new class depending on the situation.

Stubbornly, I probably can change the client code to create empty buffer and call the mentioned code action from it (maybe the code will become much simpler) but what do we need CreateClassCommand for?

@przepompownia
Copy link
Contributor Author

I see: CreateClassCommand is simply used by CreateClassProvider.

@przepompownia
Copy link
Contributor Author

Probably my direct call to create_class comes from some documentation snippet that is no longer available but I cannot find any trace of it. It seems that there is no sense to add off-spec query to support the way that can duplicate some built-in client behavior.

@przepompownia
Copy link
Contributor Author

In practice the code action is not available just after creating document at the client side. I tried to defer execution in the client side ways (autocommands in Neovim) but it seems that I need some information from the server about such availability.

@przepompownia
Copy link
Contributor Author

Deferring the call after textDocument/didOpen client notification seems to be enough for me.

https://github.com/przepompownia/nvim-arctgx/blob/1837299e9863b5b24360df601087de6e088ad6e7/lua/arctgx/lsp/serverConfigs/phpactor.lua#L3-L21

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

Successfully merging this pull request may close these issues.

None yet

2 participants