Skip to content

Commit

Permalink
devtools: label anonymous functions as "λ"
Browse files Browse the repository at this point in the history
related: 194b1a6
  • Loading branch information
darwin committed Oct 9, 2016
1 parent 8219458 commit f253859
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion resources/unpacked/devtools/front_end/ui/UIUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ WebInspector.initializeUIUtils = function(document, themeSetting)
*/
WebInspector.beautifyFunctionName = function(name)
{
if (name && dirac.hasBeautifyFunctionNames) {
if (dirac.hasBeautifyFunctionNames) {
return dirac.getFunctionName(name);
}

Expand Down
15 changes: 9 additions & 6 deletions src/implant/dirac/implant/munging.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
[devtools.munging :as m]))

(defn is-cljs-function-name? [munged-name]
(m/cljs-fn-name? munged-name))
(or (empty? munged-name)
(m/cljs-fn-name? munged-name)))

(defn ns-detector [name]
(let [demunged-name (demunge name)
namespace-descriptor (ocall (oget js/window "dirac") "getNamespace" demunged-name)]
(some? namespace-descriptor)))

(defn present-function-name [munged-name & [include-ns? include-protocol-ns?]]
(let [present-opts {:include-ns? include-ns?
:include-protocol-ns? include-protocol-ns?
:silence-common-protocols? false
:ns-detector ns-detector}]
(m/present-function-name munged-name present-opts)))
(if (empty? munged-name)
"λ"
(let [present-opts {:include-ns? include-ns?
:include-protocol-ns? include-protocol-ns?
:silence-common-protocols? false
:ns-detector ns-detector}]
(m/present-function-name munged-name present-opts))))

(defn ns-to-relpath [ns ext]
(str (string/replace (munge ns) \. \/) "." (name ext)))
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
(<!* a/wait-for-devtools-match "setCurrentPanel: sources")
(is (= (line-count (<!* a/scrape! :callstack-pane-functions)) 10))
(<!* a/wait-for-match "* breakpoint-demo / dirac.tests.scenarios.breakpoint.core/breakpoint-demo")
(<!* a/wait-for-match "* (anonymous)")
(<!* a/wait-for-match "* λ")
(<!* a/wait-for-match "* call-trigger! / dirac.automation.scenario/call-trigger!"))))
(with-scenario "breakpoint"
(testing "disabled :beautify-function-names feature"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ automate #1 scrape! [:callstack-pane-functions]
stdout displayed 9 items:
* breakpoint-demo / dirac.tests.scenarios.breakpoint.core/breakpoint-demo
* breakpoint-demo-handler / dirac.tests.scenarios.breakpoint.core/breakpoint-demo-handler
* (anonymous)
* λ / λ
* IFn:-invoke² (apply) / cljs.core.IFn:-invoke² (cljs.core/apply)
* apply / cljs.core/apply
* call-trigger! / dirac.automation.scenario/call-trigger!
Expand Down Expand Up @@ -102,7 +102,7 @@ stdout displayed 30 items:
* fancy-$%$#%$#-function???-name
* exception-demo!
* exception-demo-handler
* (anonymous)
* λ
* IFn:-invoke² (apply)
* apply
* call-trigger!
Expand All @@ -129,14 +129,14 @@ devtools #4 setCurrentPanel: sources
automate #4 scrape! [:callstack-pane-functions]
stdout displayed 10 items:
* break-here! / dirac.tests.scenarios.core-async/break-here!
* (anonymous)
* (anonymous)
* λ / λ
* λ / λ
* break-async-$-state-machine--*gen-num*--auto----*gen-num* / dirac.tests.scenarios.core-async/break-async-$-state-machine--*gen-num*--auto----*gen-num*
* break-async-$-state-machine--*gen-num*--auto-- / dirac.tests.scenarios.core-async/break-async-$-state-machine--*gen-num*--auto--
* run-state-machine / cljs.core.async.impl.ioc-helpers/run-state-machine
* run-state-machine-wrapped / cljs.core.async.impl.ioc-helpers/run-state-machine-wrapped
* (anonymous)
* (anonymous)
* λ / λ
* λ / λ
* process-messages / cljs.core.async.impl.dispatch/process-messages
automate #4 close-devtools!
extension handling command: close-dirac-devtools
Expand Down

0 comments on commit f253859

Please sign in to comment.