Skip to content
This repository was archived by the owner on Jan 23, 2018. It is now read-only.

Commit 12e96d0

Browse files
committed
Make swank-clojure work under clojure 1.5.0.
The constructor for clojure.lang.Compiler$CompilerException takes an additional column argument under 1.5.0. This patch handles the different arities, and always sets the column to 0 under 1.5.0.
1 parent dcb380a commit 12e96d0

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/swank/commands/basic.clj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119

120120
;;;; Compiler / Execution
121121

122-
(def compiler-exception-location-re #"Exception:.*\(([^:]+):([0-9]+)\)")
122+
(def compiler-exception-location-re #"Exception:.*\(([^:]+):([0-9]+)(:[0-9]+)?\)")
123123
(defn- guess-compiler-exception-location [#^Throwable t]
124124
(when (instance? clojure.lang.Compiler$CompilerException t)
125125
(let [[match file line] (re-find compiler-exception-location-re (str t))]
@@ -196,12 +196,19 @@
196196
(.getLineNumber f))
197197
(catch Exception e 1)))
198198

199+
(defmacro compiler-exception [directory line ex]
200+
`(eval (if (>= (:minor *clojure-version*) 5)
201+
'(clojure.lang.Compiler$CompilerException.
202+
~directory ~line 0 ~ex)
203+
'(clojure.lang.Compiler$CompilerException.
204+
~directory ~line ~ex))))
205+
199206
(defslimefn compile-string-for-emacs [string buffer position directory debug]
200207
(let [start (System/nanoTime)
201208
line (line-at-position directory position)
202209
ret (with-emacs-package
203210
(when-not (= (name (ns-name *ns*)) *current-package*)
204-
(throw (clojure.lang.Compiler$CompilerException.
211+
(throw (compiler-exception
205212
directory line
206213
(Exception. (str "No such namespace: "
207214
*current-package*)))))

test/swank/test_swank/commands/basic.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ list, Alan Dipert and MeikelBrandmeyer."
2222
(deftest guess-compiler-exception-location-test
2323
(is (= '(:location (:file "a.clj") (:line 1) nil)
2424
(guess-compiler-exception-location
25-
(clojure.lang.Compiler$CompilerException. "a.clj" 1 (Exception. "err"))))))
25+
(compiler-exception "a.clj" 1 (Exception. "err"))))))
2626

2727
(deftest exception-location-test
2828
(is (= '(:location (:file "a.clj") (:line 1) nil)
2929
(exception-location
30-
(clojure.lang.Compiler$CompilerException. "a.clj" 1 (Exception. "err")))))))
30+
(compiler-exception "a.clj" 1 (Exception. "err")))))))

0 commit comments

Comments
 (0)