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
The following commit(s) were added to refs/heads/master by this push:
new e144a05570 GROOVY-8162: Update Groovysh to JLine3 (maven completion
should also use grapes repo)
e144a05570 is described below
commit e144a0557099a9392034690ef3502dea1469a19e
Author: Paul King <[email protected]>
AuthorDate: Fri Jul 25 12:37:15 2025 +1000
GROOVY-8162: Update Groovysh to JLine3 (maven completion should also use
grapes repo)
---
.../groovysh/jline/MavenCoordinateCompleter.groovy | 23 +++++++++++++++++-----
1 file changed, 18 insertions(+), 5 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 894bfcf99e..f25dde947c 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
@@ -26,6 +26,7 @@ import org.jline.reader.ParsedLine
class MavenCoordinateCompleter implements Completer {
private File mavenRepo = new File(System.getProperty('user.home'),
'.m2/repository')
+ private File grapeRepo = new File(System.getProperty('user.home'),
'.groovy/grapes')
@Override
@@ -47,20 +48,32 @@ class MavenCoordinateCompleter implements Completer {
}
private void suggestGroupIds(String prefix, List<Candidate> candidates) {
+ Set seen = []
+ grapeRepo.eachDir{ subdir ->
+ def name = subdir.name
+ if (!name.startsWith(prefix)) return
+ def dots = prefix.count('.')
+ def subParts = name.split(/\./)
+ def suggestion = subParts[0..dots].join('.')
+ if (seen.contains(suggestion)) return
+ seen << suggestion
+ def sep = suggestion == name ? ':' : '.'
+ candidates << new Candidate(suggestion + sep, suggestion + sep,
null, null, '', null, false)
+ }
+
boolean endsWithDot = prefix.endsWith('.')
def parts = prefix ? prefix.split(/\./) : []
def lastPart = endsWithDot ? '' : (parts ? parts[-1] : '')
def baseParts = endsWithDot ? parts : (parts.size() > 1 ? parts[0..-2]
: [])
- def baseDir = baseParts.inject(mavenRepo) { dir, part -> new File(dir,
part) }
-
- if (!baseDir.exists()) return
+ def mavenDir = baseParts.inject(mavenRepo) { dir, part -> new
File(dir, part) }
- baseDir.eachDir { subdir ->
+ if (!mavenDir) return
+ mavenDir.eachDir { subdir ->
if (lastPart && !subdir.name.startsWith(lastPart)) return
def suggestionParts = baseParts + [subdir.name]
def suggestion = suggestionParts.join('.')
- def candidateFile = new File(baseDir, subdir.name)
+ def candidateFile = new File(mavenDir, subdir.name)
def childDirs = candidateFile.listFiles().grep(File::isDirectory)
def hasArtifactChildren = childDirs.any { isVersionDirPresent(it) }
def hasOnlyArtifactChildren = childDirs.every { isVersionDir(it) }