Class.st
changeset 2481 bb9bc51ce5f6
parent 2477 3fb0bf03bb5a
child 2482 a13e40246125
equal deleted inserted replaced
2480:077b0a0f9248 2481:bb9bc51ce5f6
  3510      printStream := Printer new.
  3510      printStream := Printer new.
  3511      Object printFullHierarchyOn:printStream indent:0.
  3511      Object printFullHierarchyOn:printStream indent:0.
  3512      printStream close"
  3512      printStream close"
  3513 
  3513 
  3514     "Modified: 13.12.1996 / 14:13:06 / cg"
  3514     "Modified: 13.12.1996 / 14:13:06 / cg"
  3515 !
       
  3516 
       
  3517 printHierarchyAnswerIndentOn:aStream
       
  3518     "print my class hierarchy on aStream - return indent
       
  3519      recursively calls itself to print superclass and use returned indent
       
  3520      for my description - used in the browser"
       
  3521 
       
  3522     |indent nm|
       
  3523 
       
  3524     indent := 0.
       
  3525     (superclass notNil) ifTrue:[
       
  3526         indent := (superclass printHierarchyAnswerIndentOn:aStream) + 2
       
  3527     ].
       
  3528     aStream spaces:indent.
       
  3529     nm := self name.
       
  3530     aStream nextPutAll:nm; nextPutAll:' ('.
       
  3531     self printInstVarNamesOn:aStream indent:(indent + nm size + 2).
       
  3532     aStream nextPutLine:')'.
       
  3533     ^ indent
       
  3534 
       
  3535     "Modified: 13.12.1996 / 14:13:13 / cg"
       
  3536 !
       
  3537 
       
  3538 printHierarchyOn:aStream
       
  3539     "print my class hierarchy on aStream"
       
  3540 
       
  3541     self printHierarchyAnswerIndentOn:aStream
       
  3542 !
       
  3543 
       
  3544 printInstVarNamesOn:aStream indent:indent
       
  3545     "print the instance variable names indented and breaking at line end"
       
  3546 
       
  3547     self printNameArray:(self instVarNames) on:aStream indent:indent
       
  3548 !
       
  3549 
       
  3550 printNameArray:anArray on:aStream indent:indent
       
  3551     "print an array of strings separated by spaces; when the stream
       
  3552      defines a lineLength, break when this limit is reached; indent
       
  3553      every line; used to printOut instance variable names"
       
  3554 
       
  3555     |thisName nextName arraySize lenMax pos mustBreak line spaces|
       
  3556 
       
  3557     arraySize := anArray size.
       
  3558     arraySize ~~ 0 ifTrue:[
       
  3559         pos := indent.
       
  3560         lenMax := aStream lineLength.
       
  3561         thisName := anArray at:1.
       
  3562         line := ''.
       
  3563         1 to:arraySize do:[:index |
       
  3564             line := line , thisName.
       
  3565             pos := pos + thisName size.
       
  3566             (index == arraySize) ifFalse:[
       
  3567                 nextName := anArray at:(index + 1).
       
  3568                 mustBreak := false.
       
  3569                 (lenMax > 0) ifTrue:[
       
  3570                     ((pos + nextName size) > lenMax) ifTrue:[
       
  3571                         mustBreak := true
       
  3572                     ]
       
  3573                 ].
       
  3574                 mustBreak ifTrue:[
       
  3575                     aStream nextPutLine:line withTabs.
       
  3576                     spaces isNil ifTrue:[
       
  3577                         spaces := String new:indent
       
  3578                     ].
       
  3579                     line := spaces.
       
  3580                     pos := indent
       
  3581                 ] ifFalse:[
       
  3582                     line := line , ' '.
       
  3583                     pos := pos + 1
       
  3584                 ].
       
  3585                 thisName := nextName
       
  3586             ]
       
  3587         ].
       
  3588         aStream nextPutAll:line withTabs
       
  3589     ]
       
  3590 
       
  3591     "Created: 10.12.1995 / 16:34:23 / cg"
       
  3592     "Modified: 9.11.1996 / 00:12:06 / cg"
       
  3593 !
  3515 !
  3594 
  3516 
  3595 printOutCategory:aCategory on:aPrintStream
  3517 printOutCategory:aCategory on:aPrintStream
  3596     "print out all methods in aCategory on aPrintStream should be a PrintStream"
  3518     "print out all methods in aCategory on aPrintStream should be a PrintStream"
  3597 
  3519 
  4913 ! !
  4835 ! !
  4914 
  4836 
  4915 !Class class methodsFor:'documentation'!
  4837 !Class class methodsFor:'documentation'!
  4916 
  4838 
  4917 version
  4839 version
  4918     ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.262 1997-03-21 14:45:05 cg Exp $'
  4840     ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.263 1997-03-22 13:14:21 cg Exp $'
  4919 ! !
  4841 ! !
  4920 Class initialize!
  4842 Class initialize!