Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #10978: Record inside interface is parsed as method
- Loading branch information
Showing
6 changed files
with
212 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...crawl/tools/checkstyle/checks/naming/methodname/InputMethodNameRecordInInterfaceBody.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
MethodName | ||
format = (default)^[a-z][a-zA-Z0-9]*$ | ||
allowClassName = (default)false | ||
applyToPublic = (default)true | ||
applyToProtected = (default)true | ||
applyToPackage = (default)true | ||
applyToPrivate = (default)true | ||
*/ | ||
|
||
//non-compiled with javac: Compilable with Java14 | ||
package com.puppycrawl.tools.checkstyle.checks.naming.methodname; | ||
|
||
public interface InputMethodNameRecordInInterfaceBody { | ||
int record = 1; | ||
static record MyRedundantStaticRecord() {} | ||
record MyRecord1(){} | ||
record MyRecord2(int x, int y, int z){} | ||
record MyRecord3(int[][] x, String... z){ | ||
String record() { // ok | ||
return null; | ||
} | ||
void VIOLATION() { // violation | ||
|
||
} | ||
} | ||
default void record(int x, int y, int z) {} | ||
} |
15 changes: 15 additions & 0 deletions
15
...uppycrawl/tools/checkstyle/grammar/antlr4/InputAntlr4AstRegressionInterfaceRecordDef.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//non-compiled with javac: Compilable with Java14 | ||
package com.puppycrawl.tools.checkstyle.grammar.antlr4; | ||
|
||
public interface InputAntlr4AstRegressionInterfaceRecordDef { | ||
int record = 1; | ||
static record MyRedundantStaticRecord() {} | ||
record MyRecord1(){} | ||
record MyRecord2(int x, int y, int z){} | ||
record MyRecord3(int[][] x, String... z){ | ||
String record(){ | ||
return null; | ||
} | ||
} | ||
default void record(int x, int y, int z) {} | ||
} |
148 changes: 148 additions & 0 deletions
148
...puppycrawl/tools/checkstyle/grammar/antlr4/InputAntlr4AstRegressionInterfaceRecordDef.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
COMPILATION_UNIT -> COMPILATION_UNIT [2:0] | ||
|--PACKAGE_DEF -> package [2:0] | ||
| |--ANNOTATIONS -> ANNOTATIONS [2:47] | ||
| |--DOT -> . [2:47] | ||
| | |--DOT -> . [2:39] | ||
| | | |--DOT -> . [2:28] | ||
| | | | |--DOT -> . [2:22] | ||
| | | | | |--DOT -> . [2:11] | ||
| | | | | | |--IDENT -> com [2:8] | ||
| | | | | | `--IDENT -> puppycrawl [2:12] | ||
| | | | | `--IDENT -> tools [2:23] | ||
| | | | `--IDENT -> checkstyle [2:29] | ||
| | | `--IDENT -> grammar [2:40] | ||
| | `--IDENT -> antlr4 [2:48] | ||
| `--SEMI -> ; [2:54] | ||
`--INTERFACE_DEF -> INTERFACE_DEF [4:0] | ||
|--MODIFIERS -> MODIFIERS [4:0] | ||
| `--LITERAL_PUBLIC -> public [4:0] | ||
|--LITERAL_INTERFACE -> interface [4:7] | ||
|--IDENT -> InputAntlr4AstRegressionInterfaceRecordDef [4:17] | ||
`--OBJBLOCK -> OBJBLOCK [4:60] | ||
|--LCURLY -> { [4:60] | ||
|--VARIABLE_DEF -> VARIABLE_DEF [5:4] | ||
| |--MODIFIERS -> MODIFIERS [5:4] | ||
| |--TYPE -> TYPE [5:4] | ||
| | `--LITERAL_INT -> int [5:4] | ||
| |--IDENT -> record [5:8] | ||
| |--ASSIGN -> = [5:15] | ||
| | `--EXPR -> EXPR [5:17] | ||
| | `--NUM_INT -> 1 [5:17] | ||
| `--SEMI -> ; [5:18] | ||
|--RECORD_DEF -> RECORD_DEF [6:4] | ||
| |--MODIFIERS -> MODIFIERS [6:4] | ||
| | `--LITERAL_STATIC -> static [6:4] | ||
| |--LITERAL_RECORD -> record [6:11] | ||
| |--IDENT -> MyRedundantStaticRecord [6:18] | ||
| |--LPAREN -> ( [6:41] | ||
| |--RECORD_COMPONENTS -> RECORD_COMPONENTS [6:42] | ||
| |--RPAREN -> ) [6:42] | ||
| `--OBJBLOCK -> OBJBLOCK [6:44] | ||
| |--LCURLY -> { [6:44] | ||
| `--RCURLY -> } [6:45] | ||
|--RECORD_DEF -> RECORD_DEF [7:4] | ||
| |--MODIFIERS -> MODIFIERS [7:4] | ||
| |--LITERAL_RECORD -> record [7:4] | ||
| |--IDENT -> MyRecord1 [7:11] | ||
| |--LPAREN -> ( [7:20] | ||
| |--RECORD_COMPONENTS -> RECORD_COMPONENTS [7:21] | ||
| |--RPAREN -> ) [7:21] | ||
| `--OBJBLOCK -> OBJBLOCK [7:22] | ||
| |--LCURLY -> { [7:22] | ||
| `--RCURLY -> } [7:23] | ||
|--RECORD_DEF -> RECORD_DEF [8:4] | ||
| |--MODIFIERS -> MODIFIERS [8:4] | ||
| |--LITERAL_RECORD -> record [8:4] | ||
| |--IDENT -> MyRecord2 [8:11] | ||
| |--LPAREN -> ( [8:20] | ||
| |--RECORD_COMPONENTS -> RECORD_COMPONENTS [8:21] | ||
| | |--RECORD_COMPONENT_DEF -> RECORD_COMPONENT_DEF [8:21] | ||
| | | |--ANNOTATIONS -> ANNOTATIONS [8:21] | ||
| | | |--TYPE -> TYPE [8:21] | ||
| | | | `--LITERAL_INT -> int [8:21] | ||
| | | `--IDENT -> x [8:25] | ||
| | |--COMMA -> , [8:26] | ||
| | |--RECORD_COMPONENT_DEF -> RECORD_COMPONENT_DEF [8:28] | ||
| | | |--ANNOTATIONS -> ANNOTATIONS [8:28] | ||
| | | |--TYPE -> TYPE [8:28] | ||
| | | | `--LITERAL_INT -> int [8:28] | ||
| | | `--IDENT -> y [8:32] | ||
| | |--COMMA -> , [8:33] | ||
| | `--RECORD_COMPONENT_DEF -> RECORD_COMPONENT_DEF [8:35] | ||
| | |--ANNOTATIONS -> ANNOTATIONS [8:35] | ||
| | |--TYPE -> TYPE [8:35] | ||
| | | `--LITERAL_INT -> int [8:35] | ||
| | `--IDENT -> z [8:39] | ||
| |--RPAREN -> ) [8:40] | ||
| `--OBJBLOCK -> OBJBLOCK [8:41] | ||
| |--LCURLY -> { [8:41] | ||
| `--RCURLY -> } [8:42] | ||
|--RECORD_DEF -> RECORD_DEF [9:4] | ||
| |--MODIFIERS -> MODIFIERS [9:4] | ||
| |--LITERAL_RECORD -> record [9:4] | ||
| |--IDENT -> MyRecord3 [9:11] | ||
| |--LPAREN -> ( [9:20] | ||
| |--RECORD_COMPONENTS -> RECORD_COMPONENTS [9:21] | ||
| | |--RECORD_COMPONENT_DEF -> RECORD_COMPONENT_DEF [9:21] | ||
| | | |--ANNOTATIONS -> ANNOTATIONS [9:21] | ||
| | | |--TYPE -> TYPE [9:21] | ||
| | | | |--LITERAL_INT -> int [9:21] | ||
| | | | |--ARRAY_DECLARATOR -> [ [9:24] | ||
| | | | | `--RBRACK -> ] [9:25] | ||
| | | | `--ARRAY_DECLARATOR -> [ [9:26] | ||
| | | | `--RBRACK -> ] [9:27] | ||
| | | `--IDENT -> x [9:29] | ||
| | |--COMMA -> , [9:30] | ||
| | `--RECORD_COMPONENT_DEF -> RECORD_COMPONENT_DEF [9:32] | ||
| | |--ANNOTATIONS -> ANNOTATIONS [9:32] | ||
| | |--TYPE -> TYPE [9:32] | ||
| | | `--IDENT -> String [9:32] | ||
| | |--ELLIPSIS -> ... [9:38] | ||
| | `--IDENT -> z [9:42] | ||
| |--RPAREN -> ) [9:43] | ||
| `--OBJBLOCK -> OBJBLOCK [9:44] | ||
| |--LCURLY -> { [9:44] | ||
| |--METHOD_DEF -> METHOD_DEF [10:8] | ||
| | |--MODIFIERS -> MODIFIERS [10:8] | ||
| | |--TYPE -> TYPE [10:8] | ||
| | | `--IDENT -> String [10:8] | ||
| | |--IDENT -> record [10:15] | ||
| | |--LPAREN -> ( [10:21] | ||
| | |--PARAMETERS -> PARAMETERS [10:22] | ||
| | |--RPAREN -> ) [10:22] | ||
| | `--SLIST -> { [10:23] | ||
| | |--LITERAL_RETURN -> return [11:12] | ||
| | | |--EXPR -> EXPR [11:19] | ||
| | | | `--LITERAL_NULL -> null [11:19] | ||
| | | `--SEMI -> ; [11:23] | ||
| | `--RCURLY -> } [12:8] | ||
| `--RCURLY -> } [13:4] | ||
|--METHOD_DEF -> METHOD_DEF [14:4] | ||
| |--MODIFIERS -> MODIFIERS [14:4] | ||
| | `--LITERAL_DEFAULT -> default [14:4] | ||
| |--TYPE -> TYPE [14:12] | ||
| | `--LITERAL_VOID -> void [14:12] | ||
| |--IDENT -> record [14:17] | ||
| |--LPAREN -> ( [14:23] | ||
| |--PARAMETERS -> PARAMETERS [14:24] | ||
| | |--PARAMETER_DEF -> PARAMETER_DEF [14:24] | ||
| | | |--MODIFIERS -> MODIFIERS [14:24] | ||
| | | |--TYPE -> TYPE [14:24] | ||
| | | | `--LITERAL_INT -> int [14:24] | ||
| | | `--IDENT -> x [14:28] | ||
| | |--COMMA -> , [14:29] | ||
| | |--PARAMETER_DEF -> PARAMETER_DEF [14:31] | ||
| | | |--MODIFIERS -> MODIFIERS [14:31] | ||
| | | |--TYPE -> TYPE [14:31] | ||
| | | | `--LITERAL_INT -> int [14:31] | ||
| | | `--IDENT -> y [14:35] | ||
| | |--COMMA -> , [14:36] | ||
| | `--PARAMETER_DEF -> PARAMETER_DEF [14:38] | ||
| | |--MODIFIERS -> MODIFIERS [14:38] | ||
| | |--TYPE -> TYPE [14:38] | ||
| | | `--LITERAL_INT -> int [14:38] | ||
| | `--IDENT -> z [14:42] | ||
| |--RPAREN -> ) [14:43] | ||
| `--SLIST -> { [14:45] | ||
| `--RCURLY -> } [14:46] | ||
`--RCURLY -> } [15:0] |