Skip to content

Commit

Permalink
Merge branch 'master' into compile-file
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoduncan committed Mar 30, 2010
2 parents b1a155a + 63d9545 commit 3f25f3e
Show file tree
Hide file tree
Showing 9 changed files with 274 additions and 103 deletions.
6 changes: 3 additions & 3 deletions src/swank/clj_contrib/macroexpand.clj
Expand Up @@ -3,14 +3,14 @@
(def
#^{:private true}
walk-enabled?
(.getResource (clojure.lang.RT/baseLoader) "clojure/contrib/walk.clj"))
(.getResource (clojure.lang.RT/baseLoader) "clojure/contrib/macro_utils.clj"))

(when walk-enabled?
(require 'clojure.contrib.walk))
(require 'clojure.contrib.macro-utils))

(defmacro macroexpand-all* [form]
(if walk-enabled?
`(clojure.contrib.walk/macroexpand-all ~form)
`(clojure.contrib.macro-utils/mexpand-all ~form)
`(macroexpand ~form)))

(defn macroexpand-all [form]
Expand Down
64 changes: 47 additions & 17 deletions src/swank/commands/basic.clj
Expand Up @@ -37,7 +37,7 @@
(if (= form rdr)
[value last-form]
(recur (read rdr false rdr)
(eval form)
(eval (with-env-locals form))
form)))))))

(defslimefn interactive-eval-region [string]
Expand Down Expand Up @@ -276,19 +276,20 @@ that symbols accessible in the current namespace go first."

;;;; meta dot find

(defn- clean-windows-path [#^String path]
;; Decode file URI encoding and remove an opening slash from
;; /c:/program%20files/... in jar file URLs and file resources.
(or (and (.startsWith (System/getProperty "os.name") "Windows")
(second (re-matches #"^/([a-zA-Z]:/.*)$" path)))
path))

(defn- slime-zip-resource [#^java.net.URL resource]
(let [jar-connection #^java.net.JarURLConnection (.openConnection resource)
;; All kinds of hacking to decode jar file URI encoding and remove
;; an opening slash from /c:/program%20files/...
jar-file (.getPath (.toURI (.getJarFileURL jar-connection)))
zip (if (and (.startsWith (System/getProperty "os.name") "Windows")
(re-seq #"^/[a-zA-Z]:/" jar-file))
(apply str (rest jar-file))
jar-file)]
(list :zip zip (.getEntryName jar-connection))))
jar-file (.getPath (.toURI (.getJarFileURL jar-connection)))]
(list :zip (clean-windows-path jar-file) (.getEntryName jar-connection))))

(defn- slime-file-resource [#^java.net.URL resource]
(list :file (.getFile resource)))
(list :file (clean-windows-path (.getFile resource))))

(defn- slime-find-resource [#^String file]
(let [resource (.getResource (clojure.lang.RT/baseLoader) file)]
Expand Down Expand Up @@ -338,20 +339,49 @@ that symbols accessible in the current namespace go first."
(defslimefn throw-to-toplevel []
(throw *debug-quit-exception*))

(defn invoke-restart [restart]
((nth restart 2)))

(defslimefn invoke-nth-restart-for-emacs [level n]
(if (= n 1)
(let [cause (.getCause *current-exception*)]
(invoke-debugger cause *debug-thread-id*)
(.getMessage cause))
(throw *debug-quit-exception*)))
((invoke-restart (*sldb-restarts* (nth (keys *sldb-restarts*) n)))))

(defslimefn throw-to-toplevel []
(if-let [restart (*sldb-restarts* :quit)]
(invoke-restart restart)))

(defslimefn sldb-continue []
(if-let [restart (*sldb-restarts* :continue)]
(invoke-restart restart)))

(defslimefn sldb-abort []
(if-let [restart (*sldb-restarts* :abort)]
(invoke-restart restart)))


(defslimefn backtrace [start end]
(doall (take (- end start) (drop start (exception-stacktrace *current-exception*)))))
(build-backtrace start end))

(defslimefn buffer-first-change [file-name] nil)

(defn locals-for-emacs [m]
(map #(list :name (name (first %)) :id 0 :value (str (second %))) m))

(defslimefn frame-catch-tags-for-emacs [n] nil)
(defslimefn frame-locals-for-emacs [n] nil)
(defslimefn frame-locals-for-emacs [n]
(if (and (zero? n) *current-env*)
(locals-for-emacs (local-non-functions *current-env*))))

(defslimefn frame-locals-and-catch-tags [n]
(list (frame-locals-for-emacs n)
(frame-catch-tags-for-emacs n)))

(defslimefn debugger-info-for-emacs [start end]
(build-debugger-info-for-emacs start end))

(defslimefn eval-string-in-frame [expr n]
(if (and (zero? n) *current-env*)
(with-bindings *current-env*
(eval expr))))

(defslimefn frame-source-location [n]
(source-location-for-frame
Expand Down
8 changes: 5 additions & 3 deletions src/swank/commands/completion.clj
Expand Up @@ -41,12 +41,14 @@
namespace"
([] (potential-dot *ns*))
([ns]
(map #(str "." %) (set (map method-name (mapcat instance-methods (vals (ns-imports ns))))))))
(map #(str "." %) (set (map member-name (mapcat instance-methods (vals (ns-imports ns))))))))

(defn potential-static
"Returns a list of potential static methods for a given namespace"
"Returns a list of potential static members for a given namespace"
([#^Class class]
(map method-name (static-methods class))))
(concat (map member-name (static-methods class))
(map member-name (static-fields class)))))


(defn potiential-classes-on-path
"Returns a list of Java class and Clojure package names found on the current
Expand Down
8 changes: 8 additions & 0 deletions src/swank/commands/inspector.clj
Expand Up @@ -264,6 +264,14 @@
(binding [*current-connection* (first @*connections*)]
(send-it))))))
(defslimefn inspect-frame-var [frame index]
(if (and (zero? frame) *current-env*)
(let [locals (local-non-functions *current-env*)
object (locals (nth (keys locals) index))]
(with-emacs-package
(reset-inspector)
(inspect-object object)))))
(defslimefn inspector-nth-part [index]
(get @*inspectee-parts* index))
Expand Down

0 comments on commit 3f25f3e

Please sign in to comment.