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

Add support for text editor actions "go to next annotation" & "go to previous annotation" #248

Closed
travkin79 opened this issue Feb 6, 2024 · 10 comments

Comments

@travkin79
Copy link
Contributor

travkin79 commented Feb 6, 2024

Editors like CDT's C++ editor and JDT's Java editor have support for the tool bar actions "next annotation" & "previous annotation" for navigating to the next / previous occurrence of a symbol / identifier (see action bar buttons).
image
These buttons are also activated for the LSP-based C++ editor, but nothing happens if you push them. It would be great if that could be fixed.

@travkin79
Copy link
Contributor Author

travkin79 commented Feb 6, 2024

I investigated a little. It turns out, since CDT LSP uses the org.eclipse.ui.editors.text.TextEditorActionContributor in its editor, the pre-defined action org.eclipse.ui.texteditor.GotoAnnotationAction is used and calls org.eclipse.ui.texteditor.AbstractTextEditor#gotoAnnotation(boolean), but that method call does not find any annotation.

CDT uses some kind of Job for updating the annotation model and available occurrences depending on the current selection (org.eclipse.cdt.internal.ui.editor.CEditor#updateOccurrenceAnnotations(ITextSelection, IASTTranslationUnit)). It seems, CDT LSP needs something similar.

Since the GotoAnnotationAction seems to be quite generic, I'm wondering if this is to be implemented in CDT LSP or in LSP4E. Any thoughts on this @ghentschke and @jonahgraham?

@ghentschke
Copy link
Contributor

Since the GotoAnnotationAction seems to be quite generic, I'm wondering if this is to be implemented in CDT LSP or in LSP4E.

CDT-LSP has not implemented anything here (yet). I've to check what LSP4E can do for us.

@ghentschke
Copy link
Contributor

ghentschke commented Feb 6, 2024

They work for breakpoints, markers, and the not-yet-merged spelling support.

@travkin79
Copy link
Contributor Author

Hello @ghentschke,
Do you have any tips on what needs to be done to also support identifiers? I'm thinking about preparing a PR for that.

@ghentschke
Copy link
Contributor

It seems that LSP4E already provides annotations:
image
Unfortunately is the Include in next/previous navigation checkbox disabled.

It seems that work has to be done in LSP4E here. Please check the org.eclipse.ui.editors.markerAnnotationSpecification extensions defined in the plugin.xml in the org.eclipse.lsp4e bundle.

@travkin79 it would be great if you provide a PR here!

@ghentschke
Copy link
Contributor

ghentschke commented Feb 7, 2024

When comparing the /org.eclipse.cdt.ui/plugin.xml with /org.eclipse.lsp4e/plugin.xml I've noticed that these target keys/ toolbar actions are missing in LSP4E:
image
Hope it helps.

@ghentschke
Copy link
Contributor

ghentschke commented Feb 7, 2024

It should work when these keys are defined. The Include in next/previous navigation is enabled in the annotations preferences and it's possible to jump from occurrence to occurrence.

@ghentschke
Copy link
Contributor

@travkin79 Can you please open an issue for that in LSP4E.

@travkin79
Copy link
Contributor Author

Thank you @ghentschke,
That were exactly the right hints. I just had some other problems with LSP4E. For some reason one of the test plug-ins switched off the actual LS and replaced it with a mock. So none of the LSP reconcilers were active. Now, I excluded the test plug-in from being started and can now finish the PR.

I'll close this issue since the actual issue is in LSP4E. See eclipse-lsp4e/lsp4e#909

@travkin79
Copy link
Contributor Author

Not a CDT LSP issue. See eclipse-lsp4e/lsp4e#909

@travkin79 travkin79 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2024
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

2 participants