Skip to content

Commit a451274

Browse files
committed
source mapping for Rhino
1 parent 2500f00 commit a451274

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/clj/cljs/repl/rhino.clj

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,23 @@
172172
{:require-foreign true
173173
:output-dir ".cljs_rhino_repl"
174174
:wrap wrap-fn})
175+
repl/IParseStacktrace
176+
(-parse-stacktrace [this frames-str ret {output-dir :output-dir}]
177+
(vec
178+
(map
179+
(fn [frame-str]
180+
(let [[file-side line-fn-side] (string/split frame-str #":")
181+
file (string/replace file-side #"\s+at\s+" "")
182+
[line function] (string/split line-fn-side #"\s+")]
183+
{:file (string/replace file (str output-dir File/separator) "")
184+
:function (when function
185+
(-> function
186+
(string/replace "(" "")
187+
(string/replace ")" "")))
188+
:line (when line
189+
(Integer/parseInt line))
190+
:column 0}))
191+
(string/split frames-str #"\n"))))
175192
repl/IJavaScriptEnv
176193
(-setup [this opts]
177194
(rhino-setup this opts))
@@ -195,6 +212,15 @@
195212

196213
(comment
197214

215+
(repl/-parse-stacktrace (repl-env)
216+
"\tat .cljs_rhino_repl/goog/../cljs/core.js:4215 (seq)
217+
\tat .cljs_rhino_repl/goog/../cljs/core.js:4245 (first)
218+
\tat .cljs_rhino_repl/goog/../cljs/core.js:5295 (ffirst)
219+
\tat <cljs repl>:1
220+
\tat <cljs repl>:1"
221+
nil
222+
{:output-dir ".cljs_rhino_repl"})
223+
198224
(require '[cljs.repl :as repl])
199225
(require '[cljs.repl.rhino :as rhino])
200226
(def env (rhino/repl-env))

0 commit comments

Comments
 (0)