Issue #13279: Support JDK 20 preview language features#13291
Issue #13279: Support JDK 20 preview language features#13291romani merged 1 commit intocheckstyle:masterfrom
Conversation
a10470b to
a5972c3
Compare
| if (forInitAST == null) { | ||
| if (!skipEnhancedForLoopVariable) { | ||
| final Deque<String> currentVariables = getCurrentVariables(); | ||
| if (!skipEnhancedForLoopVariable && !currentVariables.isEmpty()) { |
There was a problem hiding this comment.
Had to guard Deque#pop to avoid NoSuchElementException.
| * @param paramDef a for-each clause variable | ||
| */ | ||
| private void leaveForEach(DetailAST paramDef) { | ||
| final DetailAST paramName = paramDef.findFirstToken(TokenTypes.IDENT); |
There was a problem hiding this comment.
We were throwing a NPE here, so I fixed it in this PR.
| | | | |--FOR_EACH_CLAUSE -> FOR_EACH_CLAUSE [32:17] | ||
| | | | | |--RECORD_PATTERN_DEF -> RECORD_PATTERN_DEF [32:17] | ||
| | | | | | |--MODIFIERS -> MODIFIERS [32:17] | ||
| | | | | | |--TYPE -> TYPE [32:17] | ||
| | | | | | | `--IDENT -> Point [32:17] | ||
| | | | | | |--LPAREN -> ( [32:22] | ||
| | | | | | |--RECORD_PATTERN_COMPONENTS -> RECORD_PATTERN_COMPONENTS [32:23] | ||
| | | | | | | |--PATTERN_VARIABLE_DEF -> PATTERN_VARIABLE_DEF [32:23] | ||
| | | | | | | | |--MODIFIERS -> MODIFIERS [32:23] | ||
| | | | | | | | | `--FINAL -> final [32:23] | ||
| | | | | | | | |--TYPE -> TYPE [32:29] | ||
| | | | | | | | | `--IDENT -> var [32:29] | ||
| | | | | | | | `--IDENT -> x [32:33] | ||
| | | | | | | |--COMMA -> , [32:34] | ||
| | | | | | | `--PATTERN_VARIABLE_DEF -> PATTERN_VARIABLE_DEF [32:36] | ||
| | | | | | | |--MODIFIERS -> MODIFIERS [32:36] | ||
| | | | | | | | `--FINAL -> final [32:36] | ||
| | | | | | | |--TYPE -> TYPE [32:42] | ||
| | | | | | | | `--IDENT -> var [32:42] | ||
| | | | | | | `--IDENT -> y [32:46] | ||
| | | | | | `--RPAREN -> ) [32:47] | ||
| | | | | |--COLON -> : [32:49] | ||
| | | | | `--EXPR -> EXPR [32:51] | ||
| | | | | `--IDENT -> points1 [32:51] |
There was a problem hiding this comment.
Example of basic record component decomposition in enhanced for loop:
for (Point(final var x, final var y) : points1) {
}
...awl/tools/checkstyle/grammar/java20/InputJava20RecordDecompositionEnhancedForLoopTricky.java
Outdated
Show resolved
Hide resolved
545212a to
417e426
Compare
1b16d33 to
bf0e0a9
Compare
|
Moving this back to draft, I want to double check some things at https://docs.oracle.com/javase/specs/jls/se20/preview/specs/patterns-switch-record-patterns-jls.html Ok, I wanted to double check the switch grammar because it is not specified in the JEP (though they mention it has changed). Here it is from the JLS SE 20 preview: This is from the JLS SE 19 preview: So, this was just a simplification/ clean up of the existing grammar. This does not really have any impact on us; our grammar kind of falls between the two and I am OK with this. |
|
@romani @rnveach ok, I have resolved my doubts, see conclusion of investigation at #13291 (comment) |
Closes #13279
Check Regression Reports
https://nrmancuso.github.io/reports/issue-13279/2023-07-20-T-17-39-42/sevntu-check-regression_part_1-report/index.html - no diff
https://nrmancuso.github.io/reports/issue-13279/2023-07-20-T-17-39-42/part4-report/index.html - no dif
https://nrmancuso.github.io/reports/issue-13279/2023-07-20-T-17-39-42/part2-report/index.html - no diff
https://nrmancuso.github.io/reports/issue-13279/2023-07-20-T-17-39-42/part3-report/index.html - no diff
https://nrmancuso.github.io/reports/issue-13279/2023-07-20-T-17-39-42/part5-report/index.html - no diff
https://nrmancuso.github.io/reports/issue-13279/2023-07-20-T-17-39-42/part6-report/index.html - no diff
https://nrmancuso.github.io/reports/issue-13279/2023-07-20-T-17-39-42/part1-report/index.html - no diff
https://nrmancuso.github.io/reports/issue-13279/2023-07-20-T-17-39-42/sevntu-check-regression_part_2-report/index.html - no diff
ANTLR regression reports
https://nrmancuso.github.io/reports/issue-13279/2023-07-21-T-06-50-01/antlr-report/index.html