From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Filipp Gunbin Newsgroups: gmane.emacs.devel Subject: Re: Review request: javac in compilation-error-regexp-alist-alist Date: Sat, 29 Feb 2020 02:02:33 +0300 Message-ID: References: <81FF6512-6E29-46F7-9AAD-324D915B3F2F@acm.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="109071"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin) Cc: emacs-devel@gnu.org To: Mattias =?utf-8?Q?Engdeg=C3=A5rd?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Feb 29 00:03:18 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j7of7-000SGu-Gr for ged-emacs-devel@m.gmane-mx.org; Sat, 29 Feb 2020 00:03:17 +0100 Original-Received: from localhost ([::1]:54760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7of6-000795-Hn for ged-emacs-devel@m.gmane-mx.org; Fri, 28 Feb 2020 18:03:16 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48602) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7oeZ-0006h8-Kp for emacs-devel@gnu.org; Fri, 28 Feb 2020 18:02:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7oeY-0007a5-4f for emacs-devel@gnu.org; Fri, 28 Feb 2020 18:02:43 -0500 Original-Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:52827) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7oeX-0007Xl-Ob for emacs-devel@gnu.org; Fri, 28 Feb 2020 18:02:42 -0500 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 8C258D2C; Fri, 28 Feb 2020 18:02:36 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 28 Feb 2020 18:02:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type:content-transfer-encoding; s=fm2; bh= EJgJFkXSYXJu1SnJsIvGTcaVbltezzw4dqgilbmx354=; b=Ad+hLJA4iZ+bo99o vlgVD9fbi0HK0hinrNPvD51hzQe/6nKdVLjyOwLSmCN2Nov9fgV22keRwgQeuD09 qSMYnvPqvX4IRSFlpxqQNs9B0VifWYadwTpbgjCAIcMImi7RBYNQo/X+IRmpKEdr AXDjsABLPKsLfgdHzTxY3yuooCnO5W0hlpzn/Fr/BcSrEhVYdxF4SBNawnHU3YVi yMkG9QE55KuybkuMLlFFFmNptWiR0W+LVJ18op8xVsQPbNj0nvFmSQly4efAsaOQ nTAukHmFhnZ5YIsOf9Y88VEUKeyr8SnsNeijOUAiqWd/rv2LC2lT2hjRM2GWAt2W ws653g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=EJgJFkXSYXJu1SnJsIvGTcaVbltezzw4dqgilbmx3 54=; b=zFbDQD8EEecD4pvdiUHLvhcx5NOrBpux6dmXbtpasN8QxkW8fTN3FyoE/ gEM2naYsjEq2S6KVBVfeHcA8H+H0Jkfch32cpaN7I2vcQp3N1eReFqYfZFcL0h0f vmE7gfghFo4O1NNjhZAeDrWlquXlm7jZ07GjKx1z9ijbcWer4v+KrDsT4wz2JJtU I2VeD4M2Y5IFwz9P/uhiVSSb0Ex6udaC+43mMR6Vt2oDTolR+a0vQPh5Om7f5k4E WnrioipV4vVmDUEAlGp3ebKjj9Rd6FaWYesvsTZ2+QHnFc21NWWyl3nbm5QnHbh6 8hCCoOHq1gL8O1uU/VG4dCD6njVlw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrleelucetufdoteggodetrfdotffvucfrrh hofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurh ephffvufgjfhgffffkgggtgfesthhqredttderjeenucfhrhhomhephfhilhhiphhpucfi uhhnsghinhcuoehfghhunhgsihhnsehfrghsthhmrghilhdrfhhmqeenucfkphepudekhe drfedvrdeikedrudefheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpehfghhunhgsihhnsehfrghsthhmrghilhdrfhhm X-ME-Proxy: Original-Received: from fgunbin.local (unknown [185.32.68.135]) by mail.messagingengine.com (Postfix) with ESMTPA id 472B93280062; Fri, 28 Feb 2020 18:02:35 -0500 (EST) In-Reply-To: <81FF6512-6E29-46F7-9AAD-324D915B3F2F@acm.org> ("Mattias =?utf-8?Q?Engdeg=C3=A5rd=22's?= message of "Fri, 28 Feb 2020 18:11:21 +0100") Mail-Followup-To: Mattias =?utf-8?Q?Engdeg=C3=A5rd?= , emacs-devel@gnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:245115 Archived-At: Hi Mattias, thanks for the helpful comments, corrected patch below. On 28/02/2020 18:11 +0100, Mattias Engdeg=C3=A5rd wrote: > 27 feb. 2020 kl. 19.17 skrev Filipp Gunbin : > >> Besides that, `java' symbol in the said list is a misnomer: it handles >> java exceptions (why? we would never normally have them in the >> compilation output), and valgrind output. Looks like we should just >> rename it to `valgrind'. > > Maybe, but as you can see there are several questionably-named entries > in the list. Renaming them may break user customisation. Good point. > As it is, it would be useful with a comment explaining the difference > between 'java' and 'javac' in the list. One mentions java exceptions, another - javac compiler, I guess that's enough. > (Could I entice you into writing this regexp in rx? Not mandatory in > any way, but at least some of us who read it will thank you.) I'm not experienced with it yet, but noted, will do later. > There's an unnecessary ambiguity after the line number and colon; a > string of spaces can match in multiple ways. Also, avoid [[:space:]] > since you don't control that syntax class in the buffer; more likely > it should just be plain spaces, as it's very unlikely that the javac > caret output routine would use anything else. All corrected. >> + 1 2 >> + (lambda () > > If you add a comma before the lambda-expression, it gets evaluated, > byte-compiled, syntax-checked etc. Right. >> + ("/src/Test.java:5: ';' expected\n foo foo\n ^= \n" 1 15 5 "/src/Test.java" 2) >> + ("e:\\src\\Test.java: 7: warning: ';' expected\n foo foo\n = ^\n" 1 10 7 "e:\\src\\Test.java" 1) > > Why the differences in spacing before the line number? Is it a > difference between platforms, error/warning, javac versions, or just > different compilers altogether? Comments explaining this would be > useful. Be sure to include variants in compilation.txt. Completely imagined by me, removed. Filipp diff --git a/etc/compilation.txt b/etc/compilation.txt index ebce6a14d0..ed2eecd778 100644 --- a/etc/compilation.txt +++ b/etc/compilation.txt @@ -237,6 +237,19 @@ Register 6 contains wrong type =3D=3D1332=3D=3D by 0x8008621: main (vtest.c:180) =20 =20 +* javac Java compiler + +symbol: javac + +Should also work when compiling Java with Gradle. We don't have +column number, but we try to deduce it from position of "^". + +Test.java:5: error: ';' expected + foo foo + ^ +1 error + + * IBM jikes =20 symbols: jikes-file jikes-line diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 455f181f50..6411c577f7 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -265,6 +265,23 @@ compilation-error-regexp-alist-alist (java "^\\(?:[ \t]+at \\|=3D=3D[0-9]+=3D=3D +\\(?:at\\|b\\(y\\)\\)\\).+(\\(= [^()\n]+\\):\\([0-9]+\\))$" 2 3 nil (1)) =20 + (javac + ,(concat + ;; line1 + "^\\(\\(?:[A-Za-z]:\\)?[^:\n]+\\):" ;file + "\\([0-9]+\\): " ;line + "\\(?:\\(?:error\\|\\(warning\\)\\): \\)?[^\n]*\n" ;type (optional)= and message + ;; line2: source line containing error + "[^\n]*\n" + ;; line3: single "^" under error position in line2 + " *\\^\n") + 1 2 + ,(lambda () + (save-excursion + (backward-char 2) ; move back over "^\n" + (current-column))) + (3)) + (jikes-file "^\\(?:Found\\|Issued\\) .* compiling \"\\(.+\\)\":$" 1 nil nil 0) =20 @@ -1455,9 +1472,15 @@ compilation-parse-errors nil) ;; Not anchored or anchored but already allows empty spaces. (t (setq pat (concat "^\\(?: \\)?" (substring pat 1))))) =20 - (if (consp file) (setq fmt (cdr file) file (car file))) - (if (consp line) (setq end-line (cdr line) line (car line))) - (if (consp col) (setq end-col (cdr col) col (car col))) + (if (and (consp file) (not (functionp file))) + (setq fmt (cdr file) + file (car file))) + (if (and (consp line) (not (functionp line))) + (setq end-line (cdr line) + line (car line))) + (if (and (consp col) (not (functionp col))) + (setq end-col (cdr col) + col (car col))) =20 (unless (or (null (nth 5 item)) (integerp (nth 5 item))) (error "HYPERLINK should be an integer: %s" (nth 5 item))) diff --git a/test/lisp/progmodes/compile-tests.el b/test/lisp/progmodes/com= pile-tests.el index 75962566f1..cd736497e6 100644 --- a/test/lisp/progmodes/compile-tests.el +++ b/test/lisp/progmodes/compile-tests.el @@ -176,6 +176,9 @@ compile-tests--test-regexps-data 13 nil 217 "../src/Lib/System.cpp") ("=3D=3D1332=3D=3D by 0x8008621: main (vtest.c:180)" 13 nil 180 "vtest.c") + ;; javac + ("/src/Test.java:5: ';' expected\n foo foo\n ^\n"= 1 15 5 "/src/Test.java" 2) + ("e:\\src\\Test.java:7: warning: ';' expected\n foo foo\n ^= \n" 1 10 7 "e:\\src\\Test.java" 1) ;; jikes-file jikes-line ("Found 2 semantic errors compiling \"../javax/swing/BorderFactory.jav= a\":" 1 nil nil "../javax/swing/BorderFactory.java") @@ -431,8 +434,8 @@ compile-test-error-regexps (compilation-num-warnings-found 0) (compilation-num-infos-found 0)) (mapc #'compile--test-error-line compile-tests--test-regexps-data) - (should (eq compilation-num-errors-found 93)) - (should (eq compilation-num-warnings-found 36)) + (should (eq compilation-num-errors-found 94)) + (should (eq compilation-num-warnings-found 37)) (should (eq compilation-num-infos-found 26))))) =20 (ert-deftest compile-test-grep-regexps ()