mirror of
https://github.com/zsh-users/zsh
synced 2024-10-15 12:23:33 +00:00
17577: pass classpath as an option to _java_class
This commit is contained in:
parent
bc5567c859
commit
043c302261
|
@ -1,4 +1,10 @@
|
||||||
2002-08-22 Oliver Kiddle <opk@zsh.org>
|
2002-08-24 Oliver Kiddle <opk@zsh.org>
|
||||||
|
|
||||||
|
* 17577: Completion/Unix/Command/_ant, Completion/Unix/Command/_zip,
|
||||||
|
Completion/Unix/Command/_java, Completion/Unix/Type/_java_class:
|
||||||
|
pass classpath as an option to _java_class
|
||||||
|
|
||||||
|
2002-08-23 Oliver Kiddle <opk@zsh.org>
|
||||||
|
|
||||||
* 17573: Completion/Zsh/Command/_read: complete -s option to
|
* 17573: Completion/Zsh/Command/_read: complete -s option to
|
||||||
read added in 17544
|
read added in 17544
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
typeset -A opt_args
|
typeset -A opt_args
|
||||||
local buildfile tmp state line curcontext="$curcontext"
|
local buildfile tmp state line curcontext="$curcontext"
|
||||||
local target='*:target:->target'
|
local c target='*:target:->target'
|
||||||
#local CLASSPATH="$ANT_HOME/lib/*.jar"
|
|
||||||
|
c=( $ANT_HOME/lib/*.jar )
|
||||||
|
|
||||||
if [[ $service = *ANT_ARGS* ]]; then
|
if [[ $service = *ANT_ARGS* ]]; then
|
||||||
compset -q
|
compset -q
|
||||||
|
@ -22,12 +23,12 @@ _arguments -C \
|
||||||
'-debug[print debugging information]' \
|
'-debug[print debugging information]' \
|
||||||
'-emacs[produce logging information without adornments]' \
|
'-emacs[produce logging information without adornments]' \
|
||||||
'(-l -logfile)'{-l,-logfile}'[use specified file for log]:logfile:_files' \
|
'(-l -logfile)'{-l,-logfile}'[use specified file for log]:logfile:_files' \
|
||||||
'-logger[the class which is to perform logging]:classname:_java_class' \
|
'-logger[the class which is to perform logging]:classname:_java_class -cp ${(j.:.)c}' \
|
||||||
'*-listener[add an instance of class as a project listener]:classname:_java_class' \
|
'*-listener[add an instance of class as a project listener]:classname:_java_class -cp ${(j.:.)c}' \
|
||||||
'(-f -file -buildfile -find)'{-f,-file,-buildfile}'[use specified build file]:build file:_files' \
|
'(-f -file -buildfile -find)'{-f,-file,-buildfile}'[use specified build file]:build file:_files' \
|
||||||
'*-D[specify property with value to use]:property:->property' \
|
'*-D[specify property with value to use]:property:->property' \
|
||||||
'-propertyfile[load properties from specfied file]:property file:_files' \
|
'-propertyfile[load properties from specfied file]:property file:_files' \
|
||||||
'-inputhandler[specify class which will handle input requests]:class:_java_class' \
|
'-inputhandler[specify class which will handle input requests]:class:_java_class -cp ${(j.\:.)c}' \
|
||||||
'(-f -file -buildfile)-find[search for build file towards the root of filesystem]:build file:(build.xml)' \
|
'(-f -file -buildfile)-find[search for build file towards the root of filesystem]:build file:(build.xml)' \
|
||||||
$target && return
|
$target && return
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,7 @@ jdb)
|
||||||
java)
|
java)
|
||||||
_arguments -C \
|
_arguments -C \
|
||||||
"$jdb_args[@]" \
|
"$jdb_args[@]" \
|
||||||
'(-cp)-classpath[specify path for user class files]:class path:->classpath' \
|
'(-cp -classpath)'{-cp,-classpath}'[specify path for user class files]:class path:->classpath' \
|
||||||
'(-classpath)-cp[specify path for user class files]:class path:->classpath' \
|
|
||||||
'-D-[specify a property]:property:->property' \
|
'-D-[specify a property]:property:->property' \
|
||||||
'(-verbose:class)-verbose[print class information]' \
|
'(-verbose:class)-verbose[print class information]' \
|
||||||
'(-verbose)-verbose\:class[print class information]' \
|
'(-verbose)-verbose\:class[print class information]' \
|
||||||
|
@ -44,7 +43,7 @@ java)
|
||||||
'-version[print version]' \
|
'-version[print version]' \
|
||||||
'-help[print help message]' \
|
'-help[print help message]' \
|
||||||
'(- 1)-jar[specify a program capsulated as jar]:jar:_files -g \*.jar' \
|
'(- 1)-jar[specify a program capsulated as jar]:jar:_files -g \*.jar' \
|
||||||
'(-):class:_java_class -m main' \
|
'(-):class:_java_class -m main ${(kv)opt_args[(i)(-classpath|-cp)]}' \
|
||||||
'*::args: _normal' \
|
'*::args: _normal' \
|
||||||
&& return 0
|
&& return 0
|
||||||
;;
|
;;
|
||||||
|
@ -57,7 +56,7 @@ javadoc)
|
||||||
'-package[display packages, public/protected classes and members only]' \
|
'-package[display packages, public/protected classes and members only]' \
|
||||||
'-private[display all classes and members]' \
|
'-private[display all classes and members]' \
|
||||||
'-help[print help message]' \
|
'-help[print help message]' \
|
||||||
'-doclet[specify a doclet]:doclet:_java_class -t doclet' \
|
'-doclet[specify a doclet]:doclet:_java_class -t doclet ${(kv)opt_args[(i)-classpath]}' \
|
||||||
'-docletpath[specify a path to search doclet]:doclet path:->docletpath' \
|
'-docletpath[specify a path to search doclet]:doclet path:->docletpath' \
|
||||||
'-1.1[Javadoc 1.1 compatible output]' \
|
'-1.1[Javadoc 1.1 compatible output]' \
|
||||||
'-sourcepath[specify path for source files]:source path:->sourcepath' \
|
'-sourcepath[specify path for source files]:source path:->sourcepath' \
|
||||||
|
@ -118,7 +117,7 @@ jar)
|
||||||
jar_cmd="${words[2]#-}"
|
jar_cmd="${words[2]#-}"
|
||||||
tmpassoc=(
|
tmpassoc=(
|
||||||
m ':manifest file:_files'
|
m ':manifest file:_files'
|
||||||
f ':archive file:_files -g \*.\(jar\|zip\)'
|
f ':archive file:_files -g \*.\([ejw]ar\|zip\)'
|
||||||
)
|
)
|
||||||
_arguments -C \
|
_arguments -C \
|
||||||
"${jar_cmd/[^-]*/:dummy:}" \
|
"${jar_cmd/[^-]*/:dummy:}" \
|
||||||
|
@ -140,7 +139,7 @@ javah|javah_g)
|
||||||
'-bootclasspath[specify path for bootstrap class files]:bootstrap class path:->bootstrapclasspath' \
|
'-bootclasspath[specify path for bootstrap class files]:bootstrap class path:->bootstrapclasspath' \
|
||||||
'-old[generate old JDK1.0-style header files]' \
|
'-old[generate old JDK1.0-style header files]' \
|
||||||
'-force[force output]' \
|
'-force[force output]' \
|
||||||
'*:fully qualified classname:_java_class -m main' && return 0
|
'*:fully qualified classname:_java_class -m main ${(kv)opt_args[(i)-classpath]}' && return 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
javap)
|
javap)
|
||||||
|
@ -159,7 +158,7 @@ javap)
|
||||||
'-classpath[specify path for user class files]:class path:->classpath' \
|
'-classpath[specify path for user class files]:class path:->classpath' \
|
||||||
'-bootclasspath[specify path for bootstrap class files]:bootstrap class path:->bootstrapclasspath' \
|
'-bootclasspath[specify path for bootstrap class files]:bootstrap class path:->bootstrapclasspath' \
|
||||||
'-extdirs[specify directories for extensions]:extensions directories:->extdirs' \
|
'-extdirs[specify directories for extensions]:extensions directories:->extdirs' \
|
||||||
'*:class:_java_class' && return 0
|
'*:class:_java_class ${(kv)opt_args[(i)-classpath]}' && return 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
extcheck)
|
extcheck)
|
||||||
|
@ -182,7 +181,7 @@ rmic)
|
||||||
'-verbose[print verbose messages]' \
|
'-verbose[print verbose messages]' \
|
||||||
'-v1.1[JDK 1.1 stub protocol]' \
|
'-v1.1[JDK 1.1 stub protocol]' \
|
||||||
'-v1.2[JDK 1.2 stub protocol]' \
|
'-v1.2[JDK 1.2 stub protocol]' \
|
||||||
'*:package qualified class name:_java_class' && return 0
|
'*:package qualified class name:_java_class ${(kv)opt_args[(i)-classpath]}' && return 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
rmiregistry)
|
rmiregistry)
|
||||||
|
|
|
@ -50,7 +50,7 @@ case $service in
|
||||||
'(-0 -1 -2 -3 -4 -5 -6 -7 -8 )-9[compress better]' \
|
'(-0 -1 -2 -3 -4 -5 -6 -7 -8 )-9[compress better]' \
|
||||||
'-x[exclude the following names]' \
|
'-x[exclude the following names]' \
|
||||||
'-i[include only the following names]' \
|
'-i[include only the following names]' \
|
||||||
"(-f -d -R -q -c -b -@ -F -FF -A -T -y -e -h -u -m -g -j -l -ll -L -v -z -t -tt -o -D -J -X -n -0 -1 -2 -3 -4 -5 -6 -7 -8 -9):zip file:_files -g '(#i)*.(zip|[jw]ar)'" \
|
"(-f -d -R -q -c -b -@ -F -FF -A -T -y -e -h -u -m -g -j -l -ll -L -v -z -t -tt -o -D -J -X -n -0 -1 -2 -3 -4 -5 -6 -7 -8 -9):zip file:_files -g '(#i)*.(zip|[ejw]ar)'" \
|
||||||
'*:file:->files' && return 0
|
'*:file:->files' && return 0
|
||||||
;;
|
;;
|
||||||
unzip)
|
unzip)
|
||||||
|
@ -75,7 +75,7 @@ case $service in
|
||||||
'-M[page output]' \
|
'-M[page output]' \
|
||||||
'-x[exclude the following names]' \
|
'-x[exclude the following names]' \
|
||||||
'-Z[zipinfo mode]:zipinfomode:->zipinfo' \
|
'-Z[zipinfo mode]:zipinfomode:->zipinfo' \
|
||||||
"(-p -f -u -l -t -z -n -o -j -C -X -q -qq -a -aa -v -L -M)1:zip file:_files -g '(#i)*.(zip|[jw]ar)'" \
|
"(-p -f -u -l -t -z -n -o -j -C -X -q -qq -a -aa -v -L -M)1:zip file:_files -g '(#i)*.(zip|[ejw]ar)'" \
|
||||||
'*:file:->files' && return 0
|
'*:file:->files' && return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -98,7 +98,7 @@ if [[ $service == zipinfo ]] || [[ -n $uzi ]]; then
|
||||||
'(-1 -2)-T[use sortable decimal format for file times]' \
|
'(-1 -2)-T[use sortable decimal format for file times]' \
|
||||||
'-M[page output]' \
|
'-M[page output]' \
|
||||||
'-x[exclude the following names]' \
|
'-x[exclude the following names]' \
|
||||||
"(-1 -2 -s -m -l -v -h -z -C -t -T -M)1:zip file:_files -g '(#i)*.(zip|[jw]ar)'" \
|
"(-1 -2 -s -m -l -v -h -z -C -t -T -M)1:zip file:_files -g '(#i)*.(zip|[ejw]ar)'" \
|
||||||
'*:file:->files' && return 0
|
'*:file:->files' && return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ case $state in
|
||||||
;;
|
;;
|
||||||
files)
|
files)
|
||||||
if [[ $service = zip ]] && (( ! ${+opt_args[-d]} )); then
|
if [[ $service = zip ]] && (( ! ${+opt_args[-d]} )); then
|
||||||
_files -g '^(#i)*.(zip|[jw]ar)' && return 0
|
_files -g '^(#i)*.(zip|[ejw]ar)' && return 0
|
||||||
else
|
else
|
||||||
zipfile=( $~line[1](|.zip|.ZIP) )
|
zipfile=( $~line[1](|.zip|.ZIP) )
|
||||||
[[ -z $zipfile[1] ]] && return 1
|
[[ -z $zipfile[1] ]] && return 1
|
||||||
|
|
|
@ -1,16 +1,24 @@
|
||||||
#autoload
|
#autoload
|
||||||
local classpath
|
|
||||||
#Should probably add some sort of cache.
|
# Should probably add some sort of cache.
|
||||||
#First use -classpath/-cp, then CLASSPATH, then assume .
|
# Should we call _multi_parts insteads of compadd?
|
||||||
classpath=${opt_args[-classpath]:-${opt_args[-cp]:-${CLASSPATH:-.}}}
|
|
||||||
local c i
|
local classpath i expl
|
||||||
#Should we call _multipart insteads of compadd
|
local -a c
|
||||||
for i in ${(z)classpath//:/ }; do
|
local method type
|
||||||
if [ -f $i ] && [[ "$i" == *.(jar|zip|war|ear) ]]; then
|
|
||||||
c=(${${${(M)$(_call_program jar_classes jar -tf $i)##*.class}%%.class}:gs#/#.#})
|
zparseopts -D -E -a classpath t:=type m:=method cp: classpath:
|
||||||
compadd -M 'r:|.=* r:|=*' -- $c
|
: "$classpath[@]"
|
||||||
elif [ -d $i ]; then
|
classpath="${${classpath[2]:-${CLASSPATH:-.}}//\\:/:}"
|
||||||
c=(**/*.class(.:r:s/.class//:gs#/#.#))
|
: "$classpath[@]"
|
||||||
compadd -M 'r:|.=* r:|=*' -- $c
|
|
||||||
fi
|
for i in "${(s.:.)classpath}"; do
|
||||||
|
if [ -f $i ] && [[ "$i" == *.(jar|zip|war|ear) ]]; then
|
||||||
|
c+=( ${${${(M)$(_call_program jar_classes jar -tf $i)##*.class}%%.class}:gs#/#.#} )
|
||||||
|
elif [ -d $i ]; then
|
||||||
|
c+=( $i/**/*.class(.:r:s/.class//:s#$i/##:gs#/#.#) )
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
_wanted classes expl 'java class' compadd "$@" -M 'r:|.=* r:|=*' -a c
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue