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

[BUG] In VSCode, the java code highlighting is disabled under lombok annotation #2950

Closed
Ranger-118 opened this issue Sep 7, 2021 · 9 comments · Fixed by #2978
Closed

[BUG] In VSCode, the java code highlighting is disabled under lombok annotation #2950

Ranger-118 opened this issue Sep 7, 2021 · 9 comments · Fixed by #2978
Assignees
Milestone

Comments

@Ranger-118
Copy link

Describe the bug
VSCode has an initialized highlighting style for any java file code and a default highlighting style for the compiled java code, when I use the lombok annotation for the current class, the compiled code highlighting was disabled under the annotation.

To Reproduce
Open the Spring boot project in VSCode, and add any lombok annotation to the class containing any methods.

1
2

Expected behavior
Expect that the lombok annotation doesn't impact the code highlighting under the annotation in VSCode

Version info (please complete the following information):

  • Lombok version 1.18.20
  • Platform (javac 11.0.10 with VSCode).

Additional context
N/A

@Rawi01
Copy link
Collaborator

Rawi01 commented Sep 7, 2021

As far as I know VSCode uses the the eclipse JDT language server for highlighting. In eclipse syntax highlighting problems like this one occur if the generated lombok code uses wrong source positions. These problems are really hard to debug because even the smallest change in a file might fix the problem. I just installed the latest VSCode and it works for me.

Can you share this project or at least some code that I can use to reproduce the issue?

@Ranger-118
Copy link
Author

Ranger-118 commented Sep 8, 2021

As far as I know VSCode uses the the eclipse JDT language server for highlighting. In eclipse syntax highlighting problems like this one occur if the generated lombok code uses wrong source positions. These problems are really hard to debug because even the smallest change in a file might fix the problem. I just installed the latest VSCode and it works for me.

Can you share this project or at least some code that I can use to reproduce the issue?

Indeed, Eclipse can also reproduce the issue.
Please check https://github.com/Ranger-118/shorten-demo.git for reference.
I don't know other environment behavior, this is a general issue happens to me in diffferent machines. Thanks for your prompt response too.
Feel free to add the lombok annotation to any class with methods.

@Rawi01
Copy link
Collaborator

Rawi01 commented Sep 9, 2021

Thanks, I was able to reproduce the issue and also found a hacky solution to fix it. I also noticed that the javadoc copy stuff doesn't work in VSCode.

@Rawi01 Rawi01 self-assigned this Sep 9, 2021
@Ranger-118
Copy link
Author

Yes, the javadoc issue happens from time to time. And if you are able to, would you mind sharing the hacking way so that I can solve it within the existing versions?

@Rawi01
Copy link
Collaborator

Rawi01 commented Sep 28, 2021

@Ranger-118 Sorry for the delay, I created a PR and uploaded a pre-built version for you to test it. To use this version you have to disable the VSCode lombok plugin and add -javaagent:\"/path/to/lombok.jar\"" to "java.jdt.ls.vmargs" in your settings.json (Ctrl+Shift+P -> Open Settings (JSON)).

@rzwitserloot
Copy link
Collaborator

In my eclipse I get highlighting issues from time to time. Going off of gut and vague recollections, @SneakyThrows and @Cleanup are usually present when it happens.

@Rawi01 Can you provide me the contact info of your tailor? The wizard hat you pulled this rabbit out of is amazing. Are you running vscode inside a debugger, or running vscode's language server in one to figure this one out?

@Ranger-118
Copy link
Author

@Ranger-118 Sorry for the delay, I created a PR and uploaded a pre-built version for you to test it. To use this version you have to disable the VSCode lombok plugin and add -javaagent:\"/path/to/lombok.jar\"" to "java.jdt.ls.vmargs" in your settings.json (Ctrl+Shift+P -> Open Settings (JSON)).

Test all good, thank you!

@Rawi01
Copy link
Collaborator

Rawi01 commented Sep 29, 2021

@rzwitserloot 😄 I only debug the language server. I figured out how it works by looking at the lombok plugin which had to add the -javaagent parameter to the vm args. Thats the same place where you can also add the debug flags. You also have to use the Standard mode to force VSCode to only start one server and use the debug quiet mode.

So basicaly just add -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,quiet=y,address=12013 to the settings.json and set "java.server.launchMode" to "Standard" and you can attach a remote debugger. It was also useful to activate the language server debug mode.

@Ranger-118
Copy link
Author

@Rawi01 I found that the issue still happens with @SneakyThrows and maybe also @Cleanup, is there another built for this?

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

Successfully merging a pull request may close this issue.

3 participants