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
commit ee8e69e950074d75dc9655ab6854a20457202ee4 Author: Paul King <[email protected]> AuthorDate: Mon Aug 4 09:30:30 2025 +1000 GROOVY-8162: Update Groovysh to JLine3 (tweak variable regex) --- .../main/groovy/org/apache/groovy/groovysh/jline/GroovyEngine.java | 4 ++-- 1 file changed, 2 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 b2d8c1c8e3..1891d30793 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 @@ -111,7 +111,7 @@ public class GroovyEngine implements ScriptEngine { private static final String BASE_REGEX_VAR = "[\\p{L}_$][\\p{L}\\p{N}_$]*"; private static final String REGEX_VAR = "(" + BASE_REGEX_VAR + ")"; private static final String METHOD_REGEX_VAR = "(" + BASE_REGEX_VAR + "|\"(?:[^\"\\\\]|\\\\.)*\")"; - private static final String ANNOTATIONS = "((?:@(?!interface)(?:[\\p{L}_$][\\p{L}\\p{N}_$]*\\.)*[\\p{L}_$][\\p{L}\\p{N}_$]*(?:\\([^)]*\\))?\\s*)*\\s+)?"; + private static final String ANNOTATIONS = "(?:(?:@(?!interface)(?:[\\p{L}_$][\\p{L}\\p{N}_$]*\\.)*[\\p{L}_$][\\p{L}\\p{N}_$]*(?:\\([^)]*\\))?\\s*)*\\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}_ ,]*)\\)"; @@ -119,7 +119,7 @@ public class GroovyEngine implements ScriptEngine { "(?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)\\s+" + REGEX_VAR + ")|(?:\\brecord\\s+" + REGEX_VAR + "\\s*" + PARAMS + "))" + 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]*\\.)*";
