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 var keyword not highlighted #3854

Open
philiprbrenan opened this issue Apr 23, 2024 · 4 comments
Open

Java var keyword not highlighted #3854

philiprbrenan opened this issue Apr 23, 2024 · 4 comments

Comments

@philiprbrenan
Copy link

Please could Geany highlight the var keyword in Java?

Var

@elextr
Copy link
Member

elextr commented Apr 24, 2024

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.

@b4n
Copy link
Member

b4n commented Apr 24, 2024

@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
Copy link
Member

b4n commented Apr 24, 2024

I don't understand your image:

1. it does not use `var`

There is on line 3 😉

@elextr
Copy link
Member

elextr commented Apr 24, 2024

@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"; 😁

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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants