-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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) Can't match nested generic type identifier #2641
Comments
You probably wouldn't you've solve it with a nested recursive rule instead using "self" in our grammars. But we'd need a lot more examples, are the types always so simple as simple strings or can you use |
Apart from annotations, wild card types, type parameter list, and exceptions list are also not taken care of, for example: public static <A,B,C> Tuple<A,B,C> fun(Future<Tuple<A,B,C>> future) throws Exceptions {
} The first |
Are these things only used in function definitions? |
These may appear in class definitions too, but the class definition can determine by keywords According to the java method name convention, Type name should start with a capital letter,and the return type of a method should be one of as follows:
In Addition, maybe we just need to distinguish the method from class and filed. Field definition should end with |
These can occur in simple variable declarations too: Map<String, List<String>> stringListMap = new HashMap<String, List<String>();
// or
Map<String, List<String>> stringListMap = new HashMap<>()
// and can involve generic types that will happily break your regex:
Map<K, List<T>> myThing; |
👍 |
Regarding the Firstly, each of the 3 Secondly, the regex isn't correct. We use this pattern for Prism. Adopted to your approach, we get: |
Yeah I assumed I'd run into that and need to reduce the potential overlap. Thanks for the pointing out the edge case with a list though. :) |
Describe the issue
Can't match nested generic type identifier such as:
List<Atomic<Integer>>
. This will lead to a method that can't be matched correctly.Which language seems to have the issue?
Java
Are you using
highlight
orhighlightAuto
?highlightAuto
Sample Code to Reproduce
https://jsfiddle.net/tx5jLs2a/8/
Expected behavior
The method should be recognized as a
hljs-function
, not ahljs-keyword
.Additional context
The code at the 3rd row of languages/java.js:
It doesn't handle nested angle bracket, and I don't know how to solve recursive match by regular expression of javascript either;
The text was updated successfully, but these errors were encountered: