about summary refs log tree commit diff
path: root/Completion/Unix/Type/_java_class
blob: 0e30e550cd6b3598177429040ce1c7c5b526ca06 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#autoload

# Should probably add some sort of cache.
# Should we call _multi_parts instead of compadd?

local classpath i expl
local -a c
local method type

zparseopts -D -E -a classpath t:=type m:=method cp: classpath:
: "$classpath[@]"
classpath="${${classpath[2]:-${CLASSPATH:-.}}//\\:/:}"
: "$classpath[@]"

for i in "${(s.:.)classpath}"; do
  [[ -z $i ]] && i=.
  if [[ -f $i ]] && [[ "$i" == *.(jar|zip|war|ear) ]]; then
    c+=( ${${${(M)$(_call_program jar_classes jar -tf $i 2>/dev/null)##*.class}%%.class}:gs#/#.#} )
  elif [[ -d $i ]]; then
    c+=( $i/**/*.class(.:r:s/.class//:s#$i/##:gs#/#.#) )
  fi
done

_wanted classes expl 'java class' compadd "$@" -M 'r:|.=* r:|=*' -a - c