geany icon indicating copy to clipboard operation
geany copied to clipboard

Java var keyword not highlighted

Open philiprbrenan opened this issue 1 year ago • 4 comments

Please could Geany highlight the var keyword in Java?

Var

philiprbrenan avatar Apr 23 '24 21:04 philiprbrenan

I don't understand your image:

  1. it does not use var
  2. the class Var is highlighted correctly

Oracle says var is a reserved type name, not a keyword so not sure how its meant to be highlighted.

elextr avatar Apr 24 '24 01:04 elextr

@elextr not sure where you found the info, all I can find myself is that it'd be a "contextual keyword": https://docs.oracle.com/javase/specs/jls/se21/html/jls-3.html#jls-3.9

b4n avatar Apr 24 '24 08:04 b4n

I don't understand your image:

1. it does not use `var`

There is on line 3 :wink:

b4n avatar Apr 24 '24 08:04 b4n

@b4n, the highlighted text was copied from part way down this page (about para 4). Making it a predefined typename is how "contextuality" is implemented I guess, as it is a typename it makes var i = 10; be a declaration, and act like C++ auto i = 10; but where a typename is not expected its a variable name eg var var = "var"; :grin:

As the rest of the sentence I copied says which means that existing code that uses var as a variable, method, or package name is not affected.

So with the Lexilla contextless lexer implementation those cases can't be disambiguated from var as a type, so both are correct, pick one for highlighting. [no right answer]

There is on line 3 😉

Ooops, hidden by the { [end excuse]

elextr avatar Apr 24 '24 09:04 elextr