summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2002-08-24 19:19:14 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2002-08-24 19:19:14 +0000
commit043c302261dfee52e54e9a6c42b4ebcc2f7ccd33 (patch)
treedcd922959775f8c5701302c68e4425c285c14465
parentbc5567c859a074e2559b3c94c08ca1003b543da9 (diff)
downloadzsh-043c302261dfee52e54e9a6c42b4ebcc2f7ccd33.tar.gz
zsh-043c302261dfee52e54e9a6c42b4ebcc2f7ccd33.tar.xz
zsh-043c302261dfee52e54e9a6c42b4ebcc2f7ccd33.zip
17577: pass classpath as an option to _java_class pre-opt-arg
-rw-r--r--ChangeLog8
-rw-r--r--Completion/Unix/Command/_ant11
-rw-r--r--Completion/Unix/Command/_java15
-rw-r--r--Completion/Unix/Command/_zip8
-rw-r--r--Completion/Unix/Type/_java_class36
5 files changed, 46 insertions, 32 deletions
diff --git a/ChangeLog b/ChangeLog
index 8a589d5e4..58614413a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
 	read added in 17544
diff --git a/Completion/Unix/Command/_ant b/Completion/Unix/Command/_ant
index 717fa9ea4..d33589bc3 100644
--- a/Completion/Unix/Command/_ant
+++ b/Completion/Unix/Command/_ant
@@ -2,8 +2,9 @@
 
 typeset -A opt_args
 local buildfile tmp state line curcontext="$curcontext"
-local target='*:target:->target'
-#local CLASSPATH="$ANT_HOME/lib/*.jar"
+local c target='*:target:->target'
+
+c=( $ANT_HOME/lib/*.jar )
 
 if [[ $service = *ANT_ARGS* ]]; then
   compset -q
@@ -22,12 +23,12 @@ _arguments -C \
   '-debug[print debugging information]' \
   '-emacs[produce logging information without adornments]' \
   '(-l -logfile)'{-l,-logfile}'[use specified file for log]:logfile:_files' \
-  '-logger[the class which is to perform logging]:classname:_java_class' \
-  '*-listener[add an instance of class as a project listener]: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 -cp ${(j.:.)c}' \
   '(-f -file -buildfile -find)'{-f,-file,-buildfile}'[use specified build file]:build file:_files' \
   '*-D[specify property with value to use]:property:->property' \
   '-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)' \
   $target && return
 
diff --git a/Completion/Unix/Command/_java b/Completion/Unix/Command/_java
index 48ccd4eaf..b2e204164 100644
--- a/Completion/Unix/Command/_java
+++ b/Completion/Unix/Command/_java
@@ -34,8 +34,7 @@ jdb)
 java)
   _arguments -C \
     "$jdb_args[@]" \
-    '(-cp)-classpath[specify path for user class files]:class path:->classpath' \
-    '(-classpath)-cp[specify path for user class files]:class path:->classpath' \
+    '(-cp -classpath)'{-cp,-classpath}'[specify path for user class files]:class path:->classpath' \
     '-D-[specify a property]:property:->property' \
     '(-verbose:class)-verbose[print class information]' \
     '(-verbose)-verbose\:class[print class information]' \
@@ -44,7 +43,7 @@ java)
     '-version[print version]' \
     '-help[print help message]' \
     '(- 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' \
      && return 0
   ;;
@@ -57,7 +56,7 @@ javadoc)
     '-package[display packages, public/protected classes and members only]' \
     '-private[display all classes and members]' \
     '-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' \
     '-1.1[Javadoc 1.1 compatible output]' \
     '-sourcepath[specify path for source files]:source path:->sourcepath' \
@@ -118,7 +117,7 @@ jar)
     jar_cmd="${words[2]#-}"
     tmpassoc=(
       m ':manifest file:_files'
-      f ':archive file:_files -g \*.\(jar\|zip\)'
+      f ':archive file:_files -g \*.\([ejw]ar\|zip\)'
     )
     _arguments -C \
       "${jar_cmd/[^-]*/:dummy:}" \
@@ -140,7 +139,7 @@ javah|javah_g)
     '-bootclasspath[specify path for bootstrap class files]:bootstrap class path:->bootstrapclasspath' \
     '-old[generate old JDK1.0-style header files]' \
     '-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)
@@ -159,7 +158,7 @@ javap)
     '-classpath[specify path for user class files]:class path:->classpath' \
     '-bootclasspath[specify path for bootstrap class files]:bootstrap class path:->bootstrapclasspath' \
     '-extdirs[specify directories for extensions]:extensions directories:->extdirs' \
-    '*:class:_java_class' && return 0
+    '*:class:_java_class ${(kv)opt_args[(i)-classpath]}' && return 0
   ;;
 
 extcheck)
@@ -182,7 +181,7 @@ rmic)
     '-verbose[print verbose messages]' \
     '-v1.1[JDK 1.1 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)
diff --git a/Completion/Unix/Command/_zip b/Completion/Unix/Command/_zip
index 6f83b748f..29c4f85d4 100644
--- a/Completion/Unix/Command/_zip
+++ b/Completion/Unix/Command/_zip
@@ -50,7 +50,7 @@ case $service in
       '(-0 -1 -2 -3 -4 -5 -6 -7 -8   )-9[compress better]' \
       '-x[exclude 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
   ;;
   unzip)
@@ -75,7 +75,7 @@ case $service in
       '-M[page output]' \
       '-x[exclude the following names]' \
       '-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
   ;;
 esac
@@ -98,7 +98,7 @@ if [[ $service == zipinfo ]] || [[ -n $uzi ]]; then
       '(-1 -2)-T[use sortable decimal format for file times]' \
       '-M[page output]' \
       '-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
 fi
 
@@ -112,7 +112,7 @@ case $state in
   ;;
   files)
     if [[ $service = zip ]] && (( ! ${+opt_args[-d]} )); then
-      _files -g '^(#i)*.(zip|[jw]ar)' && return 0
+      _files -g '^(#i)*.(zip|[ejw]ar)' && return 0
     else
       zipfile=( $~line[1](|.zip|.ZIP) )
       [[ -z $zipfile[1] ]] && return 1
diff --git a/Completion/Unix/Type/_java_class b/Completion/Unix/Type/_java_class
index a89ceb3c0..76aeaaa2e 100644
--- a/Completion/Unix/Type/_java_class
+++ b/Completion/Unix/Type/_java_class
@@ -1,16 +1,24 @@
 #autoload
-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
+
+# Should probably add some sort of cache.
+# Should we call _multi_parts insteads 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
+  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
+
+_wanted classes expl 'java class' compadd "$@" -M 'r:|.=* r:|=*' -a c
+