-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implant: use present-function-name from cljs-devtools 0.7.1
close #25
- Loading branch information
Showing
2 changed files
with
14 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) |