# HG changeset patch # User Claus Gittinger # Date 1578689055 -3600 # Node ID 7248d8fd0b950017d964f4111852a5b09c9a3b53 # Parent 26e3e5c20b527acec85a1006c0930ccb3c6db3a4 class: Object changed: #inspector2TabJSON #printStringLimitedTo: diff -r 26e3e5c20b52 -r 7248d8fd0b95 extensions.st --- a/extensions.st Fri Jan 10 21:41:43 2020 +0100 +++ b/extensions.st Fri Jan 10 21:44:15 2020 +0100 @@ -2414,35 +2414,42 @@ inspector2TabJSON - |jsonPrinter jsonString countRecursive| + |holder jsonPrinter jsonString countRecursive v| (jsonPrinter := Smalltalk classNamed:'JSONPrinter') isNil ifTrue:[^ nil]. - countRecursive := 0. - [ - jsonString := jsonPrinter encodePrettyPrinted:self printLimit:(JSONPrinter defaultPrettyPrintLimit). - ] on:Error do:[:ex | - (ex isKindOf:RecursionError) ifTrue:[ - ex originator == JSONPrinter ifTrue:[ - countRecursive := countRecursive + 1. - countRecursive < 10 ifTrue:[ - ex proceed. + "/ because JSON generation takes a ong time, only do it when the tab's view is mapped. + holder := + [ + jsonString isNil ifTrue:[ + countRecursive := 0. + [ + jsonString := jsonPrinter encodePrettyPrinted:self printLimit:(JSONPrinter defaultPrettyPrintLimit). + ] on:Error do:[:ex | + (ex isKindOf:RecursionError) ifTrue:[ + ex originator == JSONPrinter ifTrue:[ + countRecursive := countRecursive + 1. + countRecursive < 10 ifTrue:[ + ex proceed. + ]. + ]. + ]. + jsonString := '%1\(an instance of %2)\cannot be represented as JSON because:\\%3' withCRs + bindWith:self displayString + with:self class className + with:ex description ]. ]. + jsonString ]. - jsonString := '%1\(an instance of %2)\cannot be represented as JSON because:\\%3' withCRs - bindWith:self displayString - with:self class className - with:ex description - ]. - + + v := HVScrollableView for:TextView. + v autoHideScrollBars:true. + v scrolledView onChange:#visibility evaluate:[v scrolledView model isNil ifTrue:[self halt. v scrolledView model: holder]]. ^ self newInspector2Tab label: 'JSON'; priority: 15; - view: ((HVScrollableView for:TextView) - autoHideScrollBars:true; - contents: jsonString; - yourself) + view: v "Created: / 17-02-2008 / 10:13:07 / janfrog" "Modified: / 11-11-2018 / 12:16:07 / Claus Gittinger"