You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2025/08/03 07:14:16 UTC

(groovy) branch master updated (b7ac1c1162 -> 720108cbdc)

This is an automated email from the ASF dual-hosted git repository.

paulk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


    from b7ac1c1162 GROOVY-8162: Update Groovysh to JLine3 (additional documentation)
     new 7540467226 GROOVY-8162: Update Groovysh to JLine3 (no need for types)
     new 8186b66a4c GROOVY-8162: Update Groovysh to JLine3 (tweak variable regex)
     new 720108cbdc GROOVY-8162: Update Groovysh to JLine3 (document /classloader)

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/groovy/groovysh/jline/GroovyEngine.java |   8 +-
 .../groovy-groovysh/src/spec/doc/groovysh.adoc     | 127 +++++++++++----------
 2 files changed, 72 insertions(+), 63 deletions(-)


(groovy) 02/03: GROOVY-8162: Update Groovysh to JLine3 (tweak variable regex)

Posted by pa...@apache.org.
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 <pa...@asert.com.au>
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_].*)";


(groovy) 01/03: GROOVY-8162: Update Groovysh to JLine3 (no need for types)

Posted by pa...@apache.org.
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 75404672267ef24c8459fcb6735109b127671e49
Author: Paul King <pa...@asert.com.au>
AuthorDate: Sun Aug 3 15:48:56 2025 +1000

    GROOVY-8162: Update Groovysh to JLine3 (no need for types)
---
 .../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 870d67de12..a51c2f343a 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
