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.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,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 8667524068 for ; Sat, 17 Feb 2024 02:18:55 +0100 (CET) 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:Message-ID:Date: Content-Transfer-Encoding:Content-ID:Content-Type:MIME-Version:Subject:To: References:From:In-reply-to:cc:Reply-To:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=ePJ56yiuSvTE0PXndfwwSNFBpW+FPsK9csWIE+zyHHQ=; b=SgNfHqbPe87r+ubXFZoPyP99IH ekW4QjdQ9NFi6sUagzKMl0vVgfrbBdJHFrlcReQpdbaR7kPhTxAH58rWCRf5h+Ih6bDfKxz7NmD14 9BLUdC2bPieV5q10Ixjz2vXMlYaFP9e3/LELKeXyenOCj05jIng8Pmzy7mPVbuiGikbYpC/Lyth4H qFaf7DTpdDdXsHK0kYktR0skpQzhVugaQZAVovhtdu/Phrxi71OdZIAPDoXcWjRQXt7ey6DYN3le5 UswH68AyPAZ134ak1teyfhEbGfbJ3o0+lQFSRWSwG2ByD/cJZpqi8yldo+a1Yo+PVcy4XkO2dzAWX hlonMl1A==; Received: by zero.zsh.org with local id 1rb9Ly-0008CS-96; Sat, 17 Feb 2024 01:18:54 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rb9Lh-0007tE-NQ; Sat, 17 Feb 2024 01:18:37 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.97.1) (envelope-from ) id 1rb9Lg-00000000IOz-2Y4j; Sat, 17 Feb 2024 02:18:36 +0100 cc: zsh-workers@zsh.org In-reply-to: From: Oliver Kiddle References: To: Henri Tremblay Subject: Re: Java completion for Java files MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <70739.1708132716.1@hydra> Content-Transfer-Encoding: 8bit Date: Sat, 17 Feb 2024 02:18:36 +0100 Message-ID: <70740-1708132716.601082@rJjR.yILq.82lJ> X-Seq: 52552 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: [ 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 ;;