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) Generic type variable not highlighted #4017

Open
amichair opened this issue Mar 15, 2024 · 7 comments
Open

(Java) Generic type variable not highlighted #4017

amichair opened this issue Mar 15, 2024 · 7 comments
Labels
bug help welcome Could use help from community language

Comments

@amichair
Copy link

Describe the issue
In a Java statement that declares and assigns a variable with a generic type, the type and variable don't get highlighted. Without the generic type they are properly highlighted.

Which language seems to have the issue?
java

Are you using highlight or highlightAuto?
highlightElement
...

Sample Code to Reproduce

Map<String, String> params = request.getParams();

Expected behavior
Without the generic type, the type (Map) and variable (params) get highlighted. They should be similarly highlighted also when the generic type is present (and the generic type itself should be highlighted as well).

Additional context
The example shows two generic types, but the issue also occurs with a single type such as List. This is the proper way of defining such collections.

@amichair amichair added bug help welcome Could use help from community language labels Mar 15, 2024
@joshgoebel
Copy link
Member

joshgoebel commented Mar 15, 2024

Are all types in Java CamelCase?

@amichair
Copy link
Author

As the example shows, types in this case are all a capitalized single words, and variables are lowercase single words.

@joshgoebel
Copy link
Member

Are all types in Java CamelCase?

The question was about Java, not your example. Are types always CamelCase in the Java language?

@amichair
Copy link
Author

Sorry, I misunderstood. By convention, types/classes are PascalCase, while variables/parameters/fields/methods are camelCase. Constructors are PascalCase because they are equal to the class name. Constants are all uppercase SNAKE_CASE. And a generic type can also be specified as a question mark, as in List<?>, and can be recursive as in List<Map<String, Integer>>, or use two special hierarchy tokens as in List<? extends Something> or List<? super Something>, though you probably don't get into such resolution for highlighting. I hope this helps...

@joshgoebel
Copy link
Member

So if we just chose to highlight every occurrence of PascalCase as title.class, where would that leave us?

@amichair
Copy link
Author

Probably ok, as long as it's not in strings or comments etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help welcome Could use help from community language
Projects
None yet
Development

No branches or pull requests

2 participants