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.3 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 64F552135D for ; Sat, 17 Feb 2024 03:50:29 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1708138229; b=mgP1mOBZVMeNKPjOomr8ZHT2KVOswKRcQJxbhcv/HbRIe2IQa/EFLYkqepxQ8Ao1A0UuCj0ga/ 19v202zy4EVCF5MaQLZnIIb/4jo6yOZ9ktZ+IQajQndP7ThJ1bumOuIOCECpqAY6gWUwxUSapq TlrobWgrus/NQAIAG+HWGoQrvZl8iJUBOZudXP6741T7LHvQknc17Udbm2b/sDC+Kq7YTTW93O eOasW+xTNFkrh3i6d5BYEN5P+rpoWuLn+rQ8C/JCwQg5Iyls+dPaMkvEsnHRv24v8rmoHjziYq EW34gPLixisSCjqHqM2g2trUqffGGWgsX8glzoaewwVEzQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ua1-f50.google.com) smtp.remote-ip=209.85.222.50; 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=1708138229; bh=UXAWORbAjIR1sTvggXZFvRqG1aNj5v0dTqfCjPHViiQ=; 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=LqQ6u0PNr+L1TQ/eUn+bpdu3y84GrwbEUjVHosHQwbPKalqxdSz6tG5MZ68yBCbYB2/qPtZhiD SzuiubIjTanA5imFyJpOiOk+19PQspt31FxYV02U/vNW6dDmNae7YJzrSWsM5wvMR1sTLrsuOa jbgvuA7DAYepu5nlyjO1cBA/gEmngLLM9M4+Pm90/0kZPxPIobJ2PomUyLLp6iJnOyUnepVa/Y iHFzREEL8Wqx/H0qj/jUKvT0m60F320/3d7F9Yty4wsQNPFPxGDfk6hU/wz4J/0guYjDq1cMZ5 G1ixi9Wx5GTzZF/efnhsyMHK6Ywu0mS76rANfcOMfI1ntw==; 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=YiLa/0/hnNI1NgeUwG/u5HNKRZx+NRpGkfZM8AtTLoI=; b=Y/xryX4lv8UYQiNIpaokoif3Zd +mftubAfZk4WwHzyhZnlSONbuckR9rKZjsYjKzAvGEl7wssSk2i+fwgyW7U6CQYGCjeSelpIDcD1r wwhXuIvwVfRVtl0E/Xcp68lMPzyTBbYDu/5Ke0MDrK1Kwl/nWwp6dCi0nXss6b2AzcmquAUaaeUAk aWD/7w3UucXoBh0c8/M1on5brl2u3KjcYdOTChW7pLEIk5p39sVzf5jOZLuxcUdtB1+KXResPHxAL /7M0K9pdRFMkjrYVF5nC8hWl9ptNEHNz84f060iLT+kaWpZDMXlZSoqwSI9GmxOA0zkl4oeUzjywy OmdiIkaQ==; Received: by zero.zsh.org with local id 1rbAma-000AtG-UY; Sat, 17 Feb 2024 02:50:29 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ua1-f50.google.com) smtp.remote-ip=209.85.222.50; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ua1-f50.google.com ([209.85.222.50]:53532) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rbAlx-000AYS-EJ; Sat, 17 Feb 2024 02:49:49 +0000 Received: by mail-ua1-f50.google.com with SMTP id a1e0cc1a2514c-7d2e21181c1so1267619241.3; Fri, 16 Feb 2024 18:49:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708138188; x=1708742988; 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=YiLa/0/hnNI1NgeUwG/u5HNKRZx+NRpGkfZM8AtTLoI=; b=VaYedsU5RxbMzMadfrtWCXYvvuYZUVgCQow1gLcDQxULE783eUww602wXmXCf98zmD AYug9TTJCCLGpSSIoQcn6/ay1TRPkxViBkEYl3WCTW+C8dz298N6vONGnRPhwAaCAJml tKItJDyEoHp2eIfIdwhlgixM+oCoJC0ycRv4c6QC+Suf7bAUdHwq6uMKz8EFxfGZwx0V ddgVrgIKErKjPTu5KakPXhQ78NEi5NupQao0aGhGRLjqf9/VJyinANH9T8WH2EMboUbD Hltv0wQG/IEEatsPpp5ylJi55/f4JYdmgK68fZ30LN9pNhQkMKDZ5hUb0cI2FVJvwU5M zupQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708138188; x=1708742988; 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=YiLa/0/hnNI1NgeUwG/u5HNKRZx+NRpGkfZM8AtTLoI=; b=t52dev/ZdwM0zj//QQ+mEQ+F/eW9OFngZGGKIPWQZI6RWUmzSQvify6Hjk8mysNQF9 mWGTlEJ9+sYQNjVGT0Tv2pYSR9DuhpTQ9jt0+a3sEIZ6ycfI0SnzFt79KzguCAzL4OPo BKUUG+wFIp6PuVEvBnFq8qpx0FQO129fQmvCH59maUgSfY5FCoADAl+U8OYHyZgCUqq5 lTcNR+Rk6i8ScyC5a6sUkvpgefBSM58GmJNnBE82tnrtFGHwpLIpdoS6KAyLV8jz6gNY er8FfF58WBv3LozGIiU7a5kRP4HOuTXewDnJGDhAIjEqa8X9ehTsDoUNR2rRJJgnVg7U AoKQ== X-Gm-Message-State: AOJu0Ywj5qE1wk1gMFXJ6R0btv2zlQYUWzUVAUFZ2bzt34nZ9qyxDz3L LHcnIkHcEpeOFbzt38rfUYw5qVIiWWJ0+V92EIE5QpWbx+xT3TgpDEBe0aK+hfeL5hnf0k3mKIU /c0/8unlCo2Mq072wcg+1BmpQQU/hNmVi X-Google-Smtp-Source: AGHT+IFA08h/CexQ2ULag2Mdh5woC5kGpwm36AE+BN7Ad5shPWnlC7jER3iWZGEZNmiE8rZHG5qiL/wJ0zFecTtl8NY= X-Received: by 2002:a67:fe02:0:b0:470:397e:767e with SMTP id l2-20020a67fe02000000b00470397e767emr1801378vsr.31.1708138187644; Fri, 16 Feb 2024 18:49:47 -0800 (PST) MIME-Version: 1.0 References: <70740-1708132716.601082@rJjR.yILq.82lJ> In-Reply-To: <70740-1708132716.601082@rJjR.yILq.82lJ> From: Henri Tremblay Date: Fri, 16 Feb 2024 21:49:36 -0500 Message-ID: Subject: Re: Java completion for Java files To: Oliver Kiddle Cc: zsh-workers@zsh.org Content-Type: multipart/alternative; boundary="000000000000e6e7ca06118ae9c8" X-Seq: 52553 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --000000000000e6e7ca06118ae9c8 Content-Type: text/plain; charset="UTF-8" Awesome! Thank you so much! On Fri, 16 Feb 2024 at 20:18, Oliver Kiddle 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 > ;; > --000000000000e6e7ca06118ae9c8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Awesome! Thank you so much!

