Skip to content

Commit 213576e

Browse files
committed
Exclude reflection warnings from error overlays
1 parent d7c7d99 commit 213576e

File tree

2 files changed

+38
-20
lines changed

2 files changed

+38
-20
lines changed

cider-eval.el

+18-1
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,8 @@ It delegates the actual error content to the eval or op handler."
615615
(optional ":" (group-n 4 (one-or-more digit)))
616616
" - "))
617617

618+
;; Please keep this in sync with `cider-clojure-compilation-error-regexp',
619+
;; which is a subset of these regexes.
618620
(defconst cider-clojure-compilation-regexp
619621
(eval
620622
`(rx bol (or ,cider-clojure-1.9-error
@@ -629,6 +631,21 @@ lol in this context, compiling:(/foo/core.clj:10:1)\"
629631
\"Syntax error compiling at (src/workspace_service.clj:227:3).\"
630632
\"Unexpected error (ClassCastException) macroexpanding defmulti at (src/haystack/parser.cljc:21:1).\"")
631633

634+
(defconst cider-clojure-compilation-error-regexp
635+
(eval
636+
`(rx bol (or ,cider-clojure-1.9-error
637+
,cider-clojure-1.10-error
638+
,cider-clojure-unexpected-error))
639+
t)
640+
"Like `cider-clojure-compilation-regexp',
641+
but excluding warnings such as reflection warnings.
642+
643+
A few example values that will match:
644+
\"CompilerException java.lang.RuntimeException: Unable to resolve symbol: \\
645+
lol in this context, compiling:(/foo/core.clj:10:1)\"
646+
\"Syntax error compiling at (src/workspace_service.clj:227:3).\"
647+
\"Unexpected error (ClassCastException) macroexpanding defmulti at (src/haystack/parser.cljc:21:1).\"")
648+
632649
(defconst cider--clojure-execution-error-regexp
633650
(append `(sequence
634651
"Execution error "
@@ -922,7 +939,7 @@ depending on the PHASE."
922939
(member phase (cider-clojure-compilation-error-phases))))
923940
;; Only show overlays for things that do look like an exception (#3587):
924941
(or (string-match-p cider-clojure-runtime-error-regexp err)
925-
(string-match-p cider-clojure-compilation-regexp err)))
942+
(string-match-p cider-clojure-compilation-error-regexp err)))
926943
;; Display errors as temporary overlays
927944
(let ((cider-result-use-clojure-font-lock nil)
928945
(trimmed-err (funcall cider-inline-error-message-function err)))

test/cider-error-parsing-tests.el

+20-19
Original file line numberDiff line numberDiff line change
@@ -117,31 +117,32 @@
117117
(expect (col-num info) :to-equal 43)
118118
(expect (face info) :to-equal 'cider-warning-highlight-face))))
119119

120-
(describe "The cider compilation regex"
120+
(describe "The cider compilation regexes"
121121
(it "Recognizes a clojure warning message"
122122
(let ((clojure-compiler-warning "Reflection warning, /tmp/foo/src/foo/core.clj:14:1 - call to java.lang.Integer ctor can't be resolved."))
123123
(expect clojure-compiler-warning :to-match cider-clojure-compilation-regexp)
124124
(expect (progn (string-match cider-clojure-compilation-regexp clojure-compiler-warning)
125125
(match-string 1 clojure-compiler-warning))
126126
:to-equal "warning")))
127-
(it "Recognizes a clojure-1.9 error message"
128-
(let ((clojure-1.9-compiler-error "CompilerException java.lang.RuntimeException: Unable to resolve symbol: lol in this context, compiling:(/tmp/foo/src/foo/core.clj:10:1)"))
129-
(expect clojure-1.9-compiler-error :to-match cider-clojure-compilation-regexp)
130-
(expect (progn (string-match cider-clojure-compilation-regexp clojure-1.9-compiler-error)
131-
(match-string 2 clojure-1.9-compiler-error))
132-
:to-equal "/tmp/foo/src/foo/core.clj")))
133-
(it "Recognizes a clojure-1.10 error message"
134-
(let ((clojure-1.10-compiler-error "Syntax error compiling at (src/ardoq/service/workspace_service.clj:227:3)."))
135-
(expect clojure-1.10-compiler-error :to-match cider-clojure-compilation-regexp)
136-
(expect (progn (string-match cider-clojure-compilation-regexp clojure-1.10-compiler-error)
137-
(match-string 2 clojure-1.10-compiler-error))
138-
:to-equal "src/ardoq/service/workspace_service.clj")))
139-
(it "Recognizes a clojure 'Unexpected error' message"
140-
(let ((clojure-1.10-compiler-error "Unexpected error (ClassCastException) macroexpanding defmulti at (src/haystack/parser.cljc:21:1)."))
141-
(expect clojure-1.10-compiler-error :to-match cider-clojure-compilation-regexp)
142-
(expect (progn (string-match cider-clojure-compilation-regexp clojure-1.10-compiler-error)
143-
(match-string 2 clojure-1.10-compiler-error))
144-
:to-equal "src/haystack/parser.cljc"))))
127+
(dolist (regexp (list cider-clojure-compilation-regexp cider-clojure-compilation-error-regexp))
128+
(it "Recognizes a clojure-1.9 error message"
129+
(let ((clojure-1.9-compiler-error "CompilerException java.lang.RuntimeException: Unable to resolve symbol: lol in this context, compiling:(/tmp/foo/src/foo/core.clj:10:1)"))
130+
(expect clojure-1.9-compiler-error :to-match regexp)
131+
(expect (progn (string-match regexp clojure-1.9-compiler-error)
132+
(match-string 2 clojure-1.9-compiler-error))
133+
:to-equal "/tmp/foo/src/foo/core.clj")))
134+
(it "Recognizes a clojure-1.10 error message"
135+
(let ((clojure-1.10-compiler-error "Syntax error compiling at (src/ardoq/service/workspace_service.clj:227:3)."))
136+
(expect clojure-1.10-compiler-error :to-match regexp)
137+
(expect (progn (string-match regexp clojure-1.10-compiler-error)
138+
(match-string 2 clojure-1.10-compiler-error))
139+
:to-equal "src/ardoq/service/workspace_service.clj")))
140+
(it "Recognizes a clojure 'Unexpected error' message"
141+
(let ((clojure-1.10-compiler-error "Unexpected error (ClassCastException) macroexpanding defmulti at (src/haystack/parser.cljc:21:1)."))
142+
(expect clojure-1.10-compiler-error :to-match regexp)
143+
(expect (progn (string-match regexp clojure-1.10-compiler-error)
144+
(match-string 2 clojure-1.10-compiler-error))
145+
:to-equal "src/haystack/parser.cljc")))))
145146

146147
(describe "cider-clojure-runtime-error-regexp"
147148
(it "Recognizes a clojure-1.10 runtime error message"

0 commit comments

Comments
 (0)