Thus, then.
2009/4/6 Scott Blum <[email protected]>
> On Mon, Apr 6, 2009 at 9:16 AM, Scott Blum <[email protected]> wrote:
>
>> return JavaScriptObject.class.desiredAssertionStatus() ?
>> toStringVerbose()? : toStringSimple();
>>
>
> (typo, obviously)
> return JavaScriptObject.class.desiredAssertionStatus() ? toStringVerbose()
> : toStringSimple();
>
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---
Index: user/src/com/google/gwt/core/client/JavaScriptObject.java
===================================================================
--- user/src/com/google/gwt/core/client/JavaScriptObject.java (revision 5194)
+++ user/src/com/google/gwt/core/client/JavaScriptObject.java (working copy)
@@ -99,11 +99,20 @@
}-*/;
/**
- * catch-all toString in lieu of a better mechanism.
- * Basic assumption here is that this code is for debugging only!
+ * Makes a best-effort attempt to get a useful debugging string describing
+ * the give JavaScriptObject. In web mode with assertions disabled, this
+ * will either call and return the JSO's toString() if one exists, or just
+ * return "[JavaScriptObject]". In hosted mode, or with assertions enabled,
+ * some stronger effort is made to represent other types of JSOs, including
+ * inspecting for document nodes' outerHTML and innerHTML, etc.
*/
@Override
- public final native String toString() /*-{
+ public final String toString() {
+ return JavaScriptObject.class.desiredAssertionStatus() ?
+ toStringVerbose() : toStringSimple();
+ }
+
+ public final native String toStringVerbose() /*-{
var defined = function(m) { return typeof m != 'undefined'; };
var strip = function(s) { return s.replace(/\r\n/g, ""); };
// Output nodes that have outerHTML
@@ -125,11 +134,12 @@
if (html) {
return 'IETextRange [' + strip(html) + ']';
} else {
- // NOTE(lars): using pasteHTML to place a | where the range is collapsed
- // if *very* useful when debugging. It also, however, in certain very subtle
- // circumstances change the range being toStringed! If you see different
- // behaviour in debug vs. release builds (or if logging ranges changes the
- // behaviour, comment out the 4 of the 6 lines below containing dup.
+ // NOTE: using pasteHTML to place a | where the range is collapsed
+ // if *very* useful when debugging. It also, however, in certain very
+ // subtle circumstances change the range being toStringed! If you
+ // see different behaviour in debug vs. release builds (or if logging
+ // ranges changes the behaviour, comment out the 4 of the 6 lines
+ // below containing dup.
var dup = this.duplicate();
dup.pasteHTML('|');
var out = 'IETextRange ' + strip(this.parentElement().outerHTML);
@@ -141,4 +151,7 @@
return this.toString ? this.toString() : '[JavaScriptObject]';
}-*/;
+ public final native String toStringSimple() /*-{
+ return this.toString ? this.toString() : '[JavaScriptObject]';
+ }-*/;
}