zsh-workers
 help / color / mirror / code / Atom feed
From: Henri Tremblay <henri.tremblay@gmail.com>
To: Oliver Kiddle <opk@zsh.org>
Cc: zsh-workers@zsh.org
Subject: Re: Java completion for Java files
Date: Fri, 16 Feb 2024 21:49:36 -0500	[thread overview]
Message-ID: <CADZL2=sWMpA9ZpXFaEJwP9vxYjNk4x1feAhPfGf8-hBkcuNTxA@mail.gmail.com> (raw)
In-Reply-To: <70740-1708132716.601082@rJjR.yILq.82lJ>

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

Awesome! Thank you so much!

On Fri, 16 Feb 2024 at 20:18, Oliver Kiddle <opk@zsh.org> wrote:

> [ moved to zsh-workers ]
>
> On 5 Feb, Henri Tremblay wrote:
> > Java now supports (since Java 10 I think) command lines like
> >
> > java Math.java
> >
> > or
> >
> > java src/main/java/org/me/Math.java.
> >
> > It will then just compile and launch that java file. But zsh won't
> autocomplete
> > for that. It only wants a jar, class file or whatever.
>
> The following adds completion for that. This does add --source to the
> options completed because that's needed to limit completion to files
> when it's present. However, there does appear to be many new options
> not covered by the completion. I'd guess that most javac options are now
> valid with java too.
>
> The JEP330 link indicates that with --source, files needn't have a .java
> extension but broadening the file completion in that case is probably
> unhelpful (seems the feature primarily exists to support use with a
> shebang).
>
> Oliver
>
> diff --git a/Completion/Unix/Command/_java b/Completion/Unix/Command/_java
> index b2352df7b..325413d87 100644
> --- a/Completion/Unix/Command/_java
> +++ b/Completion/Unix/Command/_java
> @@ -82,7 +82,10 @@ java)
>      '(- 1)-X-[non-standard java option]:option' \
>      '(- 1)-jar[specify a program encapsulated as jar]:jar:_files -g
> \*.jar\(-.\)' \
>      '-splash\:-[show splash screen with specified image]:image:_files' \
> -    '(-):class:_java_class -m main ${(kv)opt_args[(i)(-classpath|-cp)]}' \
> +    '--source=[set the version of the source in source-file
> mode]:version' \
> +    '(-):arg: _alternative
> +      "classes\:class\:{ (( ! $+opt_args[--source] )) && _java_class -m
> main ${(kv)opt_args[(i)(-classpath|-cp)]} }"
> +      "files\:source file\:_files -g \*.java\(-.\)"' \
>      '*::args:= _normal' \
>       && return 0
>    ;;
>

[-- Attachment #2: Type: text/html, Size: 2446 bytes --]

      reply	other threads:[~2024-02-17  2:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CADZL2=u-c69DmGyWFNMhYRCR0NQ3DtZv9DbuMSGK+iFT6t5ASQ@mail.gmail.com>
2024-02-17  1:18 ` Oliver Kiddle
2024-02-17  2:49   ` Henri Tremblay [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADZL2=sWMpA9ZpXFaEJwP9vxYjNk4x1feAhPfGf8-hBkcuNTxA@mail.gmail.com' \
    --to=henri.tremblay@gmail.com \
    --cc=opk@zsh.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).