Kernel-Classes.st 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  1. Smalltalk current createPackage: 'Kernel-Classes'!
  2. Object subclass: #Behavior
  3. instanceVariableNames: ''
  4. package: 'Kernel-Classes'!
  5. !Behavior commentStamp!
  6. I am the superclass of all class objects.
  7. I define the protocol for creating instances of a class with `#basicNew` and `#new` (see `boot.js` for class constructors details).
  8. My instances know about the subclass/superclass relationships between classes, contain the description that instances are created from,
  9. and hold the method dictionary that's associated with each class.
  10. I also provides methods for compiling methods, examining the method dictionary, and iterating over the class hierarchy.!
  11. !Behavior methodsFor: 'accessing'!
  12. >> aString
  13. ^ self methodAt: aString
  14. !
  15. allInstanceVariableNames
  16. | result |
  17. result := self instanceVariableNames copy.
  18. self superclass ifNotNil: [
  19. result addAll: self superclass allInstanceVariableNames].
  20. ^result
  21. !
  22. allSelectors
  23. ^ self allSuperclasses
  24. inject: self selectors
  25. into: [ :acc :each | acc addAll: each selectors; yourself ]
  26. !
  27. allSubclasses
  28. "Answer an collection of the receiver's and the receiver's descendent's subclasses. "
  29. | subclasses index |
  30. subclasses := self subclasses.
  31. index := 1.
  32. [ index > subclasses size ]
  33. whileFalse: [ subclasses addAll: (subclasses at: index) subclasses.
  34. index := index + 1 ].
  35. ^ subclasses
  36. !
  37. allSuperclasses
  38. self superclass ifNil: [ ^ #() ].
  39. ^ (OrderedCollection with: self superclass)
  40. addAll: self superclass allSuperclasses;
  41. yourself
  42. !
  43. comment
  44. ^(self basicAt: 'comment') ifNil: ['']
  45. !
  46. comment: aString
  47. self basicAt: 'comment' put: aString.
  48. SystemAnnouncer current
  49. announce: (ClassCommentChanged new
  50. theClass: self;
  51. yourself)
  52. !
  53. commentStamp
  54. ^ClassCommentReader new
  55. class: self;
  56. yourself
  57. !
  58. commentStamp: aStamp prior: prior
  59. ^self commentStamp
  60. !
  61. definition
  62. ^ ''
  63. !
  64. instanceVariableNames
  65. <return self.iVarNames>
  66. !
  67. lookupSelector: selector
  68. "Look up the given selector in my methodDictionary.
  69. Return the corresponding method if found.
  70. Otherwise chase the superclass chain and try again.
  71. Return nil if no method is found."
  72. | lookupClass |
  73. lookupClass := self.
  74. [ lookupClass = nil ] whileFalse: [
  75. (lookupClass includesSelector: selector)
  76. ifTrue: [ ^ lookupClass methodAt: selector ].
  77. lookupClass := lookupClass superclass ].
  78. ^ nil
  79. !
  80. methodAt: aString
  81. ^ self methodDictionary at: aString
  82. !
  83. methodDictionary
  84. <var dict = smalltalk.HashedCollection._new();
  85. var methods = self.methods;
  86. for(var i in methods) {
  87. if(methods[i].selector) {
  88. dict._at_put_(methods[i].selector, methods[i]);
  89. }
  90. };
  91. return dict>
  92. !
  93. methods
  94. ^ self methodDictionary values
  95. !
  96. methodsFor: aString
  97. ^ClassCategoryReader new
  98. class: self category: aString;
  99. yourself
  100. !
  101. methodsFor: aString stamp: aStamp
  102. "Added for compatibility, right now ignores stamp."
  103. ^self methodsFor: aString
  104. !
  105. methodsInProtocol: aString
  106. ^ (self methodDictionary values select: [ :each | each protocol = aString ])
  107. sorted: [ :a :b | a selector <= b selector ]
  108. !
  109. name
  110. <return self.className || nil>
  111. !
  112. organization
  113. ^ self basicAt: 'organization'
  114. !
  115. ownMethods
  116. "Answer the methods of the receiver that are not package extensions"
  117. ^ (self ownProtocols
  118. inject: OrderedCollection new
  119. into: [ :acc :each | acc, (self methodsInProtocol: each) ])
  120. sorted: [ :a :b | a selector <= b selector ]
  121. !
  122. ownProtocols
  123. "Answer the protocols of the receiver that are not package extensions"
  124. ^ self protocols reject: [ :each |
  125. each match: '^\*' ]
  126. !
  127. protocols
  128. ^ self organization elements sorted
  129. !
  130. prototype
  131. <return self.fn.prototype>
  132. !
  133. selectors
  134. ^ self methodDictionary keys
  135. !
  136. subclasses
  137. self subclassResponsibility
  138. !
  139. superclass
  140. <return self.superclass || nil>
  141. !
  142. theMetaClass
  143. ^ self class
  144. !
  145. theNonMetaClass
  146. ^ self
  147. !
  148. withAllSubclasses
  149. ^(Array with: self) addAll: self allSubclasses; yourself
  150. ! !
  151. !Behavior methodsFor: 'compiling'!
  152. addCompiledMethod: aMethod
  153. | oldMethod announcement |
  154. oldMethod := self methodDictionary
  155. at: aMethod selector
  156. ifAbsent: [ nil ].
  157. (self protocols includes: aMethod protocol)
  158. ifFalse: [ self organization addElement: aMethod protocol ].
  159. self basicAddCompiledMethod: aMethod.
  160. announcement := oldMethod
  161. ifNil: [
  162. MethodAdded new
  163. method: aMethod;
  164. yourself ]
  165. ifNotNil: [
  166. MethodModified new
  167. oldMethod: oldMethod;
  168. method: aMethod;
  169. yourself ].
  170. SystemAnnouncer current
  171. announce: announcement
  172. !
  173. compile: aString
  174. ^ self compile: aString category: ''
  175. !
  176. compile: aString category: anotherString
  177. ^ Compiler new
  178. install: aString
  179. forClass: self
  180. category: anotherString
  181. !
  182. recompile
  183. ^ Compiler new recompile: self
  184. !
  185. removeCompiledMethod: aMethod
  186. self basicRemoveCompiledMethod: aMethod.
  187. self methods
  188. detect: [ :each | each protocol = aMethod protocol ]
  189. ifNone: [ self organization removeElement: aMethod protocol ].
  190. SystemAnnouncer current
  191. announce: (MethodRemoved new
  192. method: aMethod;
  193. yourself)
  194. ! !
  195. !Behavior methodsFor: 'enumerating'!
  196. allSubclassesDo: aBlock
  197. "Evaluate the argument, aBlock, for each of the receiver's subclasses."
  198. self allSubclasses do: [ :each |
  199. aBlock value: each ]
  200. !
  201. protocolsDo: aBlock
  202. "Execute aBlock for each method category with
  203. its collection of methods in the sort order of category name."
  204. | methodsByCategory |
  205. methodsByCategory := HashedCollection new.
  206. self methodDictionary values do: [:m |
  207. (methodsByCategory at: m category ifAbsentPut: [Array new])
  208. add: m].
  209. self protocols do: [:category |
  210. aBlock value: category value: (methodsByCategory at: category)]
  211. ! !
  212. !Behavior methodsFor: 'instance creation'!
  213. basicNew
  214. <return new self.fn()>
  215. !
  216. new
  217. ^self basicNew initialize
  218. ! !
  219. !Behavior methodsFor: 'private'!
  220. basicAddCompiledMethod: aMethod
  221. <smalltalk.addMethod(aMethod, self)>
  222. !
  223. basicRemoveCompiledMethod: aMethod
  224. <smalltalk.removeMethod(aMethod,self)>
  225. ! !
  226. !Behavior methodsFor: 'testing'!
  227. canUnderstand: aSelector
  228. ^(self methodDictionary keys includes: aSelector asString) or: [
  229. self superclass notNil and: [self superclass canUnderstand: aSelector]]
  230. !
  231. includesBehavior: aClass
  232. ^ self == aClass or: [
  233. self inheritsFrom: aClass ]
  234. !
  235. includesSelector: aString
  236. ^ self methodDictionary includesKey: aString
  237. !
  238. inheritsFrom: aClass
  239. self superclass ifNil: [ ^ false ].
  240. ^ aClass == self superclass or: [
  241. self superclass inheritsFrom: aClass ]
  242. !
  243. isBehavior
  244. ^ true
  245. ! !
  246. Behavior subclass: #Class
  247. instanceVariableNames: ''
  248. package: 'Kernel-Classes'!
  249. !Class commentStamp!
  250. I am __the__ class object.
  251. My instances are the classes of the system.
  252. Class creation is done throught a `ClassBuilder` instance.!
  253. !Class methodsFor: 'accessing'!
  254. category
  255. ^self package ifNil: ['Unclassified'] ifNotNil: [self package name]
  256. !
  257. definition
  258. ^ String streamContents: [ :stream |
  259. stream
  260. nextPutAll: self superclass asString;
  261. nextPutAll: ' subclass: #';
  262. nextPutAll: self name;
  263. nextPutAll: String lf, String tab;
  264. nextPutAll: 'instanceVariableNames: '''.
  265. self instanceVariableNames
  266. do: [ :each | stream nextPutAll: each ]
  267. separatedBy: [ stream nextPutAll: ' ' ].
  268. stream
  269. nextPutAll: '''', String lf, String tab;
  270. nextPutAll: 'package: ''';
  271. nextPutAll: self category;
  272. nextPutAll: '''' ]
  273. !
  274. package
  275. ^ self basicAt: 'pkg'
  276. !
  277. package: aPackage
  278. | oldPackage |
  279. self package = aPackage ifTrue: [ ^ self ].
  280. oldPackage := self package.
  281. self basicAt: 'pkg' put: aPackage.
  282. oldPackage organization removeElement: self.
  283. aPackage organization addElement: self.
  284. SystemAnnouncer current announce: (ClassMoved new
  285. theClass: self;
  286. oldPackage: oldPackage;
  287. yourself)
  288. !
  289. rename: aString
  290. ClassBuilder new renameClass: self to: aString
  291. !
  292. subclasses
  293. <return self.subclasses._copy()>
  294. ! !
  295. !Class methodsFor: 'class creation'!
  296. subclass: aString instanceVariableNames: anotherString
  297. "Kept for compatibility."
  298. ^self subclass: aString instanceVariableNames: anotherString package: nil
  299. !
  300. subclass: aString instanceVariableNames: aString2 category: aString3
  301. "Kept for compatibility."
  302. self deprecatedAPI.
  303. ^self subclass: aString instanceVariableNames: aString2 package: aString3
  304. !
  305. subclass: aString instanceVariableNames: aString2 classVariableNames: classVars poolDictionaries: pools category: aString3
  306. "Just ignore class variables and pools. Added for compatibility."
  307. ^self subclass: aString instanceVariableNames: aString2 package: aString3
  308. !
  309. subclass: aString instanceVariableNames: aString2 package: aString3
  310. ^ClassBuilder new
  311. superclass: self subclass: aString asString instanceVariableNames: aString2 package: aString3
  312. ! !
  313. !Class methodsFor: 'converting'!
  314. asJavascript
  315. ^ 'smalltalk.', self name
  316. ! !
  317. !Class methodsFor: 'printing'!
  318. printOn: aStream
  319. aStream nextPutAll: self name
  320. ! !
  321. !Class methodsFor: 'testing'!
  322. isClass
  323. ^true
  324. ! !
  325. Behavior subclass: #Metaclass
  326. instanceVariableNames: ''
  327. package: 'Kernel-Classes'!
  328. !Metaclass commentStamp!
  329. I am the root of the class hierarchy.
  330. My instances are metaclasses, one for each real class, and have a single instance, which they hold onto: the class that they are the metaclass of.!
  331. !Metaclass methodsFor: 'accessing'!
  332. definition
  333. ^ String streamContents: [ :stream |
  334. stream
  335. nextPutAll: self asString;
  336. nextPutAll: ' instanceVariableNames: '''.
  337. self instanceVariableNames
  338. do: [ :each | stream nextPutAll: each ]
  339. separatedBy: [ stream nextPutAll: ' ' ].
  340. stream nextPutAll: '''' ]
  341. !
  342. instanceClass
  343. <return self.instanceClass>
  344. !
  345. instanceVariableNames: aCollection
  346. ClassBuilder new
  347. class: self instanceVariableNames: aCollection
  348. !
  349. subclasses
  350. ^ (self instanceClass subclasses
  351. select: [ :each | each isMetaclass not ])
  352. collect: [ :each | each theMetaClass ]
  353. !
  354. theMetaClass
  355. ^ self
  356. !
  357. theNonMetaClass
  358. ^ self instanceClass
  359. ! !
  360. !Metaclass methodsFor: 'converting'!
  361. asJavascript
  362. ^ 'smalltalk.', self instanceClass name, '.klass'
  363. ! !
  364. !Metaclass methodsFor: 'printing'!
  365. printOn: aStream
  366. aStream
  367. nextPutAll: self instanceClass name;
  368. nextPutAll: ' class'
  369. ! !
  370. !Metaclass methodsFor: 'testing'!
  371. isMetaclass
  372. ^true
  373. ! !
  374. Object subclass: #ClassBuilder
  375. instanceVariableNames: ''
  376. package: 'Kernel-Classes'!
  377. !ClassBuilder commentStamp!
  378. I am responsible for compiling new classes or modifying existing classes in the system.
  379. Rather than using me directly to compile a class, use `Class >> subclass:instanceVariableNames:package:`.!
  380. !ClassBuilder methodsFor: 'accessing'!
  381. instanceVariableNamesFor: aString
  382. ^(aString tokenize: ' ') reject: [ :each | each isEmpty ]
  383. ! !
  384. !ClassBuilder methodsFor: 'class definition'!
  385. addSubclassOf: aClass named: className instanceVariableNames: aCollection package: packageName
  386. | theClass thePackage |
  387. theClass := Smalltalk current at: className.
  388. thePackage := self createPackageNamed: packageName.
  389. theClass ifNotNil: [
  390. theClass package: thePackage.
  391. theClass superclass == aClass ifFalse: [
  392. ^ self
  393. migrateClassNamed: className
  394. superclass: aClass
  395. instanceVariableNames: aCollection
  396. package: packageName ] ].
  397. ^ self
  398. basicAddSubclassOf: aClass
  399. named: className
  400. instanceVariableNames: aCollection
  401. package: packageName
  402. !
  403. class: aClass instanceVariableNames: ivarNames
  404. self basicClass: aClass instanceVariableNames: ivarNames.
  405. self setupClass: aClass.
  406. SystemAnnouncer current
  407. announce: (ClassDefinitionChanged new
  408. theClass: aClass;
  409. yourself)
  410. !
  411. superclass: aClass subclass: className
  412. ^self superclass: aClass subclass: className instanceVariableNames: '' package: nil
  413. !
  414. superclass: aClass subclass: className instanceVariableNames: ivarNames package: packageName
  415. | newClass |
  416. newClass := self addSubclassOf: aClass
  417. named: className instanceVariableNames: (self instanceVariableNamesFor: ivarNames)
  418. package: (packageName ifNil: ['unclassified']).
  419. self setupClass: newClass.
  420. SystemAnnouncer current
  421. announce: (ClassAdded new
  422. theClass: newClass;
  423. yourself).
  424. ^newClass
  425. ! !
  426. !ClassBuilder methodsFor: 'class migration'!
  427. migrateClass: aClass superclass: anotherClass
  428. ^ self
  429. migrateClassNamed: aClass name
  430. superclass: anotherClass
  431. instanceVariableNames: aClass instanceVariableNames
  432. package: aClass package name
  433. !
  434. migrateClassNamed: className superclass: aClass instanceVariableNames: aCollection package: packageName
  435. | oldClass newClass tmp |
  436. tmp := 'new*', className.
  437. oldClass := Smalltalk current at: className.
  438. newClass := self
  439. addSubclassOf: aClass
  440. named: tmp
  441. instanceVariableNames: aCollection
  442. package: packageName.
  443. self basicSwapClassNames: oldClass with: newClass.
  444. [ self copyClass: oldClass to: newClass ]
  445. on: Error
  446. do: [ :exception |
  447. self
  448. basicSwapClassNames: oldClass with: newClass;
  449. basicRemoveClass: newClass.
  450. exception signal ].
  451. self
  452. rawRenameClass: oldClass to: tmp;
  453. rawRenameClass: newClass to: className.
  454. oldClass subclasses
  455. do: [ :each | self migrateClass: each superclass: newClass ]
  456. displayingProgress: 'Recompiling ', newClass name, '...'.
  457. self basicRemoveClass: oldClass.
  458. SystemAnnouncer current announce: (ClassMigrated new
  459. theClass: newClass;
  460. oldClass: oldClass;
  461. yourself).
  462. ^newClass
  463. !
  464. renameClass: aClass to: className
  465. self basicRenameClass: aClass to: className.
  466. "Recompile the class to fix potential issues with super sends"
  467. aClass recompile.
  468. SystemAnnouncer current
  469. announce: (ClassRenamed new
  470. theClass: aClass;
  471. yourself)
  472. ! !
  473. !ClassBuilder methodsFor: 'copying'!
  474. copyClass: aClass named: className
  475. | newClass |
  476. newClass := self
  477. addSubclassOf: aClass superclass
  478. named: className
  479. instanceVariableNames: aClass instanceVariableNames
  480. package: aClass package name.
  481. self copyClass: aClass to: newClass.
  482. SystemAnnouncer current
  483. announce: (ClassAdded new
  484. theClass: newClass;
  485. yourself).
  486. ^newClass
  487. !
  488. copyClass: aClass to: anotherClass
  489. anotherClass comment: aClass comment.
  490. aClass methodDictionary values do: [ :each |
  491. Compiler new install: each source forClass: anotherClass category: each category ].
  492. self basicClass: anotherClass class instanceVariables: aClass class instanceVariableNames.
  493. aClass class methodDictionary values do: [ :each |
  494. Compiler new install: each source forClass: anotherClass class category: each category ].
  495. self setupClass: anotherClass
  496. ! !
  497. !ClassBuilder methodsFor: 'method definition'!
  498. installMethod: aCompiledMethod forClass: aBehavior category: aString
  499. aCompiledMethod category: aString.
  500. aBehavior addCompiledMethod: aCompiledMethod.
  501. self setupClass: aBehavior.
  502. ^aCompiledMethod
  503. ! !
  504. !ClassBuilder methodsFor: 'private'!
  505. basicAddSubclassOf: aClass named: aString instanceVariableNames: aCollection package: packageName
  506. <
  507. smalltalk.addClass(aString, aClass, aCollection, packageName);
  508. return smalltalk[aString]
  509. >
  510. !
  511. basicClass: aClass instanceVariableNames: aString
  512. self basicClass: aClass instanceVariables: (self instanceVariableNamesFor: aString)
  513. !
  514. basicClass: aClass instanceVariables: aCollection
  515. aClass isMetaclass ifFalse: [self error: aClass name, ' is not a metaclass'].
  516. aClass basicAt: 'iVarNames' put: aCollection
  517. !
  518. basicRemoveClass: aClass
  519. <smalltalk.removeClass(aClass)>
  520. !
  521. basicRenameClass: aClass to: aString
  522. <
  523. smalltalk[aString] = aClass;
  524. delete smalltalk[aClass.className];
  525. aClass.className = aString;
  526. >
  527. !
  528. basicSwapClassNames: aClass with: anotherClass
  529. <
  530. var tmp = aClass.className;
  531. aClass.className = anotherClass.className;
  532. anotherClass.className = tmp;
  533. >
  534. !
  535. createPackageNamed: aString
  536. ^ Package named: aString ifAbsent: [
  537. Smalltalk current createPackage: aString ]
  538. !
  539. rawRenameClass: aClass to: aString
  540. <
  541. smalltalk[aString] = aClass;
  542. >
  543. ! !
  544. !ClassBuilder methodsFor: 'public'!
  545. setupClass: aClass
  546. <smalltalk.init(aClass);>
  547. ! !
  548. Object subclass: #ClassCategoryReader
  549. instanceVariableNames: 'class category'
  550. package: 'Kernel-Classes'!
  551. !ClassCategoryReader commentStamp!
  552. I provide a mechanism for retrieving class descriptions stored on a file in the Smalltalk chunk format.!
  553. !ClassCategoryReader methodsFor: 'accessing'!
  554. class: aClass category: aString
  555. class := aClass.
  556. category := aString
  557. ! !
  558. !ClassCategoryReader methodsFor: 'fileIn'!
  559. scanFrom: aChunkParser
  560. | chunk |
  561. [chunk := aChunkParser nextChunk.
  562. chunk isEmpty] whileFalse: [
  563. self compileMethod: chunk].
  564. ClassBuilder new setupClass: class
  565. ! !
  566. !ClassCategoryReader methodsFor: 'initialization'!
  567. initialize
  568. super initialize.
  569. ! !
  570. !ClassCategoryReader methodsFor: 'private'!
  571. compileMethod: aString
  572. Compiler new install: aString forClass: class category: category
  573. ! !
  574. Object subclass: #ClassCommentReader
  575. instanceVariableNames: 'class'
  576. package: 'Kernel-Classes'!
  577. !ClassCommentReader commentStamp!
  578. I provide a mechanism for retrieving class comments stored on a file.
  579. See also `ClassCategoryReader`.!
  580. !ClassCommentReader methodsFor: 'accessing'!
  581. class: aClass
  582. class := aClass
  583. ! !
  584. !ClassCommentReader methodsFor: 'fileIn'!
  585. scanFrom: aChunkParser
  586. | chunk |
  587. chunk := aChunkParser nextChunk.
  588. chunk isEmpty ifFalse: [
  589. self setComment: chunk].
  590. ! !
  591. !ClassCommentReader methodsFor: 'initialization'!
  592. initialize
  593. super initialize.
  594. ! !
  595. !ClassCommentReader methodsFor: 'private'!
  596. setComment: aString
  597. class comment: aString
  598. ! !
  599. Object subclass: #ClassSorterNode
  600. instanceVariableNames: 'theClass level nodes'
  601. package: 'Kernel-Classes'!
  602. !ClassSorterNode commentStamp!
  603. I provide an algorithm for sorting classes alphabetically.
  604. See [Issue #143](https://github.com/amber-smalltalk/amber/issues/143) on GitHub.!
  605. !ClassSorterNode methodsFor: 'accessing'!
  606. getNodesFrom: aCollection
  607. | children others |
  608. children := #().
  609. others := #().
  610. aCollection do: [:each |
  611. (each superclass = self theClass)
  612. ifTrue: [children add: each]
  613. ifFalse: [others add: each]].
  614. nodes:= children collect: [:each |
  615. ClassSorterNode on: each classes: others level: self level + 1]
  616. !
  617. level
  618. ^level
  619. !
  620. level: anInteger
  621. level := anInteger
  622. !
  623. nodes
  624. ^nodes
  625. !
  626. theClass
  627. ^theClass
  628. !
  629. theClass: aClass
  630. theClass := aClass
  631. ! !
  632. !ClassSorterNode methodsFor: 'visiting'!
  633. traverseClassesWith: aCollection
  634. "sort classes alphabetically Issue #143"
  635. aCollection add: self theClass.
  636. (self nodes sorted: [:a :b | a theClass name <= b theClass name ]) do: [:aNode |
  637. aNode traverseClassesWith: aCollection ].
  638. ! !
  639. !ClassSorterNode class methodsFor: 'instance creation'!
  640. on: aClass classes: aCollection level: anInteger
  641. ^self new
  642. theClass: aClass;
  643. level: anInteger;
  644. getNodesFrom: aCollection;
  645. yourself
  646. ! !