zsh-users
 help / color / mirror / code / Atom feed
* [SUBMIT] _ant completion function
@ 2002-08-17  1:32 Bill Burton
  2002-08-18 10:45 ` Byron Foster
  2002-08-19 14:47 ` Oliver Kiddle
  0 siblings, 2 replies; 9+ messages in thread
From: Bill Burton @ 2002-08-17  1:32 UTC (permalink / raw)
  To: Zsh users

[-- Attachment #1: Type: text/plain, Size: 1703 bytes --]

Hello,

Here's my version of an _ant function for Ant completion support in
versions 1.3 to 1.5.

It's nearly 100% pure zsh with the exception that sed is called to strip
\r's from the output of ant -projecthelp which is a requirement when
running under Cygwin.  If anyone can tell me how to do that with within
zsh I'd appreciate it.  There's also a minor cosmetic issue in that the
default target is printed with a leading space.  The problem is I couldn't
figure out how to do a substitution while condtitionally removing a
trailing space.  Using ? or * didn't work for me to make a space optional.

So far, I've not found a build file that wasn't parsed correctly but then
I haven't done extensive testing either.

Suggested improvements
* Caching of targets on a per build file basis
* Enhance the -logger option with a menu of the standard logger classes
shipping with Ant while still allowing completion on a classname.
* A number of the options support completing on a classname.  However,
this doesn't work unless the class file is in a package under the current
directory.  It would be desirable to complete on any class in the
classpath.  Since Ant's classpath isn't exposed, the best guess would be
to use a classpath of $ANT_HOME/lib/*.jar.

Also, I should mention that Ant 1.5 ships with completion support for zsh
2.5 and up.  Someone wrote a Perl script (bin/complete-ant-cmd.pl) to
support completion for Bash.  I figured out how to get it to run from zsh
and documented it at the top of the script.  Unfortunately, this isn't
mentioned in Ant's documentation.  Although this completion support does
cache targets on a per build file basis, it's using the old completion
system.

-Bill

[-- Attachment #2: _ant --]
[-- Type: text/plain, Size: 3988 bytes --]

#compdef ant

local expl tmp match basedir file buildxml
local curcontext="$curcontext"
local context state line
typeset -A opt_args

_arguments \
    '-help[print help message]' \
    '-projecthelp[print project help information]' \
    '-version[print the version information and exit]' \
    '-diagnostics[print diagnostic information to aide in troubleshooting]' \
    '(-q)-quiet[be extra quiet]' \
    '(-quiet)-q[be extra quiet]' \
    '(-v)-verbose[be extra verbose]' \
    '(-verbose)-v[be extra verbose]' \
    '-debug[print debugging information]' \
    '-emacs[produce logging information without adornments]' \
    '(-l)-logfile[use given file for log]:log file:_files' \
    '(-logfile)-l[use given file for log]:log file:_files' \
    '-logger[class which is to perform logging]:classname:->class' \
    '*-listener[add an instance of class as a project listener]:classname:->class' \
    '(-f)-buildfile[use given build file]:build file:_files -g \*.xml' \
    '(-buildfile)-f[use given build file]:build file:_files -g \*.xml' \
    '-file[use given build file]:build file:_files -g \*.xml' \
    '-D[specify a property]:property:->property' \
    '-propertyfile[load all properties from file (-D overrides)]:property file:_files' \
    '-inputhandler[class which will handle input requests]:classname:->class' \
    '-find[search for build file towards the root of the filesystem]:build file:(build.xml)' \
    '*:targets:->targets' \
     && return 0

[[ -n "$state" ]] &&
case "$state" in

# copied from _java functon
property)
  if compset -P '*='; then
    _default
  else
    _message 'property name'
  fi
  ;;

# copied from _java functon
class)
  match=()
  compset -P '(#b)(*.)'
  basedir=${match[1]//.//}
  _alternative \
    'classes:class:compadd $basedir*.class(.:t:s/.class//)' \
    'packages:package:compadd -qS. $basedir*~$basedir*.*(/:t)'
  ;;

targets)
  #echo "curcontext: \"$curcontext\""
  #echo "words: \"$words[*]\"" > /tmp/_ant-buildargs.tmp
  # Detect any of -find, -buildfile, -file or -f options and save to run with 
  # -projecthelp.
  for arg in "$words[2,-1]"; do
    case $arg in
      (-find|-buildfile|-file|-f)
	buildxml="$arg"
	;;
      (*)
	if [[ -n $buildxml ]]; then
	  buildxml="$buildxml $arg"
	  break
	fi
	;;
    esac
  done
  #echo "$buildxml" >> /tmp/_ant-buildargs.tmp
  ##if _tags targets; then
  #if zstyle -t ":completion:${curcontext}:targets" call-command; then
    # Run ant -projecthelp also passing any of -find, -buildfile or -f options.
    # Parse output into an array of the format "target:description".
    # For the array to be set with correct argument boundaries, the entire
    # set statement needs to be eval'd.  On Cygwin, need to kill \r's output
    # from Java or parsing will fail.
    eval set -A tmp "$(_call_program targets "$words[1]" $buildxml -projecthelp |
        sed 's/\\r$//' |
      while read target desc
      do
      #local target desc default_target
      # This loop reads ant -projecthelp output from versions 1.3 to 1.5
	#target="${target:s@\\r@@}"
	ln="${target}:${desc}"
	[[ $target = "" ]] && continue  # skip blank lines
	case $ln in
	    (Buildfile:*)
		buildfile=$desc
	    ;;
	    (Default:target:*)
		# with version 1.5, target is on the same line
		default_target="${desc/target:/}"
		# versions 1.3 and 1.4 with default target on a separate line
		if [[ -z $default_target ]]; then
		    read junk
		    read default_target junk
		fi
		# Output target again indicating its the default one.
		print -n "'$default_target:(Default target) ' "
	    ;;
	    (Searching:*|Main:targets:|Subtargets::|BUILD:SUCCESSFUL|Total:time:*)
	    ;;
	    (*)
		# Return target and description
		print -n "'$ln ' "
	    ;;
	esac
      done
    )"
    ##fi
  #fi
# test array
#  tmp=(
#    'compile:Compile Application'
#    'jar:Build jar file (default)'
#    'dist:Create Distribution'
#    'clean:'
#  )
  _describe 'Targets' tmp --
  ;;

*)
  _message "unknown state: $state"
  ;;
esac

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [SUBMIT] _ant completion function
  2002-08-17  1:32 [SUBMIT] _ant completion function Bill Burton
@ 2002-08-18 10:45 ` Byron Foster
  2002-08-18 15:09   ` Bart Schaefer
  2002-08-19 14:47 ` Oliver Kiddle
  1 sibling, 1 reply; 9+ messages in thread
From: Byron Foster @ 2002-08-18 10:45 UTC (permalink / raw)
  To: Zsh users

Bill Burton wrote:
> Hello,
> 
> Here's my version of an _ant function for Ant completion support in
> versions 1.3 to 1.5.

Cool, it would be nice to have ant completion for ZSH.

> It's nearly 100% pure zsh with the exception that sed is called to strip
> \r's from the output of ant -projecthelp which is a requirement when
> running under Cygwin.  If anyone can tell me how to do that with within
> zsh I'd appreciate it.

try:

target=${target//^M/}

Where ^M is a quoted insert of the single Cariage Return character 
(#0D).  ie. 'Ctrl-v Ctrl-m' in Zle or vi.

Byron


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [SUBMIT] _ant completion function
  2002-08-18 10:45 ` Byron Foster
@ 2002-08-18 15:09   ` Bart Schaefer
  0 siblings, 0 replies; 9+ messages in thread
From: Bart Schaefer @ 2002-08-18 15:09 UTC (permalink / raw)
  To: Zsh users

On Aug 18,  3:45am, Byron Foster wrote:
} Subject: Re: [SUBMIT] _ant completion function
}
} > It's nearly 100% pure zsh with the exception that sed is called to strip
} > \r's from the output
} 
} target=${target//^M/}
} 
} Where ^M is a quoted insert of the single Cariage Return character 

target=${target//$'\015'}

where you don't need to quoted insert anything.  And yes, the ending slash
is optional when the replacement is empty.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [SUBMIT] _ant completion function
  2002-08-17  1:32 [SUBMIT] _ant completion function Bill Burton
  2002-08-18 10:45 ` Byron Foster
@ 2002-08-19 14:47 ` Oliver Kiddle
  2002-08-20  0:52   ` Felix Rosencrantz
  2002-08-20  1:06   ` Felix Rosencrantz
  1 sibling, 2 replies; 9+ messages in thread
From: Oliver Kiddle @ 2002-08-19 14:47 UTC (permalink / raw)
  To: Bill Burton; +Cc: Zsh users

On 16 Aug, Bill Burton wrote:

> Here's my version of an _ant function for Ant completion support in
> versions 1.3 to 1.5.

Great, thanks. As I suggested in the previous mail, I've gone through
this and merged it with the _ant I posted last week. The _arguments
sections were almost the same and I've used the call-command style to
select between your ant -projecthelp parsing and my sed solution.

> zsh I'd appreciate it.  There's also a minor cosmetic issue in that the
> default target is printed with a leading space.  The problem is I couldn't
> figure out how to do a substitution while condtitionally removing a
> trailing space.  Using ? or * didn't work for me to make a space optional.

Just using ${default_target# } does the job. The other cosmetic issue
was that targets without a description were added with an empty
description instead of with no description. I've attempted to fix this,
hopefully without breaking the rest of it. How do you specify target
descriptions in a build.xml file?

> Suggested improvements
> * A number of the options support completing on a classname.  However,
> this doesn't work unless the class file is in a package under the current
> directory.  It would be desirable to complete on any class in the
> classpath.  Since Ant's classpath isn't exposed, the best guess would be
> to use a classpath of $ANT_HOME/lib/*.jar.

On the 4.1 branch, there is a _java_class function which is meant to do
this but I can't entirely make sense of what it is doing and how to get
it to use $ANT_HOME/lib/*.jar as you suggest. It ought to use
_multi_parts too.

Certainly, this can still be improved. For zsh 4.0, the _java_class
stuff will need the be replaced with the state from Bill's function, the
-e option passed  to _message needs to go and the $ANT_ARGS stuff needs
to go. So don't expect this to work properly on 4.0.

Oliver

Index: _ant
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ant,v
retrieving revision 1.1
diff -u -r1.1 _ant
--- _ant	9 Aug 2002 15:28:24 -0000	1.1
+++ _ant	19 Aug 2002 14:44:00 -0000
@@ -1,8 +1,9 @@
 #compdef ant -value-,ANT_ARGS,-default-
 
 typeset -A opt_args
-local state line curcontext="$curcontext"
+local buildfile tmp state line curcontext="$curcontext"
 local target='*:target:->target'
+#local CLASSPATH="$ANT_HOME/lib/*.jar"
 
 if [[ $service = *ANT_ARGS* ]]; then
   compset -q
@@ -22,17 +23,73 @@
   '-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' \
-  '(-f -file -buildfile)'{-f,-file,-buildfile}'[use specified build
file]:build file:_files' \
-  '*-D[specify property with value to use]:property' \
+  '*-listener[add an instance of class as a project
listener]:classname:_java_class' \
+  '(-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' \
-  '-find[search for buildfile]:file:_files' \
+  '(-f -file -buildfile)-find[search for build file towards the root of
filesystem]:build file:(build.xml)' \
   $target && return
 
-if [[ -n $state ]]; then
-  targets=( $(sed -n 's/ *<target name="\([^"]*\)".*/\1/p' < build.xml)
)
-  # ant can be used to get a list of targets for us like this but it is
slow
-  # targets=( ${${(M)${(f)"$(_call_program targets $words[1]
-projecthelp)"}:# *}# } )
-  _wanted targets expl target compadd -a targets
-fi
+case $state in
+  property)
+    if compset -P '*='; then
+      _default
+    else
+      _message -e properties 'property name'
+    fi
+  ;;
+  target)
+    if zstyle -t ":completion:${curcontext}:targets" call-command; then
+      # Run ant -projecthelp also passing any of -find, -buildfile or
-f options.
+      # Parse output into an array of the format "target:description".
+      # For the array to be set with correct argument boundaries, the
entire
+      # set statement needs to be eval'd.  On Cygwin, need to kill \r's
output
+      # from Java or parsing will fail.
+      eval set -A tmp "${$(_call_program targets "$words[1]" $buildxml
-projecthelp |
+	while read target desc
+	do
+          # This loop reads ant -projecthelp output from versions 1.3
to 1.5
+          ln="${target}${desc:+:$desc}"
+          [[ $target = "" ]] && continue  # skip blank lines
+          case $ln in
+              (Buildfile:*)
+                  buildfile=$desc
+              ;;
+              (Default:target:*)
+                  # with version 1.5, target is on the same line
+                  default_target="${${desc/target:/}# }"
+                  # versions 1.3 and 1.4 with default target on a
separate line
+                  if [[ -z $default_target ]]; then
+                      read junk
+                      read default_target junk
+                  fi
+                  # Output target again indicating its the default one.
+                  print -n "'${default_target}:(Default target) ' "
+              ;;
+
(Searching:*|Main:targets:|Subtargets:|BUILD:SUCCESSFUL|Total:time:
+	      *)
+              ;;
+              (*)
+                  # Return target and description
+                  print -n "'$ln' "
+              ;;
+          esac
+	done
+      )//$'\015'}"
+      _describe 'target' tmp
+    else
+      if [[ -n $opt_args[-find] ]]; then
+	buildfile=( (../)#${opt_args[-find]:-build.xml}(N[-1]) )
+      else
+	buildfile=${(v)opt_args[(I)(-f|-file|-buildfile)]:-build.xml}
+      fi
+      if [[ -f $buildfile ]]; then
+	targets=( $(sed -n 's/ *<target name="\([^"]*\)".*/\1/p' <
$buildfile) )
+	_wanted targets expl target compadd -a targets
+      else
+	_message -e targets target
+      fi
+    fi
+  ;;
+esac

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [SUBMIT] _ant completion function
  2002-08-19 14:47 ` Oliver Kiddle
@ 2002-08-20  0:52   ` Felix Rosencrantz
  2002-08-20  1:06   ` Felix Rosencrantz
  1 sibling, 0 replies; 9+ messages in thread
From: Felix Rosencrantz @ 2002-08-20  0:52 UTC (permalink / raw)
  To: Oliver Kiddle, Bill Burton; +Cc: Zsh users


--- Oliver Kiddle <okiddle@yahoo.co.uk> wrote:
> On 16 Aug, Bill Burton wrote:
> 
> > Here's my version of an _ant function for Ant completion support in
> > versions 1.3 to 1.5.
> 
> Great, thanks. As I suggested in the previous mail, I've gone through
> this and merged it with the _ant I posted last week. The _arguments
> sections were almost the same and I've used the call-command style to
> select between your ant -projecthelp parsing and my sed solution.
> 
> > zsh I'd appreciate it.  There's also a minor cosmetic issue in that the
> > default target is printed with a leading space.  The problem is I couldn't
> > figure out how to do a substitution while condtitionally removing a
> > trailing space.  Using ? or * didn't work for me to make a space optional.
> 
> Just using ${default_target# } does the job. The other cosmetic issue
> was that targets without a description were added with an empty
> description instead of with no description. I've attempted to fix this,
> hopefully without breaking the rest of it. How do you specify target
> descriptions in a build.xml file?
> 
> > Suggested improvements
> > * A number of the options support completing on a classname.  However,
> > this doesn't work unless the class file is in a package under the current
> > directory.  It would be desirable to complete on any class in the
> > classpath.  Since Ant's classpath isn't exposed, the best guess would be
> > to use a classpath of $ANT_HOME/lib/*.jar.
> 
> On the 4.1 branch, there is a _java_class function which is meant to do
> this but I can't entirely make sense of what it is doing and how to get
> it to use $ANT_HOME/lib/*.jar as you suggest. It ought to use
> _multi_parts too.
> 
> Certainly, this can still be improved. For zsh 4.0, the _java_class
> stuff will need the be replaced with the state from Bill's function, the
> -e option passed  to _message needs to go and the $ANT_ARGS stuff needs
> to go. So don't expect this to work properly on 4.0.
> 
> Oliver
> 
> Index: _ant
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ant,v
> retrieving revision 1.1
> diff -u -r1.1 _ant
> --- _ant	9 Aug 2002 15:28:24 -0000	1.1
> +++ _ant	19 Aug 2002 14:44:00 -0000
> @@ -1,8 +1,9 @@
>  #compdef ant -value-,ANT_ARGS,-default-
>  
>  typeset -A opt_args
> -local state line curcontext="$curcontext"
> +local buildfile tmp state line curcontext="$curcontext"
>  local target='*:target:->target'
> +#local CLASSPATH="$ANT_HOME/lib/*.jar"
>  
>  if [[ $service = *ANT_ARGS* ]]; then
>    compset -q
> @@ -22,17 +23,73 @@
>    '-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' \
> -  '(-f -file -buildfile)'{-f,-file,-buildfile}'[use specified build
> file]:build file:_files' \
> -  '*-D[specify property with value to use]:property' \
> +  '*-listener[add an instance of class as a project
> listener]:classname:_java_class' \
> +  '(-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' \
> -  '-find[search for buildfile]:file:_files' \
> +  '(-f -file -buildfile)-find[search for build file towards the root of
> filesystem]:build file:(build.xml)' \
>    $target && return
>  
> -if [[ -n $state ]]; then
> -  targets=( $(sed -n 's/ *<target name="\([^"]*\)".*/\1/p' < build.xml)
> )
> -  # ant can be used to get a list of targets for us like this but it is
> slow
> -  # targets=( ${${(M)${(f)"$(_call_program targets $words[1]
> -projecthelp)"}:# *}# } )
> -  _wanted targets expl target compadd -a targets
> -fi
> +case $state in
> +  property)
> +    if compset -P '*='; then
> +      _default
> +    else
> +      _message -e properties 'property name'
> +    fi
> +  ;;
> +  target)
> +    if zstyle -t ":completion:${curcontext}:targets" call-command; then
> +      # Run ant -projecthelp also passing any of -find, -buildfile or
> -f options.
> +      # Parse output into an array of the format "target:description".
> +      # For the array to be set with correct argument boundaries, the
> entire
> +      # set statement needs to be eval'd.  On Cygwin, need to kill \r's
> output
> +      # from Java or parsing will fail.
> +      eval set -A tmp "${$(_call_program targets "$words[1]" $buildxml
> -projecthelp |
> +	while read target desc
> +	do
> +          # This loop reads ant -projecthelp output from versions 1.3
> to 1.5
> +          ln="${target}${desc:+:$desc}"
> +          [[ $target = "" ]] && continue  # skip blank lines
> +          case $ln in
> +              (Buildfile:*)
> +                  buildfile=$desc
> +              ;;
> +              (Default:target:*)
> +                  # with version 1.5, target is on the same line
> +                  default_target="${${desc/target:/}# }"
> +                  # versions 1.3 and 1.4 with default target on a
> separate line
> +                  if [[ -z $default_target ]]; then
> +                      read junk
> +                      read default_target junk
> +                  fi
> +                  # Output target again indicating its the default one.
> +                  print -n "'${default_target}:(Default target) ' "
> +              ;;
> +
> (Searching:*|Main:targets:|Subtargets:|BUILD:SUCCESSFUL|Total:time:
> +	      *)
> +              ;;
> +              (*)
> +                  # Return target and description
> +                  print -n "'$ln' "
> +              ;;
> +          esac
> +	done
> +      )//$'\015'}"
> +      _describe 'target' tmp
> +    else
> +      if [[ -n $opt_args[-find] ]]; then
> +	buildfile=( (../)#${opt_args[-find]:-build.xml}(N[-1]) )
> +      else
> +	buildfile=${(v)opt_args[(I)(-f|-file|-buildfile)]:-build.xml}
> +      fi
> +      if [[ -f $buildfile ]]; then
> +	targets=( $(sed -n 's/ *<target name="\([^"]*\)".*/\1/p' <
> $buildfile) )
> +	_wanted targets expl target compadd -a targets
> +      else
> +	_message -e targets target
> +      fi
> +    fi
> +  ;;
> +esac
> 
> This e-mail and any attachment is for authorised use by the intended
> recipient(s) only.  It may contain proprietary material, confidential
> information and/or be subject to legal privilege.  It should not be copied,
> disclosed to, retained or used by, any other party.  If you are not an
> intended recipient then please promptly delete this e-mail and any attachment
> and all copies and inform the sender.  Thank you.


__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [SUBMIT] _ant completion function
  2002-08-19 14:47 ` Oliver Kiddle
  2002-08-20  0:52   ` Felix Rosencrantz
@ 2002-08-20  1:06   ` Felix Rosencrantz
  2002-08-20 10:32     ` Oliver Kiddle
  1 sibling, 1 reply; 9+ messages in thread
From: Felix Rosencrantz @ 2002-08-20  1:06 UTC (permalink / raw)
  To: Oliver Kiddle, Bill Burton; +Cc: Zsh users

Sorry about the mis-sent mail....

--- Oliver Kiddle <okiddle@yahoo.co.uk> wrote:
> On 16 Aug, Bill Burton wrote:
> How do you specify target descriptions in a build.xml file?

Target elements have a "description" attribute, like they have a "name"
attribute.

> On the 4.1 branch, there is a _java_class function which is meant to do
> this but I can't entirely make sense of what it is doing and how to get
> it to use $ANT_HOME/lib/*.jar as you suggest. It ought to use
> _multi_parts too.

You don't explain what is confusing you.  Though there are several things
that are a little odd.  One is that in _java, _java_class is called
with flags like "-m main" and "-t doclet".  These are not parsed within
_java_class.  The idea was that it might be possible someday to make
_java_class smarter to look for classes with a "main" method.  Or having
the "doclet" type.  Though this is not implemented.  The problem with
listing all classes from the class path is that there can be a lot of
classes that are not usable in a particular situation.  It would be nice
if zsh could provide some additional filtering.

The other thing is that _java_class looks at opt_args for -classpath or -cp.
This is ugly, really should be a better way to pass these values without
having to go to a state.


> Certainly, this can still be improved. For zsh 4.0, the _java_class
> stuff will need the be replaced with the state from Bill's function, the
> -e option passed  to _message needs to go and the $ANT_ARGS stuff needs
> to go. So don't expect this to work properly on 4.0.

Could we add _java_class to 4.0?  Is there something about it that would
not allow us to add it?

The other thing that would be useful for _java and _ant is if the
-D flag which takes property=value allowed for a completer other than
_default for property value.

Also, adding caching for the build.xml targets/descriptions, and
for _java_class jar files.

-FR.


__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [SUBMIT] _ant completion function
  2002-08-20  1:06   ` Felix Rosencrantz
@ 2002-08-20 10:32     ` Oliver Kiddle
  2002-08-20 16:05       ` Bill Burton
  2002-08-20 19:41       ` Felix Rosencrantz
  0 siblings, 2 replies; 9+ messages in thread
From: Oliver Kiddle @ 2002-08-20 10:32 UTC (permalink / raw)
  To: Felix Rosencrantz; +Cc: Bill Burton, Zsh users

On Mon, Aug 19, 2002 at 06:06:27PM -0700, Felix Rosencrantz wrote:
> 
> Target elements have a "description" attribute, like they have a "name"
> attribute.

Okay thanks.
 
> > On the 4.1 branch, there is a _java_class function which is meant to do
> > this but I can't entirely make sense of what it is doing and how to get
> > it to use $ANT_HOME/lib/*.jar as you suggest. It ought to use
> > _multi_parts too.
> 
> You don't explain what is confusing you.  Though there are several things

Well, a number of things, some of which you've now explained.

In the latter half, after determining that $i is a directory, why does it
then ignore $i when putting together a list based on .class files? Seems
strange to me.

Can a classpath contain things like '*.jar' or for _ant should it be
expanding the glob.

> The other thing is that _java_class looks at opt_args for -classpath or -cp.
> This is ugly, really should be a better way to pass these values without
> having to go to a state.

There is a better way. Have a look in _figlet for an example. Basically
you can use an _arguments spec which looks something like this:
'*:class:_java_class -cp ${(v)~opt_args[(i)(-cp|-classpath)]\:-$CLASSPATH}'
so no states are needed.

It'd be cleaner if _java_class just had an argument to specify the
classpath like this.

> Could we add _java_class to 4.0?  Is there something about it that would
> not allow us to add it?

I'd be in favour of adding it and can't see any particular reason not to.

> Also, adding caching for the build.xml targets/descriptions, and
> for _java_class jar files.

For cacheing the contents of jar files, it might be wise to use the same
cache used by _zip and allow jar completion to also use it.

Oliver


This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [SUBMIT] _ant completion function
  2002-08-20 10:32     ` Oliver Kiddle
@ 2002-08-20 16:05       ` Bill Burton
  2002-08-20 19:41       ` Felix Rosencrantz
  1 sibling, 0 replies; 9+ messages in thread
From: Bill Burton @ 2002-08-20 16:05 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: Felix Rosencrantz, Zsh users

Hello,

Oliver Kiddle wrote:

> Can a classpath contain things like '*.jar' or for _ant should it be
> expanding the glob.

No.  Each element of a classpath is either a directory, a .jar or a .zip
file.  Zip files aren't used as much anymore but there are still some
third party libraries that haven't been converted to jar files yet.

-Bill


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [SUBMIT] _ant completion function
  2002-08-20 10:32     ` Oliver Kiddle
  2002-08-20 16:05       ` Bill Burton
@ 2002-08-20 19:41       ` Felix Rosencrantz
  1 sibling, 0 replies; 9+ messages in thread
From: Felix Rosencrantz @ 2002-08-20 19:41 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: Bill Burton, Zsh users


--- Oliver Kiddle <okiddle@yahoo.co.uk> wrote:
> In the latter half, after determining that $i is a directory, why does it
> then ignore $i when putting together a list based on .class files? Seems
> strange to me.
Yes is a bug, it should be looking for class files under $i.

> Can a classpath contain things like '*.jar' or for _ant should it be
> expanding the glob.

Classpath can not contain globs as far as I know.

> There is a better way. Have a look in _figlet for an example. Basically
> you can use an _arguments spec which looks something like this:
> '*:class:_java_class -cp ${(v)~opt_args[(i)(-cp|-classpath)]\:-$CLASSPATH}'
> so no states are needed.
> 
> It'd be cleaner if _java_class just had an argument to specify the
> classpath like this.

That's better (and correct).  Though it is not compact, not sure what can
be done about that.

> > Also, adding caching for the build.xml targets/descriptions, and
> > for _java_class jar files.
> 
> For cacheing the contents of jar files, it might be wise to use the same
> cache used by _zip and allow jar completion to also use it.

I'm not quite sure I understand exactly how that would work.  The _zip
cache assumes that there is a single zip file that is being cached.
It seems like the _java_class code would be thrashing the cache.

In my situation, I typically will have multiple jar-type files in
my CLASSPATH.  Some jars are from third parties, so they are mostly static.
Other jars have code that changes frequently.  So
it would be nice if there was a per file cache, that would only be
updated as the jar files changed.  Also, it would be useful if the
cache was based on the complete path of the jar file, not just the basename
of the jar, since it is possible to have different versions of the same jar.

Also, feel free to fix _java_class, I don't have much time.

-FR.



__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2002-08-20 21:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-17  1:32 [SUBMIT] _ant completion function Bill Burton
2002-08-18 10:45 ` Byron Foster
2002-08-18 15:09   ` Bart Schaefer
2002-08-19 14:47 ` Oliver Kiddle
2002-08-20  0:52   ` Felix Rosencrantz
2002-08-20  1:06   ` Felix Rosencrantz
2002-08-20 10:32     ` Oliver Kiddle
2002-08-20 16:05       ` Bill Burton
2002-08-20 19:41       ` Felix Rosencrantz

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).