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: Review request: javac in compilation-error-regexp-alist-alist Date: Thu, 27 Feb 2020 21:17:05 +0300 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="84796"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Feb 27 19:18:11 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 1j7Nje-000Lvp-Ic for ged-emacs-devel@m.gmane-mx.org; Thu, 27 Feb 2020 19:18:10 +0100 Original-Received: from localhost ([::1]:36170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7Njd-0003Bv-L8 for ged-emacs-devel@m.gmane-mx.org; Thu, 27 Feb 2020 13:18:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33196) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7Nig-0002PX-Cj for emacs-devel@gnu.org; Thu, 27 Feb 2020 13:17:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7Nif-0003Up-4S for emacs-devel@gnu.org; Thu, 27 Feb 2020 13:17:10 -0500 Original-Received: from out4-smtp.messagingengine.com ([66.111.4.28]:37939) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7Nie-0003Te-Ro for emacs-devel@gnu.org; Thu, 27 Feb 2020 13:17:09 -0500 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 3DE9921FB5 for ; Thu, 27 Feb 2020 13:17:07 -0500 (EST) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 27 Feb 2020 13:17:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= from:to:subject:date:message-id:mime-version:content-type; s= fm2; bh=PHVyolueU4pxa95fus5nRKEqKfw4LG98KlVIsLIcojU=; b=tYZucCb8 ZjqsIXmSWd7NSQ9USoXYyVOyLtqfM+TgTypAJv79pZoAQACcZmVVjV9FMrD0h8XM 61mQmRu5BlqeaGTe/8fAVLjL+FGnD0abssmln6P4p7aHRhNkfmHy18dkbWznIOxd Po40e8cL1iollBANQfLGCSs/3MgNDu/YL/va1w/zVwr7ol8ZmHzk9EltrGVCMhqT fNMt40QtXC6Plqfb+rLasWZcr8y0H+aO88tN2fNxMpdj7xVLYcT4wdxTjWJupLbU dBkTcQevrKqO97Ub4anI2C2nExmQ8DOIgLwY3MbxjfCyC84dgb5Upq5zDRrDcjn1 6/sag0TpA1GpVw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=PHVyolueU4pxa95fus5nRKEqKfw4L G98KlVIsLIcojU=; b=f5vYWzjh61KAoNn7RToPmsAb7gA/GdvJglUMKYOSG+oci tUuBPwImvyAhIwqGaax7kRyRhzidLPEkNjVj9/h/TRvgHOGQ97vNE/BRFZLOB9BS 3p72W7Azq3AHiI2+ZcBJSFaj/us0/yDzb8Y3fKLHLhjMvKrP/Ta3OW3S1p6nmgJ+ wiHyRMfzTly+NnyXsKljji5tTzRi+8GHGJR6EBULtuu33nIW8s1YKv1lmczUHZHI rzDa7tj36CKHzB9txbNNHL5ehT/hKqWqXQTI1F8SGWn/AUlocfHXDa1S4/iOyLb/ 9pojYtzpnFmC6FGvpkIWNGFx3VWWvFF1n/BERKQbw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrleeigdduuddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkgggtsehttdertddttd dtnecuhfhrohhmpefhihhlihhpphcuifhunhgsihhnuceofhhguhhnsghinhesfhgrshht mhgrihhlrdhfmheqnecukfhppedukeehrdefvddrieekrddufeehnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepfhhguhhnsghinhesfhgrshht mhgrihhlrdhfmh X-ME-Proxy: Original-Received: from fgunbin.local (unknown [185.32.68.135]) by mail.messagingengine.com (Postfix) with ESMTPA id 9B0EF30610DB for ; Thu, 27 Feb 2020 13:17:06 -0500 (EST) Mail-Followup-To: emacs-devel@gnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.28 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:245091 Archived-At: Hi, I've made an attempt to teach compilation-parse-errors to handle javac output. We don't have column number there in the compiler output, and it's very inconvenient, so I'm deducing it from where the visual pointer ("^") points. Is this approach fine, or too dirty to be committed? BTW I fixed a small bug where we check whether file/line/col is consp, and at the same time allow it to be function, so lambda/closure will erroneously match. 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'. Thanks, 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 ==1332== by 0x8008621: main (vtest.c:180) +* 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 symbols: jikes-file jikes-line diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 455f181f50..890b04864a 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -265,6 +265,23 @@ compilation-error-regexp-alist-alist (java "^\\(?:[ \t]+at \\|==[0-9]+== +\\(?:at\\|b\\(y\\)\\)\\).+(\\([^()\n]+\\):\\([0-9]+\\))$" 2 3 nil (1)) + (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 + "[[:space:]]*\\^\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) @@ -1455,9 +1472,15 @@ compilation-parse-errors nil) ;; Not anchored or anchored but already allows empty spaces. (t (setq pat (concat "^\\(?: \\)?" (substring pat 1))))) - (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))) (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/compile-tests.el index 75962566f1..81452c1c38 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") ("==1332== 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.java\":" 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))))) (ert-deftest compile-test-grep-regexps ()