From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id B3F5023074 for ; Tue, 6 Feb 2024 03:48:45 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1707187725; b=rYafEMa35MGqk+QMwJU9wT6ZDokIgFMF+eyCssoXxt5BFearVcl1Fm5MbXl9Z0R8UdKgqISGlB jQl9xClAUMa5KKpvj26n7yuYKsefRxBTizrFlYmbxxoCJvhSt+WP6LxjJBr/WoTcdzu2+/WMiF /myFdxYI2Ws4qByoQbGPL3DfF4vnGCyh5TdxJqocgGgw+Ac1OtR5TjPIez75snk8KQhCkeyFrY 1ahvJ/EaGNpNuLoCVthxh6ZFnFlB9wdDKEajSyBICSDzOYgA1SERJiGUVxnFYJItycOZMnXjVS FbDoVUsaNaKyvFM8/2mIDeovw1YAHWnnpWOWkCNDFbfE8w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-vs1-f51.google.com) smtp.remote-ip=209.85.217.51; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1707187725; bh=TrYN4cSNw8b1KdOwoiGUuZJwJKUtdc/lNd7QsVZB8ps=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=OC/BHhtvFfEwUgUXvqh0N4WNj8g5fDEH2G5t6ut2V4TAoSqQ++HMM9kqLnlgqvrDFlOKfIQC8e dg1aBorKMTrWcwviRMEsJ0TBvZxeazNWjMMa7qjKf1krpZP5Rh8+606LulnNCw3hsXv7ByEPpZ I7k1dhccp6PNvT5CpVF1axynrt88Ja/tHG6t0Eb7nY2DbJ64Y5XI4z8UXI0b5ENlNZP6uX2Dt7 lnoPjM9ah6SYEcHEog0N4HNMNe7b5biQU3uk6LFlgI2xyNmp6gByipraZz0NZuDjgpMkRewRB3 n+CE+BiDOI47N7Uo+ty9C98EAP5QelgkAA7QZtdPzU41Kw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=6c96eigtjumO/L45hr6dHafgdh4QMaQ5+G9rBM+/rlY=; b=o8CdZc8oT/wbSIUGdpKkZru0Kz QC4ni28uXdqWNZ5sf+ctE5tEIVbrjPjnmLxOCvPKRdy5VsO+Pae4P9NEeqg8g+2f2n8P0ER7i864Z FygYIMks+Zq+nejJRLASQkmRmqB7ITBMANk2CH0QqKpDdd4h5er3sG3tekWh89CUx+NgGDmEdmhio lDEyHcskIT0XviNygwBO3gH3cZc9wgZeZumsZaHsaYgyJyu77lllKUWjP/RN+2Su/BWqRHtjR22JE XSuV0n1jMFaBIBsFmSrZXIwZsOkpwMI2pyCbIBeYssKSpfx2oaKgQB31nmLaeo7P8CkZqCzZwO63Z dkhQN92g==; Received: by zero.zsh.org with local id 1rXBVr-000A5d-J4; Tue, 06 Feb 2024 02:48:43 +0000 Authentication-Results: zsh.org; iprev=pass (mail-vs1-f51.google.com) smtp.remote-ip=209.85.217.51; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-vs1-f51.google.com ([209.85.217.51]:48456) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rXBVA-0009OY-Jg; Tue, 06 Feb 2024 02:48:01 +0000 Received: by mail-vs1-f51.google.com with SMTP id ada2fe7eead31-46d29d26716so380200137.1 for ; Mon, 05 Feb 2024 18:48:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707187679; x=1707792479; darn=zsh.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=6c96eigtjumO/L45hr6dHafgdh4QMaQ5+G9rBM+/rlY=; b=DHIuCa4Cd8OWYNpqsMtduUCeYELbfDeAXn6P+5HxjWtzGOGA3e6CAeZjN6Qibvjm1s okohHahTF+VH3nev3G/F/Ds8EdbHsyDGYYrcGncnP1u2UZ5C3/P7/WE34YLDKjhtyx5I EiVSi44lGxwoUGY48F3fyYdJ5qB75Xex8QMwIP/ctsd+vATX6LlOsntoKS/igm7ngaEV KHlTH96Nv+O8N742gO0y3m75uXJpwTrfl92q46BbO0yqcEURZnG1fXewzuPaOW2b874r lQ9KNwQTFWA7+2M6gDMo6gbROAK80Af8SJgTFp+wbkf3zMA2k1zoVA3AWXozQCfA3ahQ +0+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707187679; x=1707792479; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6c96eigtjumO/L45hr6dHafgdh4QMaQ5+G9rBM+/rlY=; b=B1hbx2NF3B6WRPaIEI7sTAp4efTypK2Oz26EQS+jcPzJNWUMLIBu70Oq5eLiIMmgqY SMVz0Wkg38TnbppvSLtg0Yfwl9li0Uv1roz5m5GIsjNv3lSCIdjCt1n2DbVvGKb9N7AC 1cF55wdCHB7SDIu48zRWwisxAAjGwCjivenJUvIDqttnuIHpv66ThGI628DAJSn0fCW9 7mCpIc2ghStyi79OfXU/3aCQEoc+/YNTCUrPrk7yXAuKuX/vnkMJxZfmvBx5H7oUWkMW Nka34+TI4URa1WPZjLqf6M1vz5ndrJBfQWNsEXT9YIVBgmGtYLzBzBYsdco9Tl7CS4XP /26g== X-Gm-Message-State: AOJu0YyuUsj2Tw5cpxN1EYC8sfMrgMFvswq2V/QpqGEkrjbuxu/UCuet lceo/BB2z62ykb3KWl8n3XciaSSqjiufY0bV5xStE7ftHfM1/z+wXxNi+/OVSi83HyaQz3P9NUL bX3mBzaG9Wce7jAhdw8ctFN7MxqG3aKKhniE= X-Google-Smtp-Source: AGHT+IGAc6XF/9gC//f08r4n/5lSBnTTnmKlnp4HYdsqyBJVGcQkxWlkamaADlni0N0q2oM96Z2Pf+ijEP+G5p+NUJo= X-Received: by 2002:a05:6102:21bc:b0:46d:2b0f:aeb8 with SMTP id i28-20020a05610221bc00b0046d2b0faeb8mr1611484vsb.11.1707187679112; Mon, 05 Feb 2024 18:47:59 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Henri Tremblay Date: Mon, 5 Feb 2024 21:47:48 -0500 Message-ID: Subject: Re: Java completion for Java files To: Bart Schaefer Cc: zsh-users@zsh.org Content-Type: multipart/alternative; boundary="0000000000002db8320610ad9bfc" X-Seq: 29641 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --0000000000002db8320610ad9bfc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Yes. Let's say you have a file in a directory: "src/main/java/org/zsh/Main.java". The class is named Main and is in the package org.zsh in this case. If you compile it with "javac src/main/java/org/zsh/Main.java" it will generate a file named "src/main/java/org/zsh/Main.class". So, if you execute it the old way, you would do "java -cp src/main/java org.zsh.Main" which means "Please execute the class with a main() method that is called Main and found in the package org.zsh. The classpath where this class can be found is "src/main". If you execute it the new way, you don't need to compile with javac. So you only have "src/main/java/org/zsh/Main.java". And you will execute by doing "java src/main/java/org/zsh/Main.java" and that's it. Bottom line, indeed, the ".java" at the end tells that it's a java source file and not a compile class found in the classpath that you want to execute. On Mon, 5 Feb 2024 at 15:44, Bart Schaefer wrote: > On Mon, Feb 5, 2024 at 10:04=E2=80=AFAM Henri Tremblay > 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:=3D _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"? > --0000000000002db8320610ad9bfc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Yes.
Let's say you have a file in a directory: &qu= ot;src/main/java/org/zsh/Main.java". The class is named Main and is in= the package org.zsh in this case.
If you compile it with "j= avac src/main/java/org/zsh/Main.java" it will generate a file named &q= uot;src/main/java/org/zsh/Main.class".

