vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

The highlight color in comments shows incorrectly after typing @category

Open yuyully opened this issue 2 years ago • 5 comments

Environment
  • Operating System: Windows
  • JDK version: 17.0.3
  • Visual Studio Code version: 1.74.3
  • Java extension version: 1.14.0
Steps To Reproduce
  1. Add a multi-line comments /* ... */
  2. Type @apiNote and @category
Current Result

image

Expected Result

image

yuyully avatar Jan 17 '23 07:01 yuyully

@testforstephen I just had a look at https://github.com/microsoft/vscode/blob/main/extensions/java/syntaxes/java.tmLanguage.json#L3-L5 . However, https://github.com/atom/language-java/ is read-only (since end of 2022). I guess it hasn't been an issue since the last change coming from there was from the start of 2021.

How would we contribute changes to the grammar if needed ? Could we do it directly in the VS Code repo ?

rgrunber avatar Jul 06 '23 15:07 rgrunber

The TextMate grammar for Java has always been a bit lacking. For the most part, the problems have been hidden away behind the semantic token-based syntax highlighting implemented in JDT LS, which uses the Java AST generated by JDT Core.

But as you can see when using the Scope Inspector, the semantic tokens for the Javadoc tags "break" when adding the @category tag. It looks like this is a bug in JDT Core, where the AST breaks if you add the @category tag. Interestingly enough, it seems to work fine if you add a word after the tag, such as @category foo, the AST is only broken if you have an @category tag with a missing word.

The bug in JDT Core can also be reproduced in the Eclipse IDE, for example using the AST View, if you look at the AST of the Javadoc comment before and after adding the @category tag.


In the end, I guess it doesn't really matter (to the end user) where we fix the issue (either in the TextMate grammar, to fix the TextMate tokens, or in JDT Core, to fix the semantic tokens). The bug in JDT Core could possibly affect other features that use the AST though.

0dinD avatar Jul 12 '23 23:07 0dinD

Yes, this is definitely an upstream issue. It seems similar in function with https://bugs.eclipse.org/bugs/show_bug.cgi?id=125676 . The @category tag seems to read beyond the end of line, treating the next token as an argument to itself.

rgrunber avatar Jul 17 '23 14:07 rgrunber

No longer an issue.

Image

fbricon avatar Oct 15 '25 10:10 fbricon

Actually still an issue if the category is empty

Image

meh

fbricon avatar Oct 15 '25 10:10 fbricon