I'm beginning to amass a fairly substantial CLJS code base and while most things just works great, debugging Code is way too hard. Main problem is that stack traces just arent very helpful, just figuring out in which function you actually are is sometimes the hardest part.
So I created a .patch (https://gist.github.com/thheller/4972200) which will turn
Uncaught Error: No protocol method IElement.-to-dom defined for type null:
missing_protocol
(anonymous function)
_to_dom
append__2
append
append__1
append
popup_open__delegate
popup_open
list_objects
dom_event_handler
goog.events.Listener.handleEvent
goog.events.fireListener
goog.events.handleBrowserEvent_
(anonymous function)
into
Uncaught Error: No protocol method IElement.-to-dom defined for type null:
fn_cljs_DOT_core_SLASH_missing_protocol_78
(anonymous function)
fn_thheller_DOT_web_DOT_dom_SLASH__to_dom_89
fn_thheller_DOT_web_DOT_dom_SLASH_append_122__2
fn_thheller_DOT_web_DOT_dom_SLASH_append_122
fn_thheller_DOT_web_DOT_dom_SLASH_append_122__1
fn_thheller_DOT_web_DOT_dom_SLASH_append_122
fn_thheller_DOT_debug_SLASH_popup_open_108__delegate
fn_thheller_DOT_debug_SLASH_popup_open_108
fn_thheller_DOT_debug_SLASH_list_objects_121
fn_thheller_DOT_object_SLASH_dom_event_handler_169
goog.events.Listener.handleEvent
goog.events.fireListener
goog.events.handleBrowserEvent_
(anonymous function)
Not the best example, I forgot which stacktrace actually set me out to do this, but as u can see every fn is now fully qualified. Format may be optimized but its basically "fn_[ns]/[fn name]_[line]".
It compiles fine but produces a little more code since the names can get quite long. Files get a little larger, but {:optimiziations :advanced} takes care of that and AFAICT nothing breaks. Tests pass and my code works. ;)
Is this something anyone would be interested in? Should I open a Ticket?
Regards,
/thomas
PS: If you are using lein-cljsbuild and want a quick test do this:
cd your-project
mkdir lib
cd lib
git clone git://github.com/thheller/clojurescript.git
cd clojurescript
git co debug-friendly-fn-names
cd ..
cd ..
edit project.clj and add ["lib/clojurescript/src/clj" "lib/clojurescript/src/cljs"] to the root :source-paths (not the cljsbuild source paths)
lein cljsbuild clean
lein cljsbuild once
and test your code
Wondering if source maps would be able to adress this kind of problem.
By the way, in my opinion, exceptions like "undefined has no method call()" are the real plague...
--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to the Google Groups "ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojurescrip...@googlegroups.com.
To post to this group, send email to clojur...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript?hl=en.
I created a little cljs snippet which pretty prints functions. Since they usually just dump the source all over you and usually there is no simple way to identify a cljs function via its js source. Although I got kinda good at that. ;)
Anyways gist is here https://gist.github.com/thheller/4972200
Example:
(.log js/console (pr-str name))
=>
#<function fn_cljs_DOT_core_SLASH_name_5876(x) {
if(cljs.core.string_QMARK_.call(null, x)) {
return x
}else {
if(cljs.core.truth_(function() {
var or__3966__auto__ = cljs.core.keyword_QMARK_.call(null, x);
if(or__3966__auto__) {
return or__3966__auto__
}else {
return cljs.core.symbol_QMARK_.call(null, x)
}
}())) {
var i = x.lastIndexOf("/", x.length - 2);
if(i < 0) {
return cljs.core.subs.call(null, x, 2)
}else {
return cljs.core.subs.call(null, x, i + 1)
}
}else {
if("\ufdd0:else") {
throw new Error([cljs.core.str("Doesn't support name: "), cljs.core.str(x)].join(""));
}else {
return null
}
}
}
}>
vs: #<function cljs.core/name line:5876>
I will create a Ticket now.
Cheers,
/thomas
PS: Did my CA arrive yet? Sent it last Monday.
Ticket created: http://dev.clojure.org/jira/browse/CLJS-474
PS: Did my CA arrive yet? Sent it last Monday.