@@ -431,8 +431,8 @@ public class GroovyEngine implements ScriptEngine {
         } else {
             boolean iMode = isInterpreterMode();
             EnumSet<SnippetType> filter = iMode
-                ? EnumSet.of(SnippetType.IMPORT, SnippetType.TYPE, SnippetType.VARIABLE, SnippetType.METHOD)
-                : EnumSet.of(SnippetType.IMPORT, SnippetType.TYPE);
+                ? EnumSet.of(SnippetType.IMPORT, SnippetType.VARIABLE, SnippetType.METHOD)
+                : EnumSet.of(SnippetType.IMPORT);
             out = executeStatement(shell, snippets, filter, statement);
             classLoader.purgeClassCache();
             Matcher matcher = PATTERN_TYPE_DEF.matcher(statement);


(groovy) 03/03: GROOVY-8162: Update Groovysh to JLine3 (document /classloader)

Posted by pa...@apache.org.
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 720108cbdcf30efe27c740b461031a235047f2f2
Author: Paul King <pa...@asert.com.au>
AuthorDate: Sun Aug 3 17:14:08 2025 +1000

    GROOVY-8162: Update Groovysh to JLine3 (document /classloader)
---
 .../groovy-groovysh/src/spec/doc/groovysh.adoc     | 127 +++++++++++----------
 1 file changed, 68 insertions(+), 59 deletions(-)

diff --git a/subprojects/groovy-groovysh/src/spec/doc/groovysh.adoc b/subprojects/groovy-groovysh/src/spec/doc/groovysh.adoc
index 20b9df6f93..bd2634a5d2 100644
--- a/subprojects/groovy-groovysh/src/spec/doc/groovysh.adoc
+++ b/subprojects/groovy-groovysh/src/spec/doc/groovysh.adoc
@@ -252,13 +252,22 @@ image:assets/img/repl_alias2.png[More /alias examples, width=60%]
 
 Aliases are persisted in a `.groovysh/aliases.json` file in the user home directory.
 
+[[GroovyShell-classloader]]
+==== `/classloader`
+
+Display and manage the Groovy classloader data.
+
+Let's `/grab` a dependency, define a class using it, and then use the `/classloader` command to see the classloader data:
+
+image:assets/img/repl_classloader.png[Classloader, width=80%]
+
 [[GroovyShell-clear]]
-===== `/clear`
+==== `/clear`
 
 Clears the screen.
 
 [[GroovyShell-del]]
-===== `/del`
+==== `/del`
 
 Deletes objects from the shell.
 
@@ -281,8 +290,42 @@ Exit the shell.
 This is the *only* way to exit the shell. Well, you can still `CTRL-Z` on unix platforms,
 but things like `CTRL_C` are trapped. (See JLine3 documentation for more details.)
 
+[[GroovyShell-grab]]
+==== `/grab`
+
+Grab a dependency (Maven, Ivy, etc.) from Internet sources or cache,
+and add it to the Groovy Shell environment.
+
+[source,jshell]
+----
+groovy> /grab org.apache.commons:commons-collections4:4.5.0
+groovy> import org.apache.commons.collections4.bidimap.TreeBidiMap
+groovy> TreeBidiMap t = [apple: 'red']
+{apple=red}
+groovy> t.inverseBidiMap()
+{red=apple}
+----
+
+Completion is available. Currently, completion options are populated
+by known artifacts in the local Maven (~/.m2) and Grape (~/.groovy/grapes) repositories. In the future, completion from a remote repositories may be supported.
+
+[source,jshell]
+----
+groovy> /grab org.apache.commons:commons-<TAB>
+org.apache.commons:commons-collections4:     org.apache.commons:commons-exec:
+org.apache.commons:commons-compress:         org.apache.commons:commons-imaging:
+org.apache.commons:commons-configuration2:   org.apache.commons:commons-lang3:
+org.apache.commons:commons-crypto:           org.apache.commons:commons-math3:
+org.apache.commons:commons-csv:              org.apache.commons:commons-parent:
+org.apache.commons:commons-dbcp2:            org.apache.commons:commons-pool2:
+org.apache.commons:commons-digester3:        org.apache.commons:commons-text:
+org.apache.commons:commons-email:
+----
+
+This command can be given at any time to add new dependencies.
+
 [[GroovyShell-import]]
-===== `import`
+==== `import`
 
 Add a custom import which will be included for all shell evaluations.
 
@@ -311,7 +354,7 @@ Once an import statement has been executed, relevant classes will become availab
 image:assets/img/repl_import.png[Import, width=80%]
 
 [[GroovyShell-imports]]
-===== `/imports`
+==== `/imports`
 
 You can use this to list and delete existing imports.
 
@@ -321,42 +364,8 @@ groovy> /imports
 import java.util.concurrent.BlockingQueue
 --------------
 
-[[GroovyShell-grab]]
-===== `/grab`
-
-Grab a dependency (Maven, Ivy, etc.) from Internet sources or cache,
-and add it to the Groovy Shell environment.
-
-[source,jshell]
-----
-groovy> /grab org.apache.commons:commons-collections4:4.5.0
-groovy> import org.apache.commons.collections4.bidimap.TreeBidiMap
-groovy> TreeBidiMap t = [apple: 'red']
-{apple=red}
-groovy> t.inverseBidiMap()
-{red=apple}
-----
-
-Completion is available. Currently, completion options are populated
-by known artifacts in the local Maven (~/.m2) and Grape (~/.groovy/grapes) repositories. In the future, completion from a remote repositories may be supported.
-
-[source,jshell]
-----
-groovy> /grab org.apache.commons:commons-<TAB>
-org.apache.commons:commons-collections4:     org.apache.commons:commons-exec:
-org.apache.commons:commons-compress:         org.apache.commons:commons-imaging:
-org.apache.commons:commons-configuration2:   org.apache.commons:commons-lang3:
-org.apache.commons:commons-crypto:           org.apache.commons:commons-math3:
-org.apache.commons:commons-csv:              org.apache.commons:commons-parent:
-org.apache.commons:commons-dbcp2:            org.apache.commons:commons-pool2:
-org.apache.commons:commons-digester3:        org.apache.commons:commons-text:
-org.apache.commons:commons-email:
-----
-
-This command can be given at any time to add new dependencies.
-
 [[GroovyShell-less]]
-===== `/less`
+==== `/less`
 
 Display the contents of a file (usually a page at a time).
 Formatting of common file types is supported.
@@ -364,17 +373,12 @@ Formatting of common file types is supported.
 image:assets/img/repl_less.png[Usage of the /less command, width=85%]
 
 [[GroovyShell-reset]]
-===== `/reset`
+==== `/reset`
 
 Clears the current buffer and shared variables.
 
-[[GroovyShell-show]]
-===== `/show`
-
-Show the shared variables (the binding).
-
 [[GroovyShell-prnt]]
-===== `/prnt`
+==== `/prnt`
 
 The `/prnt` command outputs its argument to the console. Both variable expansion
 and formatting are supported.
@@ -385,37 +389,42 @@ See also the `/echo` command, which is similar but takes multiple arguments.
 It also supports variable expansion but doesn't support formatting.
 
 [[GroovyShell-inspect]]
-===== `/inspect`
+==== `/inspect`
 
 Opens the GUI object browser to inspect a variable or the result of the
 last evaluation.
 
-[[GroovyShell-nano]]
-===== `/nano`
-
-Edit the current buffer in an external editor.
-
-Currently only works on UNIX systems which have the `EDITOR` environment
-variable set, or have configured the `editor` preference.
-
 [[GroovyShell-load]]
-===== `/load`
+==== `/load`
 
 Load a file into the buffer.
 
 If no filename is given as an argument, the current shared variables are
 loaded from the `.groovy/groovysh.ser` file in the user home directory.
 
+[[GroovyShell-nano]]
+==== `/nano`
+
+Edit the current buffer in an external editor.
+
+Currently only works on UNIX systems which have the `EDITOR` environment
+variable set, or have configured the `editor` preference.
+
 [[GroovyShell-save]]
-===== `/save`
+==== `/save`
 
 Saves the buffer’s contents to a file.
 
 If no filename is given as an argument, the current shared variables are
 saved into the `.groovy/groovysh.ser` file in the user home directory.
 
+[[GroovyShell-show]]
+==== `/show`
+
+Show the shared variables (the binding).
+
 [[GroovyShell-history]]
-===== `/history`
+==== `/history`
 
 Display, manage and recall edit-line history.
 
@@ -432,7 +441,7 @@ Display, manage and recall edit-line history.
 `history clear`
 
 [[GroovyShell-doc]]
-===== `/doc`
+==== `/doc`
 
 Opens a browser with documentation for the provided class.