* [PATCH] Ant Completion: Find targets recursively
@ 2005-08-26 12:17 Jean-Baptiste Quenot
2005-08-27 20:05 ` Peter Stephenson
0 siblings, 1 reply; 4+ messages in thread
From: Jean-Baptiste Quenot @ 2005-08-26 12:17 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 318 bytes --]
Hello,
Thank you very much for providing support for imported files in
Ant completion. However, recursive handling of imported files was
not supported. Please find attached a patch that adresses this
issue.
This patch is against zsh 4.2.5
Thanks in advance,
--
Jean-Baptiste Quenot
http://caraldi.com/jbq/
[-- Attachment #2: patch-zsh-ant-find-targets --]
[-- Type: text/plain, Size: 1223 bytes --]
--- _ant.orig Wed Aug 3 10:51:03 2005
+++ _ant Fri Aug 26 14:13:05 2005
@@ -14,6 +14,18 @@
unset target
fi
+find_targets() {
+ importedfiles=( $(sed -n "s/ *<import[^>]* file=[\"']\([^\"']*\)[\"'].*/\1/p" < $1) )
+ targets=( $(sed -n "s/ *<target[^>]* name=[\"']\([^\"']*\)[\"'].*/\1/p" $1) )
+ if (( $#importedfiles )) ; then
+ cd $1:h
+ for file in $importedfiles ; do
+ find_targets $file
+ done
+ fi
+ _wanted targets expl target compadd -a targets && ret=0
+}
+
_arguments -C \
'-help[display usage information]' \
'-projecthelp[print project help information]' \
@@ -87,11 +99,7 @@
buildfile=${(v)opt_args[(I)(-f|-file|-buildfile)]:-build.xml}
fi
if [[ -f $buildfile ]]; then
- importedfiles=( $(sed -n "s/ *<import[^>]* file=[\"']\([^\"']*\)[\"'].*/\1/p" < $buildfile) )
- targets=( $(sed -n "s/ *<target[^>]* name=[\"']\([^\"']*\)[\"'].*/\1/p" $buildfile) )
- (( $#importedfiles )) && targets+=( $(cd $buildfile:h;
- sed -n "s/ *<target[^>]* name=[\"']\([^\"']*\)[\"'].*/\1/p" $importedfiles) )
- _wanted targets expl target compadd -a targets && ret=0
+ find_targets $buildfile
else
_message -e targets target
fi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Ant Completion: Find targets recursively
2005-08-26 12:17 [PATCH] Ant Completion: Find targets recursively Jean-Baptiste Quenot
@ 2005-08-27 20:05 ` Peter Stephenson
2005-09-02 8:25 ` Jean-Baptiste Quenot
0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2005-08-27 20:05 UTC (permalink / raw)
To: Jean-Baptiste Quenot, zsh-workers
Jean-Baptiste Quenot wrote:
> Thank you very much for providing support for imported files in
> Ant completion. However, recursive handling of imported files was
> not supported. Please find attached a patch that adresses this
> issue.
This patch clashes with an attempt to parse the output of ant to do
something or other, and will need to be resolved with what's now in the
CVS archive, unfortunately. I'm afraid I can't help since I don't know
enough about ant to see if it's the same thing you're trying, nor to fix
up the clash if it's something different.
--
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
Work: pws@csr.com
Web: http://www.pwstephenson.fsnet.co.uk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Ant Completion: Find targets recursively
2005-08-27 20:05 ` Peter Stephenson
@ 2005-09-02 8:25 ` Jean-Baptiste Quenot
2005-09-05 13:40 ` Jean-Baptiste Quenot
0 siblings, 1 reply; 4+ messages in thread
From: Jean-Baptiste Quenot @ 2005-09-02 8:25 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 871 bytes --]
* Peter Stephenson:
> Jean-Baptiste Quenot wrote:
>
> > Thank you very much for providing support for imported files
> > in Ant completion. However, recursive handling of imported
> > files was not supported. Please find attached a patch that
> > adresses this issue.
>
> This patch clashes with an attempt to parse the output of ant to
> do something or other, and will need to be resolved with what's
> now in the CVS archive, unfortunately.
Oh, that sounds interesting. How to use the new ant completion?
Using ant -projecthelp to find targets is a good idea, but how to
activate it:
if zstyle -t ":completion:${curcontext}:targets" call-command; then
Shall I set « zstyle :completion: » something?
Anyway, for those not using this new code, please find attached an
updated patch against zsh's CVS.
--
Jean-Baptiste Quenot
http://caraldi.com/jbq/
[-- Attachment #2: patch-zsh-ant-find-targets-head --]
[-- Type: text/plain, Size: 1456 bytes --]
Index: _ant
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ant,v
retrieving revision 1.13
diff -u -r1.13 _ant
--- _ant 8 Jun 2005 16:59:32 -0000 1.13
+++ _ant 2 Sep 2005 08:18:37 -0000
@@ -6,6 +6,18 @@
typeset -A opt_args
local buildfile classpath cp userjars importedfiles target='*:target:->target' targets tmp
+find_targets() {
+ importedfiles=( $(sed -n "s/ *<import[^>]* file=[\"']\([^\"']*\)[\"'].*/\1/p" < $1) )
+ targets=( $(sed -n "s/ *<target[^>]* name=[\"']\([^\"']*\)[\"'].*/\1/p" $1) )
+ if (( $#importedfiles )) ; then
+ cd $1:h
+ for file in $importedfiles ; do
+ find_targets $file
+ done
+ fi
+ _wanted targets expl target compadd -a targets && ret=0
+}
+
if [[ $service = *ANT_ARGS* ]]; then
compset -q
words=( fake "$words[@]" )
@@ -114,11 +126,7 @@
)//$'\015'}"
_describe 'target' tmp && ret=0
else
- importedfiles=( $(sed -n "s/ *<import[^>]* file=[\"']\([^\"']*\)[\"'].*/\1/p" < $buildfile) )
- targets=( $(sed -n "s/ *<target[^>]* name=[\"']\([^\"']*\)[\"'].*/\1/p" $buildfile) )
- (( $#importedfiles )) && targets+=( $(cd $buildfile:h;
- sed -n "s/ *<target[^>]* name=[\"']\([^\"']*\)[\"'].*/\1/p" $importedfiles) )
- _wanted targets expl target compadd -a targets && ret=0
+ find_targets $buildfile
fi
else
_message -e targets target
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Ant Completion: Find targets recursively
2005-09-02 8:25 ` Jean-Baptiste Quenot
@ 2005-09-05 13:40 ` Jean-Baptiste Quenot
0 siblings, 0 replies; 4+ messages in thread
From: Jean-Baptiste Quenot @ 2005-09-05 13:40 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 490 bytes --]
Thank you for committing the patch:
----------------------------
revision 1.14
date: 2005/09/02 09:17:32; author: pws; state: Exp; lines: +13 -5
21693: Jean-Baptiste Quenot: recursively find ant targets
However, there was an error in this patch: it has the side effect
to change current working directory when build.xml imports files
from other directories.
Thanks to Philippe Gassmann for pointing out.
Please see patch attached.
--
Jean-Baptiste Quenot
http://caraldi.com/jbq/
[-- Attachment #2: patch-zsh-ant-find-targets-bug --]
[-- Type: text/plain, Size: 1083 bytes --]
Index: _ant
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ant,v
retrieving revision 1.14
diff -u -r1.14 _ant
--- _ant 2 Sep 2005 09:17:32 -0000 1.14
+++ _ant 5 Sep 2005 13:33:26 -0000
@@ -8,14 +8,13 @@
find_targets() {
importedfiles=( $(sed -n "s/ *<import[^>]* file=[\"']\([^\"']*\)[\"'].*/\1/p" < $1) )
- targets=( $(sed -n "s/ *<target[^>]* name=[\"']\([^\"']*\)[\"'].*/\1/p" $1) )
+ sed -n "s/ *<target[^>]* name=[\"']\([^\"']*\)[\"'].*/\1/p" $1
if (( $#importedfiles )) ; then
- cd $1:h
+ ( cd $1:h
for file in $importedfiles ; do
find_targets $file
- done
+ done )
fi
- _wanted targets expl target compadd -a targets && ret=0
}
if [[ $service = *ANT_ARGS* ]]; then
@@ -126,7 +125,8 @@
)//$'\015'}"
_describe 'target' tmp && ret=0
else
- find_targets $buildfile
+ targets=( $(find_targets $buildfile) )
+ _wanted targets expl target compadd -a targets && ret=0
fi
else
_message -e targets target
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-09-05 13:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-26 12:17 [PATCH] Ant Completion: Find targets recursively Jean-Baptiste Quenot
2005-08-27 20:05 ` Peter Stephenson
2005-09-02 8:25 ` Jean-Baptiste Quenot
2005-09-05 13:40 ` Jean-Baptiste Quenot
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).