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

Java editor syntax highlighting via extension point #1594

Open
BoykoAlex opened this issue Aug 20, 2024 · 7 comments · May be fixed by #1683
Open

Java editor syntax highlighting via extension point #1594

BoykoAlex opened this issue Aug 20, 2024 · 7 comments · May be fixed by #1683
Labels
enhancement New feature or request

Comments

@BoykoAlex
Copy link

BoykoAlex commented Aug 20, 2024

Language servers (LSP4E project) could provide semantic tokens with highlight information for Java files. These semantic tokens are primarily for languages embedded into Java. For example Spring Java code can have embedded:

These embedded languages syntax fits nicely into LSP semantic tokens feature.

Bringing in semantic highlighting for these embedded languages into JDT Java editor is a challenge because syntax highlighting in Java editor does not allow for contributions.

(cc: @martinlippert)

@martinlippert
Copy link

We implemented the necessary logic for the highlighting via semantic tokens and LSP already inside of the language server that we are building for Spring and have this feature working nicely in VSCode (e.g. https://x.com/springtools4/status/1816014400379032005), now trying to bring this to Eclipse as well. It already works out-of-the-box when using the generic editor for Java source files, but since everybody is using the real JDT UI Java source editor in Eclipse, we would love to bring this to JDT UI as well - if possible.

@BoykoAlex submitted an initial PR for this (#1595), which is more a PoC than a ready-to-merge contribution, but would be awesome to hear from you whether the team would be interested in pushing this forward. Since it involves adding new public API to JDT UI, we would love to hear your thoughts about this.

@iloveeclipse
Copy link
Member

Haven't looked in the code yet, but the idea sounds great.

@noopur2507
Copy link
Member

As I understand, this is an enhancement that will add highlighting for embedded languages in the Java editor via an extension point. Sounds good!

@martinlippert
Copy link

Sounds like the is some consensus that this would be a good thing to implement. What are the next steps? I think we (specifically @BoykoAlex ) would need some advice on the next steps, since the PR is more meant as a draft to discuss than the final implementation (as mentioned on the PR). So would someone be willing to jump on the PR and provide overall feedback on the questions at hand? I am sure @BoykoAlex would also be around for a screenshare call to get some advice, provide some overview of the PR, etc.

@martinlippert
Copy link

(and thanks to @noopur2507 , @jukzi , @iloveeclipse for your initial reactions here, much appreciated)

@BoykoAlex
Copy link
Author

Any feedback on the attached PR anyone?
I suppose my main questions are:

  1. Any wished for the extension point schema?
  2. Ideas for slow/async semantic tokens computation integration into the existing Java editor SemanticHighlightingReconciler?

Currently the PR computes contributed semantic tokens synchronously which is an obvious no go... Wonder if for example if can trigger a semantic highlight reconcile once async semantic tokens are computed? We'd need to to re-compute the sync tokens and add the already computed lazy ones on top, right? Not familiar with this code so would appreciate some guidance :-)

@BoykoAlex BoykoAlex linked a pull request Sep 28, 2024 that will close this issue
@BoykoAlex
Copy link
Author

The async approach resulted in some ugly flickering. The sync solution worked much better. I'd go with the sync solution for now. Please review the PR #1683

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

Successfully merging a pull request may close this issue.

5 participants