So, if= you execute it the old way, you would do "java -cp src/main/java org.= zsh.Main" which means "Please execute the class with a main() met= hod that is called Main and found in the package org.zsh. The classpath whe= re this class can be found is "src/main".

If you execute it the new way, you don't need to compile with javac. = So you only have "src/main/java/org/zsh/Main.java".
And= you will execute by doing "java src/main/java/org/zsh/Main.java"= and that's it.

Bottom line, indeed, the "= ;.java" at the end tells that it's a java source file and not a co= mpile class found in the classpath that you want to execute.

=

On Mon, 5 Feb 2024 at 15:44, Bart Schaefer <schaefer@brasslantern.com> wrote:
On Mon, Feb 5, 2024 at 10:0= 4=E2=80=AFAM Henri Tremblay <henri.tremblay@gmail.com> 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:

=C2=A0 =C2=A0 '(-):class:_java_class -m main ${(kv)opt_args[(i)(-classp= ath|-cp)]}' \
=C2=A0 =C2=A0 '*::args:=3D _normal' \
=C2=A0 =C2=A0 =C2=A0&& return 0

The (-) says that the first word after "java" must either be an o= ption
(start with "-") or must be a class name.=C2=A0 The completion st= ops there
unless working on the next word.

How does "java" itself distinguish between a class name and a fil= e
name?=C2=A0 Just whether the string ends in ".java"?
--0000000000002db8320610ad9bfc--