This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new f4cab49a4e GROOVY-8162: Update Groovysh to JLine3 (refine
record/method regex expressions)
f4cab49a4e is described below
commit f4cab49a4e468a8f87dc19570023ad7589a2034b
Author: Paul King <[email protected]>
AuthorDate: Fri Jul 25 23:09:41 2025 +1000
GROOVY-8162: Update Groovysh to JLine3 (refine record/method regex
expressions)
---
.../main/groovy/org/apache/groovy/groovysh/jline/GroovyEngine.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git
a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyEngine.java
b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyEngine.java
index 286f596355..6695004a0c 100644
---
a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyEngine.java
+++
b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyEngine.java
@@ -114,11 +114,12 @@ public class GroovyEngine implements ScriptEngine {
private static final String ANNOTATIONS =
"^\\s*(?:@(?!interface)(?:[\\p{L}_$][\\p{L}\\p{N}_$]*\\.)*[\\p{L}_$][\\p{L}\\p{N}_$]*(?:\\([^)]*\\))?\\s*)*";
private static final String MODIFIERS =
"(?:(?:public|protected|private|abstract|final|static|sealed|non-sealed|strictfp)\\s+)*";
private static final String BODY = "\\s*(.*?\\{.*?})(|;|\n)$";
+ private static final String PARAMS = "\\(([\\p{L}\\p{N}_ ,]*)\\)";
private static final Pattern PATTERN_METHOD_DEF = Pattern.compile(
- "(?ms)" + ANNOTATIONS + MODIFIERS + REGEX_VAR + "\\s+(" +
METHOD_REGEX_VAR + "\\s*\\(([\\p{L}\\p{N}_ ,]*)\\))" + BODY);
+ "(?ms)" + ANNOTATIONS + MODIFIERS + "(?!record)" + REGEX_VAR +
"\\s+(" + METHOD_REGEX_VAR + "\\s*" + PARAMS + ")" + BODY);
private static final Pattern PATTERN_VAR_DEF = Pattern.compile("^\\s*" +
ANNOTATIONS + BASE_REGEX_VAR + "\\s*" + REGEX_VAR + "\\s*=[^=~].*");
private static final Pattern PATTERN_TYPE_DEF =
- Pattern.compile("(?ms)" + ANNOTATIONS + MODIFIERS +
"(\\bclass|@?\\binterface|\\benum|\\btrait|\\brecord)\\s+" + REGEX_VAR + BODY);
+ Pattern.compile("(?ms)" + ANNOTATIONS + MODIFIERS +
"((?:(?:\\bclass|@?\\binterface|\\benum|\\btrait)\\s+" + REGEX_VAR +
")|(?:\\brecord\\s+" + REGEX_VAR + "\\s*" + PARAMS + "))" + BODY);
private static final String REGEX_CLASS = "(.*?)\\.([A-Z_].*)";
private static final Pattern PATTERN_CLASS = Pattern.compile(REGEX_CLASS);
private static final String REGEX_PACKAGE = "([a-z][a-z_0-9]*\\.)*";