Permalink
Browse files

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.
  • Loading branch information...
1 parent ed5c8ba commit 0a0640cc0b9c58f2fac06984e4b6962623653475 @tobias tobias committed Nov 29, 2012
Showing with 11 additions and 4 deletions.
  1. +9 −2 src/swank/commands/basic.clj
  2. +2 −2 test/swank/test_swank/commands/basic.clj
@@ -111,7 +111,7 @@
;;;; Compiler / Execution
-(def compiler-exception-location-re #"Exception:.*\(([^:]+):([0-9]+)\)")
+(def compiler-exception-location-re #"Exception:.*\(([^:]+):([0-9]+)(:[0-9]+)?\)")
(defn- guess-compiler-exception-location [#^Throwable t]
(when (instance? clojure.lang.Compiler$CompilerException t)
(let [[match file line] (re-find compiler-exception-location-re (str t))]
@@ -175,12 +175,19 @@
(.getLineNumber f))
(catch Exception e 1)))
+(defmacro compiler-exception [directory line ex]
+ `(eval (if (>= (:minor *clojure-version*) 5)
+ '(clojure.lang.Compiler$CompilerException.
+ ~directory ~line 0 ~ex)
+ '(clojure.lang.Compiler$CompilerException.
+ ~directory ~line ~ex))))
+
(defslimefn compile-string-for-emacs [string buffer position directory debug]
(let [start (System/nanoTime)
line (line-at-position directory position)
ret (with-emacs-package
(when-not (= (name (ns-name *ns*)) *current-package*)
- (throw (clojure.lang.Compiler$CompilerException.
+ (throw (compiler-exception
directory line
(Exception. (str "No such namespace: "
*current-package*)))))
@@ -22,9 +22,9 @@ list, Alan Dipert and MeikelBrandmeyer."
(deftest guess-compiler-exception-location-test
(is (= '(:location (:file "a.clj") (:line 1) nil)
(guess-compiler-exception-location
- (clojure.lang.Compiler$CompilerException. "a.clj" 1 (Exception. "err"))))))
+ (compiler-exception "a.clj" 1 (Exception. "err"))))))
(deftest exception-location-test
(is (= '(:location (:file "a.clj") (:line 1) nil)
(exception-location
- (clojure.lang.Compiler$CompilerException. "a.clj" 1 (Exception. "err")))))))
+ (compiler-exception "a.clj" 1 (Exception. "err")))))))

0 comments on commit 0a0640c

Please sign in to comment.