rubychan / coderay

Fast and easy syntax highlighting for selected languages, written in Ruby.
http://coderay.rubychan.de/
Other
847 stars 115 forks source link

java: support for special type 'var' #229

Closed dfa1 closed 5 years ago

dfa1 commented 6 years ago

Hello,

it would be nice to support the new Java type inference "var". According to the spec [1] "var" is not a keyword but rather a special type identifier.

This is why I added var to TYPES rather than to KEYWORDS.

[1] see section "3.9" of The Java Language Specification, Java SE 11 Edition (https://docs.oracle.com/javase/specs/jls/se11/html/jls-3.html#jls-3.9)

korny commented 5 years ago

Maybe I was to quick here: It seems var is used as an identifier in the example files on https://github.com/rubychan/coderay-scanner-tests, for example https://raw.githubusercontent.com/rubychan/coderay-scanner-tests/master/java/jruby.in.java:

    public static IRubyObject trace_var(…) {
        …
        String var = args.length > 1 ? args[0].toString() : null;

Here, highlighting var as a type seems wrong. CodeRay can't know which version of Java the code is targeting, so it might be better to leave this word alone.