These are new Java 9 and Java 10 keywords.
Fixes #3854 You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/4014
-- Commit Summary --
* Java: add "exports", "module", "requires", and "var" keywords
-- File Changes --
M data/filedefs/filetypes.java (2)
-- Patch Links --
https://github.com/geany/geany/pull/4014.patch https://github.com/geany/geany/pull/4014.diff
LGBI
LGTM although there seem to be more missing keywords, even for Java 9 according to https://cr.openjdk.org/~mr/jigsaw/spec/java-se-9-jls-diffs.pdf
LGTM although there seem to be more missing keywords, even for Java 9 according to https://cr.openjdk.org/~mr/jigsaw/spec/java-se-9-jls-diffs.pdf
OK, I was lazy and followed the first link I found (https://www.w3schools.com/java/java_ref_keywords.asp).
There's possibly a bigger problem though - those "restricted keywords" like `var` are keywords only in some context so here the first `var` is the keyword, the second one isn't: ```java var var = 0; ```
So I'm actually not sure whether we should add `var` to keywords as Scintilla would then colorize both `var`s.
Well contextual keywords exist in other languages, its a method to add more keywords without forcing all existing code having to change existing names immediately because in the context where the keyword does not clash with existing names there is no issues eg [C++ has contextual keywords](https://en.cppreference.com/w/cpp/keyword) (the second table). The C++11 and C++20 keywords are in `filetypes.cpp` and yeah, it is legal for those names to be used as variable names outside the context but they will be styled wrong. That is not just Geany, other non-LSP editors have the same issue, but LSPs should be ok?
After the new keywords are standardised by a language new code created by users will mostly not use those names as variables to avoid confusion, and overtime existing code that has those as names will slowly be changed, again to avoid confusion. So for most users having the contextual keywords styled is best as over time the world will move to only using the word as a keyword.
```java var var = 0; // well "var" as the variable is pretty meaningless anyway, would be better to be a useful name var some_meaningful_var = 0; // thats better ;-) ```
To summarise, I would advise to include keywords that are defined by the language in the filetype file (any language).
I agree with @elextr, better have the keywords and the occasional mishighlighting for weird code than the other way around. So long as Scintilla doesn't have contextual keywords support it ain't gonna be perfect.
@techee pushed 1 commit.
b46ca22f173bf323eef4adafa750b56824c99c9d Java: add Java SE23 keywords
> LGTM although there seem to be more missing keywords, even for Java 9 according to https://cr.openjdk.org/~mr/jigsaw/spec/java-se-9-jls-diffs.pdf
Done. I used the keywords from here:
https://docs.oracle.com/javase/specs/jls/se23/html/jls-3.html#jls-3.9
@b4n approved this pull request.
Not that I know Java, but LGBI
Merged #4014 into master.
> Not that I know Java, but LGBI
I "know" Java but have never used any of these new keywords :-P.
Probably a tad better than me that did *write* some but didn't really knew what I was doing 😁
github-comments@lists.geany.org