emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 319a2a7: javac support in compilation-parse-errors rules


From: Filipp Gunbin
Subject: master 319a2a7: javac support in compilation-parse-errors rules
Date: Tue, 31 Mar 2020 20:19:35 -0400 (EDT)

branch: master
commit 319a2a742759e5a6738a554918e2030bed6f8188
Author: Filipp Gunbin <address@hidden>
Commit: Filipp Gunbin <address@hidden>

    javac support in compilation-parse-errors rules
    
    * etc/compilation.txt: Add doc and example.
    * lisp/progmodes/compile.el (compilation-error-regexp-alist-alist):
    Add javac rule.
    (compilation-parse-errors): Fix file/line/col test, so that
    lambda/closure (which are valid values) don't match.
    * test/lisp/progmodes/compile-tests.el
    (compile-tests--test-regexps-data, compile-test-error-regexps): Add
    test.
---
 etc/compilation.txt                  | 14 ++++++++++++++
 lisp/progmodes/compile.el            | 26 +++++++++++++++++++++++---
 test/lisp/progmodes/compile-tests.el |  7 +++++--
 3 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/etc/compilation.txt b/etc/compilation.txt
index ebce6a1..8f7e290 100644
--- a/etc/compilation.txt
+++ b/etc/compilation.txt
@@ -237,6 +237,20 @@ 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 use the position
+of "^" in the third line as column number because no explicit value is
+present.
+
+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 e5878b2..a76a3c4 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -265,6 +265,20 @@ of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2 nil (1))
     (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
+       "\\(warning: \\)?.*\n"              ;type (optional) and message
+       ;; line2: source line containing error
+       ".*\n"
+       ;; line3: single "^" under error position in line2
+       " *\\^$")
+     1 2
+     ,(lambda () (1- (current-column)))
+     (3))
+
     (jikes-file
      "^\\(?:Found\\|Issued\\) .* compiling \"\\(.+\\)\":$" 1 nil nil 0)
 
@@ -1466,9 +1480,15 @@ to `compilation-error-regexp-alist' if RULES is nil."
         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 7596256..cd73649 100644
--- a/test/lisp/progmodes/compile-tests.el
+++ b/test/lisp/progmodes/compile-tests.el
@@ -176,6 +176,9 @@
      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 @@ The test data is in `compile-tests--test-regexps-data'."
           (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 ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]