Skip to content

Commit

Permalink
implant: use present-function-name from cljs-devtools 0.7.1
Browse files Browse the repository at this point in the history
close #25
  • Loading branch information
darwin committed Jun 19, 2016
1 parent 97c62a0 commit efa02d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/implant/dirac/implant.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@

(defn get-function-name [munged-name]
(if (munging/is-cljs-function-name? munged-name)
(second (munging/break-and-demunge-name munged-name))
(munging/present-function-name munged-name)
munged-name))

(defn get-full-function-name [munged-name]
(if (munging/is-cljs-function-name? munged-name)
(string/join "/" (munging/break-and-demunge-name munged-name))
(munging/present-function-name munged-name true true)
munged-name))

(defn get-repl-specials-async []
Expand Down
24 changes: 12 additions & 12 deletions src/implant/dirac/implant/munging.cljs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
(ns dirac.implant.munging
(:require [clojure.string :as string]))
(:require [clojure.string :as string]
[chromex.support :refer-macros [oget oset ocall oapply]]
[devtools.munging :as m]))

(defn is-cljs-function-name? [munged-name]
(some? (re-matches #"^[^$]+\$[^$]+\$.*$" munged-name))) ; must have at least two dollars but not at the beginning
(m/cljs-fn-name? munged-name))

(defn demunge-ns [munged-name]
(string/replace munged-name "$" "."))
(defn ns-detector [name]
(some? (ocall (oget js/window "dirac") "getNamespace" name)))

(defn break-and-demunge-name [munged-name]
(let [index (.lastIndexOf munged-name "$")]
(if (= index -1)
["" (demunge munged-name)]
(let [ns (demunge (demunge-ns (.substring munged-name 0 index)))
name (demunge (.substring munged-name (inc index) (.-length munged-name)))]
[ns name]))))
(defn present-function-name [munged-name & [include-ns? include-protocol-ns?]]
(m/present-function-name munged-name {:include-ns? include-ns?
:include-protocol-ns? include-protocol-ns?
:silence-common-protocols? false
:ns-detector ns-detector}))

(defn ns-to-relpath [ns ext]
(str (string/replace (munge ns) \. \/) "." (name ext)))
(str (string/replace (munge ns) \. \/) "." (name ext)))

0 comments on commit efa02d1

Please sign in to comment.