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

VSCode Spring Boot extension causes semantic token loss upon loading #1260

Closed
Skyxim opened this issue Jun 5, 2024 · 12 comments
Closed

VSCode Spring Boot extension causes semantic token loss upon loading #1260

Skyxim opened this issue Jun 5, 2024 · 12 comments
Assignees
Labels
for: vscode something that is specific for VSCode theme: spring-data-support type: bug

Comments

@Skyxim
Copy link

Skyxim commented Jun 5, 2024

Describe the bug
When using the VSCode Spring Boot extension, the extension causes semantic tokens to be lost after loading, affecting code semantic highlighting and other related features. I tried using the preview version of the Spring Boot extension, which restored most tokens, but class tokens are still missing. Restarting the Java language server restores the tokens.

To Reproduce
1. Install VSCode.
2. Install the RedHat Java extension and ensure semantic tokens are enabled.
3. Install the Spring Boot extension.
4. Completely close VSCode.
5. Reopen VSCode and load a Spring Boot project.
6. Observe that semantic tokens load correctly at first.
7. After the Spring Boot extension loads, semantic tokens are lost.

Sample
Release:
image

image

Pre-Release:
image

Snipaste_2024-06-05_17-29-55
Snipaste_2024-06-05_17-29-50

@BoykoAlex
Copy link
Contributor

@Skyxim what is wrong with the pre-release version java syntax highlighting? Can you show the diffs with spring boot tools disabled vs enabled? Are you on Windows?

@Skyxim
Copy link
Author

Skyxim commented Jun 5, 2024

@Skyxim what is wrong with the pre-release version java syntax highlighting? Can you show the diffs with spring boot tools disabled vs enabled? Are you on Windows?

The pre-release looks mostly fine, but the semantic tokens for class definitions are still missing. There might be other issues I haven’t noticed yet. My setup is VSCode on macOS, with the LSP running on a Debian 12 virtual machine. I’ve also tried using Windows with SSH remote, and the same issue persists.

@BoykoAlex
Copy link
Contributor

Hmm.. I'm on mac as well so ideally i should be able to see the same as you. The class definition token is TestDemoApplication and the colour for it seems to be green for me for in both cases (extension enabled and disabled). Is it different for you?

@Skyxim
Copy link
Author

Skyxim commented Jun 5, 2024

Hmm.. I'm on mac as well so ideally i should be able to see the same as you. The class definition token is TestDemoApplication and the colour for it seems to be green for me for in both cases (extension enabled and disabled). Is it different for you?

Sorry, the image doesn't provide an explanation. I mainly want to point out that there is no semantic token in the definition. Its color should be the same as the class used in the main function below, which is blue.

If I disable the Spring Boot plugin and restart VSCode, the Java LSP will correctly return the semantic tokens for the class definitions.

@BoykoAlex
Copy link
Contributor

I have completely removed Spring Boot Tools extension from vscode. Uninstalled and removed from ~/.vscode/extensions/ folder.

This is how vanilla Java syntax highlighting from TextMate + RedHat Java extension semantic highlighting looks like for me

Screenshot 2024-06-05 at 11 56 25

I do see SpringApplication in light blue for a bit but then when Java LS starts ad provides semantic token highlighting the colour turns into green.

Now if I disable all Java related extensions, i.e. to disable Java extension, i.e. Java LS and its semantic token provider i see only the TextMate grammar syntax highlighting which looks like:

Screenshot 2024-06-05 at 12 01 51.

How does this look like for you?

@BoykoAlex
Copy link
Contributor

BoykoAlex commented Jun 5, 2024

Do you have any extensions installed beyond the standard Java Extension Pack?

I don't see semantic token type: class when hover over SpringApplication for example.

I see this:

Screenshot 2024-06-05 at 12 23 05

This is VSCode + Java Extension Pack - no Spring extensions of any kind.

I suspect that you have another extension trying to enhance Java syntax highlighting. Multiple semantic token providers for the same language don't work well together.

@Skyxim
Copy link
Author

Skyxim commented Jun 5, 2024

Do you have any extensions installed beyond the standard Java Extension Pack?

  • Spring Boot Application Development Extension Pack

  • Java Extension Pack

I have only installed these two extensions for Spring Boot development.

My issue depends on whether the Spring Boot Tools is enabled. Once it is enabled and loaded, the problem occurs.

Disable Spring Boot Extension Pack:
image

Enable Spring Boot Extension Pack:
image

@BoykoAlex
Copy link
Contributor

Aa a workaround you could try disabling JPQL support via settings (with the pre-release version)
Screenshot 2024-06-05 at 21 41 00

Might be a better option than disabling the Boot extension.

The hover has:
foreground User settings: class - #339cf

So there must be something overriding the vanilla Java semantic tokens setup. How does your settings.json look like? (The user settings)

@Skyxim
Copy link
Author

Skyxim commented Jun 6, 2024

Aa a workaround you could try disabling JPQL support via settings (with the pre-release version)

Thank you for the suggestion. I tried it, but it didn’t work.

foreground User settings: class - #339cf

This is the color I set for the class. I expect the class definitions to match the color I’ve set. But due to the loss of semantic tokens, it falls back to a default value.

@BoykoAlex
Copy link
Contributor

@Skyxim can you please try installing spring-boot extension VSIX from https://cdn.spring.io/spring-tools/snapshot/STS4/nightly-distributions.html
Look for Spring Boot Language Server VSIX at the bottom of the page. Anything after timestamp 202406060451 (not including it) should be okay to try.

@Skyxim
Copy link
Author

Skyxim commented Jun 6, 2024

@Skyxim can you please try installing spring-boot extension VSIX from https://cdn.spring.io/spring-tools/snapshot/STS4/nightly-distributions.html Look for Spring Boot Language Server VSIX at the bottom of the page. Anything after timestamp 202406060451 (not including it) should be okay to try.

The semantic token for class declarations are now returning normally. Thank you for your contribution.

@BoykoAlex
Copy link
Contributor

Fixed with 64dc2d0 and a setting as well to switch back to java original semantic tokens d2373fb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: vscode something that is specific for VSCode theme: spring-data-support type: bug
Projects
None yet
Development

No branches or pull requests

3 participants