1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-11-19 21:44:11 +01:00

New _java_class to find classes on the classpath.

This commit is contained in:
Felix Rosencrantz 2002-04-10 05:24:29 +00:00
parent c5ebd0fad0
commit 21139de01d
2 changed files with 16 additions and 0 deletions

@ -9,4 +9,5 @@ _files _pdf _pspdf _users
_groups _perl_basepods _signals _users_on
_hosts _perl_builtin_funcs _tar_archive _time_zone
_file_systems _net_interfaces _terminals _locales
_java_class
'

@ -0,0 +1,15 @@
local classpath
#Should probably add some sort of cache.
#First use -classpath/-cp, then CLASSPATH, then assume .
classpath=${opt_args[-classpath]:-${opt_args[-cp]:-${CLASSPATH:-.}}}
local c i
#Should we call _multipart insteads of compadd
for i in ${(z)classpath//:/ }; do
if [ -f $i ] && [[ "$i" == *.(jar|zip|war|ear) ]]; then
c=(${${${(M)$(_call_program jar_classes jar -tf $i)##*.class}%%.class}:gs#/#.#})
compadd -M 'r:|.=* r:|=*' -- $c
elif [ -d $i ]; then
c=(**/*.class(.:r:s/.class//:gs#/#.#))
compadd -M 'r:|.=* r:|=*' -- $c
fi
done