Skip to content

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

Closed

Description

@Skyxim

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

Activity

  1. added this to the 4.23.0.RELEASE milestone on Jun 5, 2024
  2. BoykoAlex commented on Jun 5, 2024

    @BoykoAlex
    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?

  3. Skyxim commented on Jun 5, 2024

    @Skyxim
    Author

    @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.

  4. BoykoAlex commented on Jun 5, 2024

    @BoykoAlex
    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?

  5. Skyxim commented on Jun 5, 2024

    @Skyxim
    Author

    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.

  6. BoykoAlex commented on Jun 5, 2024

    @BoykoAlex
    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?

  7. BoykoAlex commented on Jun 5, 2024

    @BoykoAlex
    Contributor

    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.

  8. Skyxim commented on Jun 5, 2024

    @Skyxim
    Author

    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

  9. BoykoAlex commented on Jun 6, 2024

    @BoykoAlex
    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)

  10. Skyxim commented on Jun 6, 2024

    @Skyxim
    Author

    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.

  11. BoykoAlex commented on Jun 6, 2024

    @BoykoAlex
    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.

  12. Skyxim commented on Jun 6, 2024

    @Skyxim
    Author

    @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.

  13. BoykoAlex commented on Jun 6, 2024

    @BoykoAlex
    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

Metadata

Metadata

Assignees

Labels

for: vscodetheme: spring-data-supporttype: bug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions