Skip to content

Commit ee8e69e

Browse files
committed
GROOVY-8162: Update Groovysh to JLine3 (tweak variable regex)
1 parent a919798 commit ee8e69e

File tree

1 file changed

+2
-2
lines changed
  • subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline

1 file changed

+2
-2
lines changed

subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyEngine.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,15 @@ public enum Format {
111111
private static final String BASE_REGEX_VAR = "[\\p{L}_$][\\p{L}\\p{N}_$]*";
112112
private static final String REGEX_VAR = "(" + BASE_REGEX_VAR + ")";
113113
private static final String METHOD_REGEX_VAR = "(" + BASE_REGEX_VAR + "|\"(?:[^\"\\\\]|\\\\.)*\")";
114-
private static final String ANNOTATIONS = "((?:@(?!interface)(?:[\\p{L}_$][\\p{L}\\p{N}_$]*\\.)*[\\p{L}_$][\\p{L}\\p{N}_$]*(?:\\([^)]*\\))?\\s*)*\\s+)?";
114+
private static final String ANNOTATIONS = "(?:(?:@(?!interface)(?:[\\p{L}_$][\\p{L}\\p{N}_$]*\\.)*[\\p{L}_$][\\p{L}\\p{N}_$]*(?:\\([^)]*\\))?\\s*)*\\s+)?";
115115
private static final String MODIFIERS = "(?:(?:public|protected|private|abstract|final|static|sealed|non-sealed|strictfp)\\s+)*";
116116
private static final String BODY = "\\s*(.*?\\{.*?})(|;|\n)$";
117117
private static final String PARAMS = "\\(([\\p{L}\\p{N}_ ,]*)\\)";
118118
private static final Pattern PATTERN_METHOD_DEF = Pattern.compile(
119119
"(?ms)" + ANNOTATIONS + MODIFIERS + "(?!record)" + REGEX_VAR + "\\s+(" + METHOD_REGEX_VAR + "\\s*" + PARAMS + ")" + BODY);
120120
private static final Pattern PATTERN_VAR_DEF = Pattern.compile("^\\s*" + ANNOTATIONS + BASE_REGEX_VAR + "\\s+" + REGEX_VAR + "\\s*=[^=~].*");
121121
private static final Pattern PATTERN_TYPE_DEF =
122-
Pattern.compile("(?ms)" + ANNOTATIONS + MODIFIERS + "((?:(?:\\bclass|@?\\binterface|\\benum|\\btrait)\\s+" + REGEX_VAR + ")|(?:\\brecord\\s+" + REGEX_VAR + "\\s*" + PARAMS + "))" + BODY);
122+
Pattern.compile("(?ms)" + ANNOTATIONS + MODIFIERS + "((?:\\bclass|@?\\binterface|\\benum|\\btrait)\\s+" + REGEX_VAR + "|(?:\\brecord\\s+" + REGEX_VAR + "\\s*" + PARAMS + "))" + BODY);
123123
private static final String REGEX_CLASS = "(.*?)\\.([A-Z_].*)";
124124
private static final Pattern PATTERN_CLASS = Pattern.compile(REGEX_CLASS);
125125
private static final String REGEX_PACKAGE = "([a-z][a-z_0-9]*\\.)*";

0 commit comments

Comments
 (0)