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

Code refactor actions are disabled in CDT LSP editor #386

Open
emaayan opened this issue Dec 15, 2024 · 13 comments
Open

Code refactor actions are disabled in CDT LSP editor #386

emaayan opened this issue Dec 15, 2024 · 13 comments

Comments

@emaayan
Copy link

emaayan commented Dec 15, 2024

when using the LSP editor code refactor such as extract to method are disabled
image

OTOH opening them via the standard CDT editor they show up
image
this the version stack i'm using
image

@jonahgraham
Copy link
Member

I think there are multiple (very connected) bugs here:

  1. The legacy C/C++ Editor's actions are displayed (correctly disabled, bug confusingly) when in the C/C++ perspective. Opening a Java file has the same issue:

image

  1. The LSP provided refactorings aren't being exposed to the user in the same way as previous flows. AFAICT LSP4E doesn't contribute to the top-level Refactor menu. That probably needs to be raised in https://github.com/eclipse-lsp4e/lsp4e - or is CDT LSP expected to add such contributions. For example, rename is in the context-menu Refactoring submenu, but the Code Actions submenu has some of the items we are used to seeing in the Refactor menu (like extract expression)

The CDT actions are retargettable, so theoretically CDT LSP could add the new targets.

Not sure what the preexisting thoughts in this area are. @ghentschke is this an area that has already been discussed?

@emaayan
Copy link
Author

emaayan commented Dec 16, 2024

I think there are multiple (very connected) bugs here:

  1. The legacy C/C++ Editor's actions are displayed (correctly disabled, bug confusingly) when in the C/C++ perspective. Opening a Java file has the same issue:

image

  1. The LSP provided refactorings aren't being exposed to the user in the same way as previous flows. AFAICT LSP4E doesn't contribute to the top-level Refactor menu. That probably needs to be raised in eclipse-lsp4e/lsp4e - or is CDT LSP expected to add such contributions. For example, rename is in the context-menu Refactoring submenu, but the Code Actions submenu has some of the items we are used to seeing in the Refactor menu (like extract expression)

The CDT actions are retargettable, so theoretically CDT LSP could add the new targets.

Not sure what the preexisting thoughts in this area are. @ghentschke is this an area that has already been discussed?

not seeing any code actions in LSP editor..
image

@ghentschke
Copy link
Contributor

ghentschke commented Dec 16, 2024

Not sure what the preexisting thoughts in this area are. @ghentschke is this an area that has already been discussed?

No, we haven't discussed this issue yet (AFAIK).

The CDT actions are retargettable, so theoretically CDT LSP could add the new targets.

That seems a good solution to me.

@ghentschke
Copy link
Contributor

ghentschke commented Dec 16, 2024

not seeing any code actions in LSP editor..

The code actions proposals depend on the selected code. Clangd decides if a refactoring can be made:
image

@emaayan
Copy link
Author

emaayan commented Dec 16, 2024

not seeing any code actions in LSP editor..

The code actions proposals depend on the selected code. Clangd decides if a refactoring can be made: image

that's that i thought but no matter what selection i chose i see no code actions.

image

@jonahgraham
Copy link
Member

There are some code actions, for example:

image

We are reliant on the Code Actions that clangd provides here, and AFAICT clangd don't document them well. For example, when clangd 15 was released there were some entries in their release notes and the design walk through references the code from the docs, but that is not user docs.

@emaayan
Copy link
Author

emaayan commented Dec 17, 2024

There are some code actions, for example:

image

We are reliant on the Code Actions that clangd provides here, and AFAICT clangd don't document them well. For example, when clangd 15 was released there were some entries in their release notes and the design walk through references the code from the docs, but that is not user docs.

thanks, i've finally managed to get this particular one appear , but it does seem very limited.

@jonahgraham
Copy link
Member

thanks, i've finally managed to get this particular one appear , but it does seem very limited.

Glad to hear that you got something working - the clangd is still more limited in that regard. In the distant past a lot of refactorings (and Codan checks) in CDT were contributed by university students as part of their master's degrees. We are relying on the clangd ecosystem here, so this is perhaps a third item for my list for the multiple bugs. This one however is best reported to clangd itself.

@emaayan
Copy link
Author

emaayan commented Dec 20, 2024

thanks, i've finally managed to get this particular one appear , but it does seem very limited.

Glad to hear that you got something working - the clangd is still more limited in that regard. In the distant past a lot of refactorings (and Codan checks) in CDT were contributed by university students as part of their master's degrees. We are relying on the clangd ecosystem here, so this is perhaps a third item for my list for the multiple bugs. This one however is best reported to clangd itself.

i'm not sure exactly what i would be reporting on as the effects are only seen on eclipse.
this whole started as i am using espressif-IDE which recently moved to LSP https://developer.espressif.com/blog/espressif-ide-lsp-support/ because they support newer C standards, and that took away refactoring, so now i need to workup a strange process where i "re-open" the source in the legacy editor, do my refactor and get back to the original LSP editor.

@jonahgraham
Copy link
Member

i'm not sure exactly what i would be reporting on as the effects are only seen on eclipse.

clangd is the "provider" of refactorings going forward, but...

this whole started as i am using espressif-IDE which recently moved to LSP

... as you are using a commercial product then in the first instance contacting them makes sense. For example, if you don't need newer C++ standards for your coding, then always using the legacy editor makes sense to me.

cc: @kolipakakondal

@emaayan
Copy link
Author

emaayan commented Dec 28, 2024

it's not a product it's just a plugin , you download individually, or download the eclipse bundles with it. it's just how i noticed it in the first place.

@jonahgraham
Copy link
Member

Thanks for the clarification and the feedback. I hope that as we migrate to clangd based flows future development effort into things like refactoring go to the correct place. As for "product", I meant it was a product in the sense that that Espressif, a company, makes it available and should be supporting their users (you). I tagged @kolipakakondal from their team so they can weigh in on what they expect their users to do in this situation. Espressif are leading the way in that they are one of the first companies to make an Eclipse product based on cdt-lsp available to their users. I do expect that will need future refinement contributed to the open source by Espressif and other interested parties.

@emaayan
Copy link
Author

emaayan commented Dec 28, 2024 via email

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

No branches or pull requests

3 participants