You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/03/21 12:47:08 UTC
[groovy] 02/07: minor edits
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 70fc5024ae35a7a078bf8e47fb40d9f08b8ec15f
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Fri Mar 20 10:22:49 2020 -0500
minor edits
(cherry picked from commit 89a2dab34dd47167060254368b3d2a1443f66ea5)
---
src/antlr/GroovyLexer.g4 | 6 +-
.../groovy/parser/antlr4/SyntaxErrorTest.groovy | 399 +++++++++++----------
.../antlr4/util/ASTComparatorCategory.groovy | 92 ++---
3 files changed, 252 insertions(+), 245 deletions(-)
diff --git a/src/antlr/GroovyLexer.g4 b/src/antlr/GroovyLexer.g4
index dc3d37f..a6c7e72 100644
--- a/src/antlr/GroovyLexer.g4
+++ b/src/antlr/GroovyLexer.g4
@@ -894,7 +894,7 @@ JavaLetter
{ Character.isJavaIdentifierStart(_input.LA(-1)) }?
| // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
[\uD800-\uDBFF] [\uDC00-\uDFFF]
- { Character.isJavaIdentifierStart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1))) }?
+ { Character.isJavaIdentifierStart(Character.toCodePoint((char) _input.LA(-2), (char) _input.LA(-1))) }?
;
fragment
@@ -910,7 +910,7 @@ JavaLetterOrDigit
{ Character.isJavaIdentifierPart(_input.LA(-1)) }?
| // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
[\uD800-\uDBFF] [\uDC00-\uDFFF]
- { Character.isJavaIdentifierPart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1))) }?
+ { Character.isJavaIdentifierPart(Character.toCodePoint((char) _input.LA(-2), (char) _input.LA(-1))) }?
;
fragment
@@ -935,7 +935,7 @@ WS : ([ \t\u000C]+ | LineEscape+) -> skip
NL : LineTerminator { this.ignoreTokenInsideParens(); }
;
-// Multiple-line comments(including groovydoc comments)
+// Multiple-line comments (including groovydoc comments)
ML_COMMENT
: '/*' .*? '*/' { this.ignoreMultiLineCommentConditionally(); } -> type(NL)
;
diff --git a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
index ce37a69..6d15e98 100644
--- a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
+++ b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
@@ -20,97 +20,80 @@ package org.apache.groovy.parser.antlr4
import groovy.test.GroovyTestCase
import groovy.test.NotYetImplemented
-import org.apache.groovy.parser.antlr4.util.ASTComparatorCategory
+import groovy.transform.AutoFinal
import org.codehaus.groovy.control.CompilationUnit
import org.codehaus.groovy.control.Phases
+import static org.apache.groovy.parser.antlr4.util.ASTComparatorCategory.LOCATION_IGNORE_LIST
+
/**
* Some syntax error test cases for the new parser.
*/
+@AutoFinal
final class SyntaxErrorTest extends GroovyTestCase {
- void "test groovy core - List"() {
+ void 'test groovy core - List'() {
TestUtils.shouldFail('fail/List_01.groovy')
}
-
- void "test groovy core - Expression"() {
+
+ void 'test groovy core - Expression'() {
TestUtils.shouldFail('fail/Expression_01.groovy')
TestUtils.shouldFail('fail/Expression_02.groovy')
TestUtils.shouldFail('fail/Expression_03.groovy')
-// TestUtils.shouldFail('fail/Expression_04.groovy')
-// TestUtils.shouldFail('fail/Expression_05.groovy')
+ //TestUtils.shouldFail('fail/Expression_04.groovy')
+ //TestUtils.shouldFail('fail/Expression_05.groovy')
TestUtils.shouldFail('fail/Expression_06.groovy')
TestUtils.shouldFail('fail/Expression_07.groovy')
TestUtils.shouldFail('fail/Expression_08.groovy')
TestUtils.shouldFail('fail/Expression_09.groovy')
}
- void "test groovy core - CommandExpression"() {
+ void 'test groovy core - CommandExpression'() {
TestUtils.doRunAndShouldFail('fail/CommandExpression_01x.groovy')
}
- void "test groovy core - Switch"() {
+ void 'test groovy core - Switch'() {
TestUtils.shouldFail('fail/Switch_01.groovy')
}
@NotYetImplemented
- void "test groovy core - LocalVariableDeclaration"() {
+ void 'test groovy core - LocalVariableDeclaration'() {
TestUtils.shouldFail('fail/LocalVariableDeclaration_01.groovy')
}
- void "test groovy core - Continue"() {
+ void 'test groovy core - Continue'() {
TestUtils.doRunAndShouldFail('fail/Continue_01x.groovy')
TestUtils.doRunAndShouldFail('fail/Continue_02x.groovy')
}
- void "test groovy core - Break"() {
+ void 'test groovy core - Break'() {
TestUtils.doRunAndShouldFail('fail/Break_01x.groovy')
TestUtils.doRunAndShouldFail('fail/Break_02x.groovy')
}
- void "test groovy core - UnexpectedCharacter"() {
+ void 'test groovy core - UnexpectedCharacter 1'() {
TestUtils.doRunAndShouldFail('fail/UnexpectedCharacter_01x.groovy')
}
- /*void "test CompilerErrorTest_001.groovy"() {
- unzipScriptAndShouldFail("scripts/CompilerErrorTest_001.groovy", [])
- }
-
- void "test CompilerErrorTest_002.groovy"() {
- unzipScriptAndShouldFail("scripts/CompilerErrorTest_002.groovy", [])
- }
-
- void "test DifferencesFromJavaTest_002.groovy"() {
- unzipScriptAndShouldFail("scripts/DifferencesFromJavaTest_002.groovy", [])
- }
-
- void "test Groovy5212Bug_001.groovy"() {
- unzipScriptAndShouldFail("scripts/Groovy5212Bug_001.groovy", [])
- }
-
- void "test GStringEndTest_001.groovy"() {
- unzipScriptAndShouldFail("scripts/GStringEndTest_001.groovy", [])
- }*/
-
- void "test groovy core - ParExpression"() {
+ void 'test groovy core - ParExpression'() {
TestUtils.doRunAndShouldFail('fail/ParExpression_01x.groovy')
TestUtils.doRunAndShouldFail('fail/ParExpression_02x.groovy')
TestUtils.doRunAndShouldFail('fail/ParExpression_03x.groovy')
}
- void "test groovy core - Parentheses"() {
+ void 'test groovy core - Parentheses'() {
TestUtils.shouldFail('fail/Parentheses_01.groovy')
}
- void "test groovy core - This"() {
+ void 'test groovy core - This'() {
TestUtils.doRunAndShouldFail('fail/This_01x.groovy')
}
- void "test groovy core - Super"() {
+ void 'test groovy core - Super'() {
TestUtils.doRunAndShouldFail('fail/Super_01x.groovy')
}
- void "test groovy core - AbstractMethod"() {
+ void 'test groovy core - AbstractMethod'() {
TestUtils.doRunAndShouldFail('fail/AbstractMethod_01x.groovy')
TestUtils.doRunAndShouldFail('fail/AbstractMethod_02x.groovy')
TestUtils.doRunAndShouldFail('fail/AbstractMethod_03x.groovy')
@@ -119,22 +102,22 @@ final class SyntaxErrorTest extends GroovyTestCase {
TestUtils.doRunAndShouldFail('fail/AbstractMethod_06x.groovy')
}
- void "test groovy core - BUGs"() {
+ void 'test groovy core - BUGs'() {
TestUtils.doRunAndShouldFail('bugs/BUG-GROOVY-5318.groovy')
TestUtils.doRunAndShouldFail('bugs/BUG-GROOVY-8150.groovy')
TestUtils.doRunAndShouldFail('bugs/BUG-GROOVY-8216.groovy')
}
- void "test groovy core - DoWhile"() {
+ void 'test groovy core - DoWhile'() {
TestUtils.doRunAndShouldFail('fail/DoWhile_01x.groovy')
}
- void "test groovy core - For"() {
+ void 'test groovy core - For'() {
TestUtils.shouldFail('fail/For_01.groovy')
TestUtils.shouldFail('fail/For_02.groovy')
}
- void "test groovy core - Modifier"() {
+ void 'test groovy core - Modifier'() {
TestUtils.doRunAndShouldFail('fail/Modifier_01x.groovy')
TestUtils.doRunAndShouldFail('fail/Modifier_02x.groovy')
TestUtils.doRunAndShouldFail('fail/Modifier_03x.groovy')
@@ -143,15 +126,105 @@ final class SyntaxErrorTest extends GroovyTestCase {
TestUtils.shouldFail('fail/Modifier_07.groovy')
}
- void "test groovy core - ClassDeclaration"() {
+ void 'test groovy core - ClassDeclaration 1'() {
TestUtils.doRunAndShouldFail('fail/ClassDeclaration_02x.groovy')
}
- void "test groovy core - AnnotationDeclaration"() {
+ void 'test groovy core - ClassDeclaration 2'() {
+ def err = expectParseError '''\
+ |class C extends Object, Number {}
+ |'''.stripMargin()
+
+ assert err == '''\
+ |startup failed:
+ |test.groovy: 1: Cannot extend multiple classes @ line 1, column 9.
+ | class C extends Object, Number {}
+ | ^
+ |
+ |1 error
+ |'''.stripMargin()
+ }
+
+ void 'test groovy core - EnumDeclaration 1'() {
+ def err = expectParseError '''\
+ |enum E<T> {}
+ |'''.stripMargin()
+
+ assert err == '''\
+ |startup failed:
+ |test.groovy: 1: enum declaration cannot have type parameters @ line 1, column 7.
+ | enum E<T> {}
+ | ^
+ |
+ |1 error
+ |'''.stripMargin()
+ }
+
+ void 'test groovy core - EnumDeclaration 2'() {
+ def err = expectParseError '''\
+ |enum E extends Object {}
+ |'''.stripMargin()
+
+ assert err == '''\
+ |startup failed:
+ |test.groovy: 1: No extends clause allowed for enum declaration @ line 1, column 8.
+ | enum E extends Object {}
+ | ^
+ |
+ |1 error
+ |'''.stripMargin()
+ }
+
+ void 'test groovy core - AnnotationDeclaration 1'() {
TestUtils.doRunAndShouldFail('fail/AnnotationDeclaration_01x.groovy');
}
- void "test groovy core - MethodDeclaration"() {
+ void 'test groovy core - AnnotationDeclaration 2'() {
+ def err = expectParseError '''\
+ |@interface A<T> {}
+ |'''.stripMargin()
+
+ assert err == '''\
+ |startup failed:
+ |test.groovy: 1: annotation declaration cannot have type parameters @ line 1, column 13.
+ | @interface A<T> {}
+ | ^
+ |
+ |1 error
+ |'''.stripMargin()
+ }
+
+ void 'test groovy core - AnnotationDeclaration 3'() {
+ def err = expectParseError '''\
+ |@interface A extends Object {}
+ |'''.stripMargin()
+
+ assert err == '''\
+ |startup failed:
+ |test.groovy: 1: No extends clause allowed for annotation declaration @ line 1, column 14.
+ | @interface A extends Object {}
+ | ^
+ |
+ |1 error
+ |'''.stripMargin()
+ }
+
+ void 'test groovy core - AnnotationDeclaration 4'() {
+ def err = expectParseError '''\
+ |@interface A implements Serializable {}
+ |'''.stripMargin()
+
+ assert err == '''\
+ |startup failed:
+ |test.groovy: 1: No implements clause allowed for annotation declaration @ line 1, column 14.
+ | @interface A implements Serializable {}
+ | ^
+ |
+ |1 error
+ |'''.stripMargin()
+ }
+
+ void 'test groovy core - MethodDeclaration'() {
TestUtils.shouldFail('fail/MethodDeclaration_01.groovy')
TestUtils.doRunAndShouldFail('fail/MethodDeclaration_02x.groovy')
TestUtils.doRunAndShouldFail('fail/MethodDeclaration_03x.groovy')
@@ -159,51 +232,66 @@ final class SyntaxErrorTest extends GroovyTestCase {
TestUtils.doRunAndShouldFail('fail/MethodDeclaration_05x.groovy')
}
- void "test groovy core - ConstructorDeclaration"() {
+ void 'test groovy core - ConstructorDeclaration'() {
TestUtils.shouldFail('fail/ConstructorDeclaration_01.groovy')
}
- void "test groovy core - ClosureListExpression"() {
+ void 'test groovy core - ClosureListExpression'() {
TestUtils.shouldFail('fail/ClosureListExpression_01.groovy')
TestUtils.shouldFail('fail/ClosureListExpression_02.groovy')
TestUtils.shouldFail('fail/ClosureListExpression_03.groovy')
TestUtils.shouldFail('fail/ClosureListExpression_04.groovy')
}
- void "test groovy core - InterfaceDeclaration"() {
+ void 'test groovy core - InterfaceDeclaration 1'() {
TestUtils.shouldFail('fail/InterfaceDeclaration_01.groovy')
}
- void "test groovy core - void"() {
+ void 'test groovy core - InterfaceDeclaration 2'() {
+ def err = expectParseError '''\
+ |interface I implements Serializable {}
+ |'''.stripMargin()
+
+ assert err == '''\
+ |startup failed:
+ |test.groovy: 1: No implements clause allowed for interface declaration @ line 1, column 13.
+ | interface I implements Serializable {}
+ | ^
+ |
+ |1 error
+ |'''.stripMargin()
+ }
+
+ void 'test groovy core - void'() {
TestUtils.doRunAndShouldFail('fail/Void_01x.groovy')
TestUtils.doRunAndShouldFail('fail/Void_02x.groovy')
}
- void "test groovy core - FieldDeclaration"() {
+ void 'test groovy core - FieldDeclaration'() {
TestUtils.doRunAndShouldFail('fail/FieldDeclaration_01x.groovy')
TestUtils.doRunAndShouldFail('fail/FieldDeclaration_02x.groovy')
TestUtils.doRunAndShouldFail('fail/FieldDeclaration_03x.groovy')
TestUtils.doRunAndShouldFail('fail/FieldDeclaration_04x.groovy')
}
- void "test groovy core - Assert"() {
+ void 'test groovy core - Assert'() {
TestUtils.doRunAndShouldFail('fail/Assert_01x.groovy')
}
- void "test groovy core - DuplicatedNamedParameter"() {
+ void 'test groovy core - DuplicatedNamedParameter'() {
TestUtils.doRunAndShouldFail('fail/DuplicatedNamedParameter_01x.groovy')
TestUtils.doRunAndShouldFail('fail/DuplicatedNamedParameter_02x.groovy')
}
- void "test groovy core - threadsafe"() {
+ void 'test groovy core - threadsafe'() {
TestUtils.doRunAndShouldFail('fail/ThreadSafe_01x.groovy')
}
- void "test groovy core - VarArgParameter"() {
+ void 'test groovy core - VarArgParameter'() {
TestUtils.doRunAndShouldFail('fail/VarArgParameter_01x.groovy')
}
- void "test groovy core - Number"() {
+ void 'test groovy core - Number'() {
TestUtils.doRunAndShouldFail('fail/Number_01x.groovy')
TestUtils.doRunAndShouldFail('fail/Number_02x.groovy')
TestUtils.doRunAndShouldFail('fail/Number_03x.groovy')
@@ -211,204 +299,123 @@ final class SyntaxErrorTest extends GroovyTestCase {
TestUtils.doRunAndShouldFail('fail/Number_05x.groovy')
}
- void "test groovy core - MethodCall"() {
+ void 'test groovy core - MethodCall'() {
TestUtils.doRunAndShouldFail('fail/MethodCall_01x.groovy')
}
- void "test groovy core - var"() {
+ void 'test groovy core - var'() {
TestUtils.doRunAndShouldFail('fail/Var_01x.groovy')
TestUtils.doRunAndShouldFail('fail/Var_02x.groovy')
}
- void "test groovy core - String"() {
+ void 'test groovy core - String'() {
TestUtils.doRunAndShouldFail('fail/String_01x.groovy')
TestUtils.doRunAndShouldFail('fail/String_02x.groovy')
TestUtils.shouldFail('fail/String_03.groovy')
TestUtils.shouldFail('fail/String_04.groovy')
}
- void "test groovy core - NonStaticClass"() {
+ void 'test groovy core - NonStaticClass'() {
TestUtils.doRunAndShouldFail('fail/NonStaticClass_01x.groovy')
}
- void "test groovy core - Import"() {
+ void 'test groovy core - Import'() {
TestUtils.doRunAndShouldFail('fail/Import_01x.groovy')
TestUtils.doRunAndShouldFail('fail/Import_02x.groovy')
}
- void "test groovy core - UnaryOperator"() {
+ void 'test groovy core - UnaryOperator'() {
TestUtils.doRunAndShouldFail('fail/UnaryOperator_01x.groovy')
TestUtils.doRunAndShouldFail('fail/UnaryOperator_02x.groovy')
}
- void "test groovy core - Trait"() {
+ void 'test groovy core - Trait'() {
TestUtils.shouldFail('fail/Trait_01.groovy')
}
- void "test groovy core - Array"() {
+ void 'test groovy core - Array'() {
TestUtils.doRunAndShouldFail('fail/Array_01x.groovy')
TestUtils.doRunAndShouldFail('fail/Array_02x.groovy')
}
-
- void "test error alternative - Missing ')' 1"() {
- def err = expectFail '''\
-println ((int 123)
- '''
-
- assert err == '''\
-startup failed:
-test.groovy: 1: Missing ')' @ line 1, column 14.
- println ((int 123)
- ^
-
-1 error
-'''
- }
-
- void "test error alternative - Missing ')' 2"() {
- def err = expectFail '''\
-def x() {
- println((int) 123
-}
- '''
-
- assert err == '''\
-startup failed:
-test.groovy: 2: Missing ')' @ line 2, column 22.
- println((int) 123
- ^
-
-1 error
-'''
- }
-
-
- void "test groovy core - AnnotationDeclaration 1"() {
- def err = expectFail '''\
-@interface A<T> {}
- '''
+ void 'test error alternative - Missing ")" 1'() {
+ def err = expectParseError '''\
+ |println ((int 123)
+ |'''.stripMargin()
assert err == '''\
-startup failed:
-test.groovy: 1: annotation declaration cannot have type parameters @ line 1, column 13.
- @interface A<T> {}
- ^
-
-1 error
-'''
- }
-
- void "test groovy core - AnnotationDeclaration 2"() {
- def err = expectFail '''\
-@interface A extends Object {}
- '''
+ |startup failed:
+ |test.groovy: 1: Missing ')' @ line 1, column 14.
+ | println ((int 123)
+ | ^
+ |
+ |1 error
+ |'''.stripMargin()
+ }
+
+ void 'test error alternative - Missing ")" 2'() {
+ def err = expectParseError '''\
+ |def x() {
+ | println((int) 123
+ |}
+ |'''.stripMargin()
assert err == '''\
-startup failed:
-test.groovy: 1: No extends clause allowed for annotation declaration @ line 1, column 14.
- @interface A extends Object {}
- ^
-
-1 error
-'''
+ |startup failed:
+ |test.groovy: 2: Missing ')' @ line 2, column 22.
+ | println((int) 123
+ | ^
+ |
+ |1 error
+ |'''.stripMargin()
}
- void "test groovy core - AnnotationDeclaration 3"() {
- def err = expectFail '''\
-@interface A implements Serializable {}
- '''
-
- assert err == '''\
-startup failed:
-test.groovy: 1: No implements clause allowed for annotation declaration @ line 1, column 14.
- @interface A implements Serializable {}
- ^
-
-1 error
-'''
+ @NotYetImplemented
+ void 'test CompilerErrorTest_001.groovy'() {
+ unzipScriptAndShouldFail('scripts/CompilerErrorTest_001.groovy', [])
}
- void "test groovy core - EnumDeclaration 1"() {
- def err = expectFail '''\
-enum E<T> {}
- '''
-
- assert err == '''\
-startup failed:
-test.groovy: 1: enum declaration cannot have type parameters @ line 1, column 7.
- enum E<T> {}
- ^
-
-1 error
-'''
+ @NotYetImplemented
+ void 'test CompilerErrorTest_002.groovy'() {
+ unzipScriptAndShouldFail('scripts/CompilerErrorTest_002.groovy', [])
}
- void "test groovy core - EnumDeclaration 2"() {
- def err = expectFail '''\
-enum E extends Object {}
- '''
-
- assert err == '''\
-startup failed:
-test.groovy: 1: No extends clause allowed for enum declaration @ line 1, column 8.
- enum E extends Object {}
- ^
-
-1 error
-'''
+ @NotYetImplemented
+ void 'test DifferencesFromJavaTest_002.groovy'() {
+ unzipScriptAndShouldFail('scripts/DifferencesFromJavaTest_002.groovy', [])
}
- void "test groovy core - InterfaceDeclaration 1"() {
- def err = expectFail '''\
-interface I implements Serializable {}
- '''
-
- assert err == '''\
-startup failed:
-test.groovy: 1: No implements clause allowed for interface declaration @ line 1, column 13.
- interface I implements Serializable {}
- ^
-
-1 error
-'''
+ @NotYetImplemented
+ void 'test Groovy5212Bug_001.groovy'() {
+ unzipScriptAndShouldFail('scripts/Groovy5212Bug_001.groovy', [])
}
- void "test test groovy core - ClassDeclaration 1"() {
- def err = expectFail '''\
-class C extends Object, Number {}
- '''
-
- assert err == '''\
-startup failed:
-test.groovy: 1: Cannot extend multiple classes @ line 1, column 9.
- class C extends Object, Number {}
- ^
-
-1 error
-'''
+ @NotYetImplemented
+ void 'test GStringEndTest_001.groovy'() {
+ unzipScriptAndShouldFail('scripts/GStringEndTest_001.groovy', [])
}
-
//--------------------------------------------------------------------------
- def expectFail(String code) {
+
+ private static String expectParseError(String source) {
try {
- def ast = new CompilationUnit().tap {
- addSource 'test.groovy', code
- compile Phases.CONVERSION
- }.getAST()
+ new CompilationUnit().with {
+ addSource('test.groovy', source)
+ compile(Phases.CONVERSION)
+ getAST()
+ }
- fail("should fail")
+ fail('expected parse to fail')
} catch (e) {
- return e.message.replaceAll('\r\n', '\n')
+ return e.message.replace('\r\n', '\n')
}
}
- private static unzipScriptAndShouldFail(String entryName, List ignoreClazzList, Map<String, String> replacementsMap=[:], boolean toCheckNewParserOnly = false) {
+ private static unzipScriptAndShouldFail(String entryName, List ignoreClazzList, Map<String, String> replacementsMap = [:], boolean toCheckNewParserOnly = false) {
ignoreClazzList.addAll(TestUtils.COMMON_IGNORE_CLASS_LIST)
- TestUtils.unzipAndFail(SCRIPT_ZIP_PATH, entryName, TestUtils.addIgnore(ignoreClazzList, ASTComparatorCategory.LOCATION_IGNORE_LIST), replacementsMap, toCheckNewParserOnly)
+ TestUtils.unzipAndFail(SCRIPT_ZIP_PATH, entryName, TestUtils.addIgnore(ignoreClazzList, LOCATION_IGNORE_LIST), replacementsMap, toCheckNewParserOnly)
}
- private static final String SCRIPT_ZIP_PATH = "$TestUtils.RESOURCES_PATH/groovy-2.5.0/groovy-2.5.0-SNAPSHOT-20160921-allscripts.zip"
+ private static final String SCRIPT_ZIP_PATH = "${TestUtils.RESOURCES_PATH}/groovy-2.5.0/groovy-2.5.0-SNAPSHOT-20160921-allscripts.zip"
}
diff --git a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/util/ASTComparatorCategory.groovy b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/util/ASTComparatorCategory.groovy
index 0480004..9b85163 100644
--- a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/util/ASTComparatorCategory.groovy
+++ b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/util/ASTComparatorCategory.groovy
@@ -101,58 +101,50 @@ import org.codehaus.groovy.syntax.Token
import java.util.logging.Level
-@CompileStatic
-@Log @SuppressWarnings("GroovyUnusedDeclaration")
+@CompileStatic @Log @SuppressWarnings('GroovyUnusedDeclaration')
class ASTComparatorCategory {
static { log.level = Level.WARNING }
- static List<String> LOCATION_IGNORE_LIST = ["columnNumber", "lineNumber", "lastColumnNumber", "lastLineNumber", "startLine"]
- static private List<String> EXPRESSION_IGNORE_LIST = ["text"] + LOCATION_IGNORE_LIST
+ public static final List<String> LOCATION_IGNORE_LIST = ['columnNumber', 'lineNumber', 'lastColumnNumber', 'lastLineNumber', 'startLine'].asUnmodifiable()
+ private static final List<String> EXPRESSION_IGNORE_LIST = (['text'] + LOCATION_IGNORE_LIST).asUnmodifiable()
- /**
- * Keeps all checked object pairs and their comparison result.
- * Will be cleared at {@link #apply(groovy.lang.Closure)} method }
- */
- static Map<List<Object>, Boolean> objects = [:] as Map<List<Object>, Boolean>
- static String lastName
-
- static Map<Class, List<String>> DEFAULT_CONFIGURATION = [
- (ClassNode) : (['module', "declaredMethodsMap", "plainNodeReference", "typeClass", "allInterfaces", "orAddStaticConstructorNode", "allDeclaredMethods", "unresolvedSuperClass", "innerClasses" ] + LOCATION_IGNORE_LIST) as List<String>,
+ public static final Map<Class, List<String>> DEFAULT_CONFIGURATION = [
+ (ClassNode) : ['module', 'declaredMethodsMap', 'plainNodeReference', 'typeClass', 'allInterfaces', 'orAddStaticConstructorNode', 'allDeclaredMethods', 'unresolvedSuperClass', 'innerClasses' ] + LOCATION_IGNORE_LIST,
(ConstructorNode) : ['declaringClass'],
(DynamicVariable) : [],
- (EnumConstantClassNode) : ["typeClass"],
- (FieldNode) : ["owner", "declaringClass", "initialValueExpression", "assignToken"],
+ (EnumConstantClassNode) : ['typeClass'],
+ (FieldNode) : ['owner', 'declaringClass', 'initialValueExpression', 'assignToken'],
(GenericsType) : [],
(ImportNode) : LOCATION_IGNORE_LIST,
- (InnerClassNode) : (['module', "declaredMethodsMap", "plainNodeReference", "typeClass", "allInterfaces", "orAddStaticConstructorNode", "allDeclaredMethods", "unresolvedSuperClass", "innerClasses" ] + LOCATION_IGNORE_LIST) as List<String>,
+ (InnerClassNode) : ['module', 'declaredMethodsMap', 'plainNodeReference', 'typeClass', 'allInterfaces', 'orAddStaticConstructorNode', 'allDeclaredMethods', 'unresolvedSuperClass', 'innerClasses' ] + LOCATION_IGNORE_LIST,
(InterfaceHelperClassNode) : [],
- (MethodNode) : ["text", "declaringClass"],
+ (MethodNode) : ['text', 'declaringClass'],
(MixinNode) : [],
- (ModuleNode) : ["context"],
+ (ModuleNode) : ['context'],
(PackageNode) : [],
(Parameter) : [],
- (PropertyNode) : ['declaringClass', 'initialValueExpression', "assignToken"],
+ (PropertyNode) : ['declaringClass', 'initialValueExpression', 'assignToken'],
(Variable) : [],
- (VariableScope) : ["clazzScope", "parent", "declaredVariablesIterator"],
- (Token) : ["root", "startColumn"],
- (AnnotationNode) : (["text"] + LOCATION_IGNORE_LIST) as List<String>,
- (AssertStatement) : ["text"],
- (BlockStatement) : ["columnNumber", "lineNumber", "lastColumnNumber", "lastLineNumber", "text"],
- (BreakStatement) : ["text"],
- (CaseStatement) : ["text"],
- (CatchStatement) : (["text"] + LOCATION_IGNORE_LIST) as List<String>,
- (ContinueStatement) : ["text"],
- (DoWhileStatement) : ["text"],
- (EmptyStatement) : ["text"],
- (ExpressionStatement) : ["text"],
- (ForStatement) : ["text"],
- (IfStatement) : ["text"],
- (LoopingStatement) : ["text"],
- (ReturnStatement) : ["text"],
- (SwitchStatement) : ["columnNumber", "lineNumber", "lastColumnNumber", "lastLineNumber", "text"],
- (SynchronizedStatement) : ["text"],
- (ThrowStatement) : ["text"],
- (TryCatchStatement) : (["text"] + LOCATION_IGNORE_LIST) as List<String>,
- (WhileStatement) : ["text"],
+ (VariableScope) : ['clazzScope', 'parent', 'declaredVariablesIterator'],
+ (Token) : ['root', 'startColumn'],
+ (AnnotationNode) : (['text'] + LOCATION_IGNORE_LIST),
+ (AssertStatement) : ['text'],
+ (BlockStatement) : ['columnNumber', 'lineNumber', 'lastColumnNumber', 'lastLineNumber', 'text'],
+ (BreakStatement) : ['text'],
+ (CaseStatement) : ['text'],
+ (CatchStatement) : ['text'] + LOCATION_IGNORE_LIST,
+ (ContinueStatement) : ['text'],
+ (DoWhileStatement) : ['text'],
+ (EmptyStatement) : ['text'],
+ (ExpressionStatement) : ['text'],
+ (ForStatement) : ['text'],
+ (IfStatement) : ['text'],
+ (LoopingStatement) : ['text'],
+ (ReturnStatement) : ['text'],
+ (SwitchStatement) : ['columnNumber', 'lineNumber', 'lastColumnNumber', 'lastLineNumber', 'text'],
+ (SynchronizedStatement) : ['text'],
+ (ThrowStatement) : ['text'],
+ (TryCatchStatement) : ['text'] + LOCATION_IGNORE_LIST,
+ (WhileStatement) : ['text'],
(AnnotationConstantExpression): EXPRESSION_IGNORE_LIST,
(ArgumentListExpression) : EXPRESSION_IGNORE_LIST,
(ArrayExpression) : EXPRESSION_IGNORE_LIST,
@@ -166,7 +158,7 @@ class ASTComparatorCategory {
(ClosureListExpression) : EXPRESSION_IGNORE_LIST,
(ConstantExpression) : EXPRESSION_IGNORE_LIST,
(ConstructorCallExpression) : EXPRESSION_IGNORE_LIST,
- (DeclarationExpression) : ["text", "columnNumber", "lineNumber", "lastColumnNumber", "lastLineNumber"],
+ (DeclarationExpression) : ['text', 'columnNumber', 'lineNumber', 'lastColumnNumber', 'lastLineNumber'],
(ElvisOperatorExpression) : EXPRESSION_IGNORE_LIST,
(EmptyExpression) : EXPRESSION_IGNORE_LIST,
(ExpressionTransformer) : EXPRESSION_IGNORE_LIST,
@@ -192,13 +184,21 @@ class ASTComparatorCategory {
(UnaryMinusExpression) : EXPRESSION_IGNORE_LIST,
(UnaryPlusExpression) : EXPRESSION_IGNORE_LIST,
(VariableExpression) : EXPRESSION_IGNORE_LIST,
- ] as Map<Class, List<String>>
+ ].asUnmodifiable()
+
+ public static final Map<Class, List<String>> COLLECTION_PROPERTY_CONFIGURATION = [
+ (ModuleNode): ['classes', 'name']
+ ].asUnmodifiable()
- static Map<Class, List<String>> COLLECTION_PROPERTY_CONFIGURATION = [
- (ModuleNode): ["classes", "name"]
- ] as Map<Class, List<String>>
+ public static Map<Class, List<String>> configuration = DEFAULT_CONFIGURATION
- static Map<Class, List<String>> configuration = DEFAULT_CONFIGURATION;
+ /**
+ * Keeps all checked object pairs and their comparison result.
+ * Will be cleared at {@link #apply(groovy.lang.Closure)} method }
+ */
+ public static final Map<List<Object>, Boolean> objects = [:]
+
+ static String lastName
@CompileDynamic
static void apply(config = DEFAULT_CONFIGURATION, Closure cl) {