On Fri, 16 Feb 2024 at 20:18, O= liver Kiddle <opk@zsh.org> wrote:<= br>
[ moved to zsh-w= orkers ]

On 5 Feb, Henri Tremblay wrote:
> Java now supports (since Java 10 I think) command lines like=C2=A0
>
> java Math.java=C2=A0
>
> or=C2=A0
>
> java src/main/java/org/me/Math.java.=C2=A0
>
> 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 no= w
valid with java too.

The JEP330 link indicates that with --source, files needn't have a .jav= a
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<= br> index b2352df7b..325413d87 100644
--- a/Completion/Unix/Command/_java
+++ b/Completion/Unix/Command/_java
@@ -82,7 +82,10 @@ java)
=C2=A0 =C2=A0 =C2=A0'(- 1)-X-[non-standard java option]:option' \ =C2=A0 =C2=A0 =C2=A0'(- 1)-jar[specify a program encapsulated as jar]:j= ar:_files -g \*.jar\(-.\)' \
=C2=A0 =C2=A0 =C2=A0'-splash\:-[show splash screen with specified image= ]:image:_files' \
-=C2=A0 =C2=A0 '(-):class:_java_class -m main ${(kv)opt_args[(i)(-class= path|-cp)]}' \
+=C2=A0 =C2=A0 '--source=3D[set the version of the source in source-fil= e mode]:version' \
+=C2=A0 =C2=A0 '(-):arg: _alternative
+=C2=A0 =C2=A0 =C2=A0 "classes\:class\:{ (( ! $+opt_args[--source] )) = && _java_class -m main ${(kv)opt_args[(i)(-classpath|-cp)]} }"=
+=C2=A0 =C2=A0 =C2=A0 "files\:source file\:_files -g \*.java\(-.\)&quo= t;' \
=C2=A0 =C2=A0 =C2=A0'*::args:=3D _normal' \
=C2=A0 =C2=A0 =C2=A0 && return 0
=C2=A0 =C2=A0;;
--000000000000e6e7ca06118ae9c8--