Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Java completion for Java files



On Mon, Feb 5, 2024 at 10:04 AM Henri Tremblay <henri.tremblay@xxxxxxxxx> wrote:
>
> Java now supports (since Java 10 I think) command lines like
>
> java 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 issue is here in the _arguments setup for _java:

    '(-):class:_java_class -m main ${(kv)opt_args[(i)(-classpath|-cp)]}' \
    '*::args:= _normal' \
     && return 0

The (-) says that the first word after "java" must either be an option
(start with "-") or must be a class name.  The completion stops there
unless working on the next word.

How does "java" itself distinguish between a class name and a file
name?  Just whether the string ends in ".java"?




Messages sorted by: Reverse Date, Date, Thread, Author