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 8186b66a4cf6bfb6268e4f8455ac60808c98216e Author: Paul King <[email protected]> AuthorDate: Sun Aug 3 17:10:44 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 a51c2f343a..b002f6918e 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 @@ -108,7 +108,7 @@ public class GroovyEngine implements ScriptEngine { private static final String VAR_GROOVY_OPTIONS = "GROOVY_OPTIONS"; private static final String DEFAULT_NANORC_SYNTAX = "classpath:/nanorc/jnanorc"; private static final String REGEX_SYSTEM_VAR = "[A-Z]+[A-Z_]*"; - private static final String BASE_REGEX_VAR = "[\\p{L}_$][\\p{L}\\p{N}_$]*"; + 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 = "^\\s*(?:@(?!interface)(?:[\\p{L}_$][\\p{L}\\p{N}_$]*\\.)*[\\p{L}_$][\\p{L}\\p{N}_$]*(?:\\([^)]*\\))?\\s*)*"; @@ -117,7 +117,7 @@ public class GroovyEngine implements ScriptEngine { private static final String PARAMS = "\\(([\\p{L}\\p{N}_ ,]*)\\)"; private static final Pattern PATTERN_METHOD_DEF = Pattern.compile( "(?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_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); private static final String REGEX_CLASS = "(.*?)\\.([A-Z_].*)";
