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

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


The following commit(s) were added to refs/heads/jline3 by this push:
     new 83abb55602 better handle case where both artifacts and deeper nesting 
occur
83abb55602 is described below

commit 83abb55602323bd66698b0de9082f691b2f80261
Author: Paul King <pa...@asert.com.au>
AuthorDate: Mon Jun 23 17:39:09 2025 +1000

    better handle case where both artifacts and deeper nesting occur
---
 .../groovysh/jline/MavenCoordinateCompleter.groovy | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git 
a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/MavenCoordinateCompleter.groovy
 
b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/MavenCoordinateCompleter.groovy
index 89a1e8ae61..894bfcf99e 100644
--- 
a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/MavenCoordinateCompleter.groovy
+++ 
b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/MavenCoordinateCompleter.groovy
@@ -61,22 +61,16 @@ class MavenCoordinateCompleter implements Completer {
             def suggestionParts = baseParts + [subdir.name]
             def suggestion = suggestionParts.join('.')
             def candidateFile = new File(baseDir, subdir.name)
-            def childDirs = candidateFile.listFiles().findAll { 
it.isDirectory() }
-
+            def childDirs = candidateFile.listFiles().grep(File::isDirectory)
             def hasArtifactChildren = childDirs.any { isVersionDirPresent(it) }
+            def hasOnlyArtifactChildren = childDirs.every { isVersionDir(it) }
+            def hasDeeperGroupChildren = !hasOnlyArtifactChildren && 
childDirs.any { !isVersionDirPresent(it) }
 
-            if (endsWithDot) {
-                if (hasArtifactChildren) {
-                    candidates << new Candidate(suggestion + ':', suggestion + 
':', null, null, '', null, false)
-                }
-            } else {
-                def hasDeeperGroupChildren = childDirs.any { 
!isVersionDirPresent(it) }
-                if (hasArtifactChildren) {
-                    candidates << new Candidate(suggestion + ':', suggestion + 
':', null, null, '', null, false)
-                }
-                if (hasDeeperGroupChildren) {
-                    candidates << new Candidate(suggestion + '.', suggestion + 
'.', null, null, '', null, false)
-                }
+            if (hasArtifactChildren) {
+                candidates << new Candidate(suggestion + ':', suggestion + 
':', null, null, '', null, false)
+            }
+            if (hasDeeperGroupChildren) {
+                candidates << new Candidate(suggestion + '.', suggestion + 
'.', null, null, '', null, false)
             }
         }
     }

Reply via email to