Helios-Browser.st 22 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043
  1. Smalltalk current createPackage: 'Helios-Browser'!
  2. HLWidget subclass: #HLBrowser
  3. instanceVariableNames: 'model packagesListWidget classesListWidget protocolsListWidget methodsListWidget sourceWidget'
  4. package: 'Helios-Browser'!
  5. !HLBrowser methodsFor: 'accessing'!
  6. announcer
  7. ^ self model announcer
  8. !
  9. environment
  10. ^ self model environment
  11. !
  12. model
  13. ^ model ifNil: [ model := HLBrowserModel new ]
  14. !
  15. model: aModel
  16. model := aModel
  17. ! !
  18. !HLBrowser methodsFor: 'keybindings'!
  19. registerBindingsOn: aBindingGroup
  20. aBindingGroup
  21. addGroupKey: 66 labelled: 'Browse';
  22. addGroupKey: 71 labelled: 'Go to';
  23. addGroupKey: 84 labelled: 'Toggle'.
  24. HLBrowserCommand withAllSubclasses do: [ :each |
  25. each key ifNotNil: [
  26. (aBindingGroup at: each bindingGroup)
  27. add: (each on: self model) asBinding ] ]
  28. ! !
  29. !HLBrowser methodsFor: 'rendering'!
  30. renderContentOn: html
  31. html with: (HLContainer with: (HLHorizontalSplitter
  32. with: (HLVerticalSplitter
  33. with: (HLVerticalSplitter
  34. with: self packagesListWidget
  35. with: self classesListWidget)
  36. with: (HLVerticalSplitter
  37. with: self protocolsListWidget
  38. with: self methodsListWidget))
  39. with: self sourceWidget))
  40. ! !
  41. !HLBrowser methodsFor: 'widgets'!
  42. classesListWidget
  43. ^ classesListWidget ifNil: [
  44. classesListWidget := HLClassesListWidget on: self model.
  45. classesListWidget next: self protocolsListWidget ]
  46. !
  47. methodsListWidget
  48. ^ methodsListWidget ifNil: [
  49. methodsListWidget := HLMethodsListWidget on: self model ]
  50. !
  51. packagesListWidget
  52. ^ packagesListWidget ifNil: [
  53. packagesListWidget := HLPackagesListWidget on: self model.
  54. packagesListWidget next: self classesListWidget ]
  55. !
  56. protocolsListWidget
  57. ^ protocolsListWidget ifNil: [
  58. protocolsListWidget := HLProtocolsListWidget on: self model.
  59. protocolsListWidget next: self methodsListWidget ]
  60. !
  61. sourceWidget
  62. ^ sourceWidget ifNil: [
  63. sourceWidget := HLBrowserSourceWidget on: self model ]
  64. ! !
  65. HLBrowser class instanceVariableNames: 'nextId'!
  66. !HLBrowser class methodsFor: 'accessing'!
  67. nextId
  68. nextId ifNil: [ nextId := 0 ].
  69. ^ 'browser_', (nextId + 1) asString
  70. !
  71. tabLabel
  72. ^ 'Browser'
  73. !
  74. tabPriority
  75. ^ 0
  76. ! !
  77. !HLBrowser class methodsFor: 'testing'!
  78. canBeOpenAsTab
  79. ^ true
  80. ! !
  81. HLNavigationListWidget subclass: #HLBrowserListWidget
  82. instanceVariableNames: 'model'
  83. package: 'Helios-Browser'!
  84. !HLBrowserListWidget methodsFor: 'accessing'!
  85. model
  86. ^ model
  87. !
  88. model: aBrowserModel
  89. model := aBrowserModel.
  90. self observeModel
  91. ! !
  92. !HLBrowserListWidget methodsFor: 'actions'!
  93. observeModel
  94. !
  95. observeSystem
  96. ! !
  97. !HLBrowserListWidget methodsFor: 'initialization'!
  98. initialize
  99. super initialize.
  100. self observeSystem
  101. ! !
  102. !HLBrowserListWidget class methodsFor: 'instance creation'!
  103. on: aModel
  104. ^ self new
  105. model: aModel;
  106. yourself
  107. ! !
  108. HLBrowserListWidget subclass: #HLClassesListWidget
  109. instanceVariableNames: ''
  110. package: 'Helios-Browser'!
  111. !HLClassesListWidget methodsFor: 'accessing'!
  112. getChildrenOf: aClass
  113. ^ self items select: [ :each | each superclass = aClass ]
  114. !
  115. getRootClassesOf: aCollection
  116. ^ aCollection select: [ :each |
  117. (aCollection includes: each superclass) not ]
  118. !
  119. iconForItem: aClass
  120. ^ aClass theNonMetaClass comment isEmpty
  121. ifFalse: [ 'icon-none' ]
  122. ifTrue: [ 'icon-question-sign' ]
  123. !
  124. showInstance
  125. ^ self model showInstance
  126. ! !
  127. !HLClassesListWidget methodsFor: 'actions'!
  128. focusMethodsListWidget
  129. self model announcer announce: HLMethodsListFocus new
  130. !
  131. focusProtocolsListWidget
  132. self model announcer announce: HLProtocolsListFocus new
  133. !
  134. observeModel
  135. self model announcer
  136. on: HLPackageSelected do: [ :ann | self onPackageSelected: ann item ];
  137. on: HLShowInstanceToggled do: [ :ann | self onShowInstanceToggled ];
  138. on: HLClassSelected do: [ :ann | self onClassSelected: ann item ]
  139. !
  140. observeSystem
  141. SystemAnnouncer current
  142. on: ClassAdded
  143. do: [ :ann | self onClassAdded: ann theClass ];
  144. on: ClassRemoved
  145. do: [ :ann | self onClassRemoved: ann theClass ]
  146. !
  147. selectItem: aClass
  148. self model selectedClass: aClass
  149. !
  150. showInstance: aBoolean
  151. self model showInstance: aBoolean
  152. ! !
  153. !HLClassesListWidget methodsFor: 'private'!
  154. setItemsForPackage: aPackage
  155. self items: (aPackage
  156. ifNil: [ #() ]
  157. ifNotNil: [ ((aPackage classes
  158. collect: [ :each | each theNonMetaClass ]) asSet asArray)
  159. sort: [:a :b | a name < b name ] ]).
  160. !
  161. setItemsForSelectedPackage
  162. self setItemsForPackage: self model selectedPackage
  163. ! !
  164. !HLClassesListWidget methodsFor: 'reactions'!
  165. onClassAdded: aClass
  166. aClass package = self model selectedPackage ifFalse: [ ^ self ].
  167. self setItemsForSelectedPackage.
  168. self refresh
  169. !
  170. onClassRemoved: aClass
  171. aClass package = self model selectedPackage ifFalse: [ ^ self ].
  172. aClass = self model selectedClass ifTrue: [ self selectItem: nil ].
  173. self setItemsForSelectedPackage.
  174. self refresh
  175. !
  176. onClassSelected: aClass
  177. self selectedItem: aClass.
  178. aClass ifNil: [ ^ self ].
  179. self focus
  180. !
  181. onPackageSelected: aPackage
  182. self selectedItem: nil.
  183. self setItemsForSelectedPackage.
  184. self refresh
  185. !
  186. onShowInstanceToggled
  187. self refresh
  188. ! !
  189. !HLClassesListWidget methodsFor: 'rendering'!
  190. renderButtonsOn: html
  191. html div
  192. class: 'btn-group';
  193. at: 'data-toggle' put: 'buttons-radio';
  194. with: [
  195. html button
  196. class: (String streamContents: [ :str |
  197. str nextPutAll: 'btn'.
  198. self showInstance ifTrue: [
  199. str nextPutAll: ' active'] ]);
  200. with: 'Instance';
  201. onClick: [ self showInstance: true ].
  202. html button
  203. class: (String streamContents: [ :str |
  204. str nextPutAll: 'btn'.
  205. self model showInstance ifFalse: [
  206. str nextPutAll: ' active'] ]);
  207. with: 'Class';
  208. onClick: [ self model showInstance: false ] ].
  209. html button
  210. class: 'btn';
  211. at: 'data-toggle' put: 'button';
  212. with: 'Comment'
  213. !
  214. renderItem: aClass level: anInteger on: html
  215. | li |
  216. li := html li.
  217. li
  218. at: 'list-data' put: (self items indexOf: aClass);
  219. class: (self cssClassForItem: aClass);
  220. with: [
  221. html a
  222. with: [
  223. (html tag: 'i') class: (self iconForItem: aClass).
  224. self renderItemLabel: aClass level: anInteger on: html ];
  225. onClick: [
  226. self activateListItem: li asJQuery ] ].
  227. (self getChildrenOf: aClass) do: [ :each |
  228. self renderItem: each level: anInteger + 1 on: html ]
  229. !
  230. renderItem: aClass on: html
  231. super renderItem: aClass on: html.
  232. (self getChildrenOf: aClass) do: [ :each |
  233. self renderItem: each level: 1 on: html ]
  234. !
  235. renderItemLabel: aClass level: anInteger on: html
  236. html span asJQuery html: (String streamContents: [ :str |
  237. anInteger timesRepeat: [
  238. str nextPutAll: '&nbsp;&nbsp;&nbsp;&nbsp;'].
  239. str nextPutAll: aClass name ])
  240. !
  241. renderItemLabel: aClass on: html
  242. self renderItemLabel: aClass level: 0 on: html
  243. !
  244. renderListOn: html
  245. (self getRootClassesOf: self items)
  246. do: [ :each | self renderItem: each on: html ]
  247. ! !
  248. HLBrowserListWidget subclass: #HLMethodsListWidget
  249. instanceVariableNames: ''
  250. package: 'Helios-Browser'!
  251. !HLMethodsListWidget methodsFor: 'accessing'!
  252. allProtocol
  253. ^ self model allProtocol
  254. !
  255. iconForItem: aSelector
  256. | override overriden method |
  257. method := self methodForSelector: aSelector.
  258. override := self isOverride: method.
  259. overriden := self isOverridden: method.
  260. ^ override
  261. ifTrue: [ overriden
  262. ifTrue: [ 'icon-resize-vertical' ]
  263. ifFalse: [ 'icon-arrow-up' ] ]
  264. ifFalse: [
  265. overriden
  266. ifTrue: [ 'icon-arrow-down' ]
  267. ifFalse: [ 'icon-none' ] ]
  268. !
  269. methodForSelector: aSelector
  270. ^ self model selectedClass
  271. methodDictionary at: aSelector
  272. !
  273. methodsInProtocol: aString
  274. ^ aString = self allProtocol
  275. ifTrue: [ self model selectedClass methods ]
  276. ifFalse: [ self model selectedClass methodsInProtocol: aString ]
  277. !
  278. overrideSelectors
  279. ^ self selectorsCache
  280. at: 'override'
  281. ifAbsentPut: [
  282. self model selectedClass allSuperclasses
  283. inject: Set new into: [ :acc :each | acc addAll: each selectors; yourself ] ]
  284. !
  285. overridenSelectors
  286. ^ self selectorsCache
  287. at: 'overriden'
  288. ifAbsentPut: [
  289. self model selectedClass allSubclasses
  290. inject: Set new into: [ :acc :each | acc addAll: each selectors; yourself ] ]
  291. !
  292. selectorsCache
  293. ^ self class selectorsCache
  294. !
  295. selectorsInProtocol: aString
  296. ^ (self methodsInProtocol: aString)
  297. collect: [ :each | each selector ]
  298. ! !
  299. !HLMethodsListWidget methodsFor: 'actions'!
  300. observeModel
  301. self model announcer on: HLProtocolSelected do: [ :ann |
  302. self onProtocolSelected: ann item ].
  303. self model announcer on: HLShowInstanceToggled do: [ :ann |
  304. self onProtocolSelected: nil ].
  305. self model announcer on: HLMethodSelected do: [ :ann |
  306. self onMethodSelected: ann item ]
  307. !
  308. observeSystem
  309. SystemAnnouncer current
  310. on: MethodAdded
  311. do: [ :ann | self onMethodAdded: ann method ];
  312. on: MethodRemoved
  313. do: [ :ann | self onMethodRemoved: ann method ]
  314. !
  315. selectItem: aSelector
  316. self model selectedMethod: (self methodForSelector: aSelector)
  317. ! !
  318. !HLMethodsListWidget methodsFor: 'cache'!
  319. flushSelectorsCache
  320. selectorsCache := Dictionary new
  321. ! !
  322. !HLMethodsListWidget methodsFor: 'initialization'!
  323. initialize
  324. super initialize.
  325. self flushSelectorsCache
  326. ! !
  327. !HLMethodsListWidget methodsFor: 'reactions'!
  328. onMethodAdded: aMethod
  329. self items detect: [ :each | each = aMethod selector ] ifNone: [ ^ self ].
  330. self refresh
  331. !
  332. onMethodRemoved: aMethod
  333. self items detect: [ :each | each = aMethod selector ] ifNone: [ ^ self ].
  334. (aMethod methodClass = self model selectedClass and: [ aMethod selector = self selectedItem ])
  335. ifTrue: [ self selectItem: nil ].
  336. self refresh
  337. !
  338. onMethodSelected: aMethod
  339. self selectedItem: aMethod.
  340. aMethod ifNil: [ ^ self ].
  341. self focus
  342. !
  343. onProtocolSelected: aString
  344. self selectedItem: nil.
  345. self items: (self model selectedClass
  346. ifNil: [ #() ]
  347. ifNotNil: [ aString
  348. ifNil: [ #() ]
  349. ifNotNil: [ self selectorsInProtocol: aString ] ]).
  350. self refresh
  351. ! !
  352. !HLMethodsListWidget methodsFor: 'rendering'!
  353. renderContentOn: html
  354. self model showInstance
  355. ifFalse: [ html div
  356. class: 'class_side';
  357. with: [ super renderContentOn: html ] ]
  358. ifTrue: [ super renderContentOn: html ]
  359. !
  360. renderItemLabel: aSelector on: html
  361. html with: aSelector
  362. ! !
  363. !HLMethodsListWidget methodsFor: 'testing'!
  364. isOverridden: aMethod
  365. ^ self selectorsCache isOverridden: aMethod
  366. !
  367. isOverride: aMethod
  368. ^ self selectorsCache isOverride: aMethod
  369. ! !
  370. HLMethodsListWidget class instanceVariableNames: 'selectorsCache'!
  371. !HLMethodsListWidget class methodsFor: 'accessing'!
  372. selectorsCache
  373. ^ HLSelectorsCache current
  374. ! !
  375. HLBrowserListWidget subclass: #HLPackagesListWidget
  376. instanceVariableNames: ''
  377. package: 'Helios-Browser'!
  378. !HLPackagesListWidget methodsFor: 'accessing'!
  379. initializeItems
  380. ^ items := self model packages sort:[:a :b|
  381. a name < b name]
  382. !
  383. items
  384. ^ items ifNil: [self initializeItems]
  385. ! !
  386. !HLPackagesListWidget methodsFor: 'actions'!
  387. focusClassesListWidget
  388. self model announcer announce: HLClassesListFocus new
  389. !
  390. observeModel
  391. self model announcer on: HLPackageSelected do: [ :ann |
  392. self onPackageSelected: ann item ]
  393. !
  394. selectItem: aPackage
  395. self model selectedPackage: aPackage
  396. ! !
  397. !HLPackagesListWidget methodsFor: 'reactions'!
  398. onPackageSelected: aPackage
  399. self selectedItem: aPackage.
  400. self focus
  401. ! !
  402. !HLPackagesListWidget methodsFor: 'rendering'!
  403. renderButtonsOn: html
  404. html span class: 'info'; with: 'Auto commit'.
  405. html div
  406. class: 'btn-group switch';
  407. at: 'data-toggle' put: 'buttons-radio';
  408. with: [
  409. html button
  410. class: (String streamContents: [ :str |
  411. str nextPutAll: 'btn' ]);
  412. with: 'On'.
  413. html button
  414. class: (String streamContents: [ :str |
  415. str nextPutAll: 'btn active' ]);
  416. with: 'Off' ].
  417. html a
  418. class: 'btn';
  419. with: 'Commit'.
  420. ! !
  421. HLBrowserListWidget subclass: #HLProtocolsListWidget
  422. instanceVariableNames: ''
  423. package: 'Helios-Browser'!
  424. !HLProtocolsListWidget methodsFor: 'accessing'!
  425. allProtocol
  426. ^ self model allProtocol
  427. !
  428. selectedItem
  429. ^ super selectedItem" ifNil: [ self allProtocol ]"
  430. ! !
  431. !HLProtocolsListWidget methodsFor: 'actions'!
  432. observeModel
  433. self model announcer on: HLClassSelected do: [ :ann |
  434. self onClassSelected: ann item ].
  435. self model announcer on: HLShowInstanceToggled do: [ :ann |
  436. self onClassSelected: self model selectedClass ].
  437. self model announcer on: HLProtocolSelected do: [ :ann |
  438. self onProtocolSelected: ann item ]
  439. !
  440. selectItem: aString
  441. self model selectedProtocol: aString
  442. ! !
  443. !HLProtocolsListWidget methodsFor: 'reactions'!
  444. onClassSelected: aClass
  445. self selectedItem: nil.
  446. self items: (aClass
  447. ifNil: [ Array with: self allProtocol ]
  448. ifNotNil: [
  449. (Array with: self allProtocol)
  450. addAll: aClass protocols;
  451. yourself ]).
  452. self refresh
  453. !
  454. onProtocolSelected: aString
  455. self selectedItem: aString.
  456. aString ifNil: [ ^ self ].
  457. self focus
  458. ! !
  459. !HLProtocolsListWidget methodsFor: 'rendering'!
  460. renderContentOn: html
  461. self model showInstance
  462. ifFalse: [ html div
  463. class: 'class_side';
  464. with: [ super renderContentOn: html ] ]
  465. ifTrue: [ super renderContentOn: html ]
  466. ! !
  467. Object subclass: #HLBrowserModel
  468. instanceVariableNames: 'announcer environment selectedPackage selectedClass selectedProtocol selectedSelector showInstance showComment'
  469. package: 'Helios-Browser'!
  470. !HLBrowserModel methodsFor: 'accessing'!
  471. allProtocol
  472. ^ '-- All --'
  473. !
  474. announcer
  475. ^ announcer ifNil: [ announcer := Announcer new ]
  476. !
  477. environment
  478. ^ environment ifNil: [ HLManager current environment ]
  479. !
  480. environment: anEnvironment
  481. environment := anEnvironment
  482. !
  483. packages
  484. ^ self environment packages
  485. !
  486. selectedClass
  487. ^ selectedClass
  488. !
  489. selectedClass: aClass
  490. selectedClass = aClass ifTrue: [ ^ self ].
  491. aClass
  492. ifNil: [ selectedClass := nil ]
  493. ifNotNil: [
  494. self showInstance
  495. ifTrue: [ selectedClass := aClass theNonMetaClass ]
  496. ifFalse: [ selectedClass := aClass theMetaClass ] ].
  497. self selectedProtocol: nil.
  498. self announcer announce: (HLClassSelected on: self selectedClass)
  499. !
  500. selectedMethod
  501. ^ self selectedClass
  502. ifNotNil: [ self selectedClass methodDictionary at: selectedSelector ]
  503. !
  504. selectedMethod: aCompiledMethod
  505. selectedSelector = aCompiledMethod ifTrue: [ ^ self ].
  506. aCompiledMethod
  507. ifNil: [ selectedSelector := nil ]
  508. ifNotNil: [
  509. selectedSelector = aCompiledMethod selector ifTrue: [ ^ self ].
  510. selectedSelector := aCompiledMethod selector ].
  511. self announcer announce: (HLMethodSelected on: aCompiledMethod)
  512. !
  513. selectedPackage
  514. ^ selectedPackage
  515. !
  516. selectedPackage: aPackage
  517. selectedPackage = aPackage ifTrue: [ ^ self ].
  518. selectedPackage := aPackage.
  519. self selectedClass: nil.
  520. self announcer announce: (HLPackageSelected on: aPackage)
  521. !
  522. selectedProtocol
  523. ^ selectedProtocol
  524. !
  525. selectedProtocol: aString
  526. selectedProtocol = aString ifTrue: [ ^ self ].
  527. selectedProtocol := aString.
  528. self selectedMethod: nil.
  529. self announcer announce: (HLProtocolSelected on: aString)
  530. !
  531. showComment
  532. ^ showComment ifNil: [ false ]
  533. !
  534. showComment: aBoolean
  535. showComment := aBoolean.
  536. self announcer announce: HLShowCommentToggled new
  537. !
  538. showInstance
  539. ^ showInstance ifNil: [ true ]
  540. !
  541. showInstance: aBoolean
  542. showInstance := aBoolean.
  543. self selectedClass ifNotNil: [
  544. self selectedClass: (aBoolean
  545. ifTrue: [self selectedClass theNonMetaClass ]
  546. ifFalse: [ self selectedClass theMetaClass ]) ].
  547. self announcer announce: HLShowInstanceToggled new
  548. ! !
  549. !HLBrowserModel class methodsFor: 'actions'!
  550. on: anEnvironment
  551. ^ self new
  552. environment: anEnvironment;
  553. yourself
  554. ! !
  555. HLWidget subclass: #HLBrowserSourceWidget
  556. instanceVariableNames: 'model methodContents codeWidget'
  557. package: 'Helios-Browser'!
  558. !HLBrowserSourceWidget methodsFor: 'accessing'!
  559. codeWidget
  560. ^ codeWidget ifNil: [ codeWidget := HLCodeWidget new ]
  561. !
  562. contents
  563. ^ self codeWidget contents
  564. !
  565. contents: aString
  566. self methodContents: aString.
  567. self codeWidget contents: aString
  568. !
  569. methodContents
  570. ^ methodContents ifNil: [ methodContents := '' ]
  571. !
  572. methodContents: aString
  573. methodContents := aString
  574. !
  575. model
  576. ^ model
  577. !
  578. model: aBrowserModel
  579. model := aBrowserModel.
  580. self observeModel
  581. ! !
  582. !HLBrowserSourceWidget methodsFor: 'actions'!
  583. observeModel
  584. self model announcer on: HLMethodSelected do: [ :ann |
  585. self onMethodSelected: ann item ].
  586. self model announcer on: HLClassSelected do: [ :ann |
  587. self onClassSelected: ann item ].
  588. self model announcer on: HLProtocolSelected do: [ :ann |
  589. self onProtocolSelected: ann item ]
  590. !
  591. observeSystem
  592. SystemAnnouncer current
  593. on: MethodModified
  594. do: [ :ann | self onMethodModified: ann method ]
  595. ! !
  596. !HLBrowserSourceWidget methodsFor: 'initialization'!
  597. initialize
  598. super initialize.
  599. self observeSystem
  600. ! !
  601. !HLBrowserSourceWidget methodsFor: 'reactions'!
  602. onClassSelected: aClass
  603. aClass ifNil: [ ^ self contents: '' ].
  604. self contents: aClass definition
  605. !
  606. onMethodModified: aMethod
  607. self model selectedClass = aMethod methodClass ifFalse: [ ^ self ].
  608. self model selectedMethod selector = aMethod selector ifFalse: [ ^ self ].
  609. self refresh
  610. !
  611. onMethodSelected: aCompiledMethod
  612. aCompiledMethod ifNil: [ ^ self contents: '' ].
  613. self contents: aCompiledMethod source
  614. !
  615. onProtocolSelected: aString
  616. self model selectedClass ifNil: [ ^ self contents: '' ].
  617. self contents: self model selectedClass definition
  618. ! !
  619. !HLBrowserSourceWidget methodsFor: 'rendering'!
  620. renderContentOn: html
  621. self codeWidget renderOn: html
  622. ! !
  623. !HLBrowserSourceWidget methodsFor: 'testing'!
  624. hasModification
  625. ^ (self methodContents = self contents) not
  626. ! !
  627. !HLBrowserSourceWidget methodsFor: 'updating'!
  628. refresh
  629. self hasModification ifTrue: [ ^ self ].
  630. self contents: self model selectedMethod source.
  631. super refresh
  632. ! !
  633. !HLBrowserSourceWidget class methodsFor: 'instance creation'!
  634. on: aBrowserModel
  635. ^ self new
  636. model: aBrowserModel;
  637. yourself
  638. ! !
  639. Object subclass: #HLClassCache
  640. instanceVariableNames: 'class selectorsCache overrideCache overriddenCache'
  641. package: 'Helios-Browser'!
  642. !HLClassCache methodsFor: 'accessing'!
  643. overriddenCache
  644. ^ overriddenCache ifNil: [ overriddenCache := HashedCollection new ]
  645. !
  646. overrideCache
  647. ^ overrideCache ifNil: [ overrideCache := HashedCollection new ]
  648. !
  649. selectorsCache
  650. ^ selectorsCache
  651. !
  652. selectorsCache: aCache
  653. selectorsCache := aCache
  654. !
  655. theClass
  656. ^ class
  657. !
  658. theClass: aClass
  659. class := aClass
  660. ! !
  661. !HLClassCache methodsFor: 'actions'!
  662. invalidateChildrenSelector: aSelector
  663. self theClass subclasses do: [ :each |
  664. (self selectorsCache cacheFor: each)
  665. removeSelector: aSelector;
  666. invalidateChildrenSelector: aSelector ]
  667. !
  668. invalidateParentSelector: aSelector
  669. self theClass superclass ifNotNil: [
  670. (self selectorsCache cacheFor: self theClass superclass)
  671. removeSelector: aSelector;
  672. invalidateParentSelector: aSelector ]
  673. !
  674. invalidateSelector: aSelector
  675. self
  676. invalidateParentSelector: aSelector;
  677. invalidateChildrenSelector: aSelector;
  678. removeSelector: aSelector
  679. ! !
  680. !HLClassCache methodsFor: 'private'!
  681. removeSelector: aSelector
  682. self overriddenCache
  683. removeKey: aSelector
  684. ifAbsent: [ ].
  685. self overrideCache
  686. removeKey: aSelector
  687. ifAbsent: [ ]
  688. ! !
  689. !HLClassCache methodsFor: 'testing'!
  690. isOverridden: aMethod
  691. ^ self overriddenCache
  692. at: aMethod selector
  693. ifAbsentPut: [ aMethod isOverridden ]
  694. !
  695. isOverride: aMethod
  696. ^ self overrideCache
  697. at: aMethod selector
  698. ifAbsentPut: [ aMethod isOverride ]
  699. ! !
  700. !HLClassCache class methodsFor: 'instance creation'!
  701. on: aClass selectorsCache: aSelectorsCache
  702. ^ self new
  703. theClass: aClass;
  704. selectorsCache: aSelectorsCache;
  705. yourself
  706. ! !
  707. Object subclass: #HLSelectorsCache
  708. instanceVariableNames: 'classesCache'
  709. package: 'Helios-Browser'!
  710. !HLSelectorsCache methodsFor: 'accessing'!
  711. cacheFor: aClass
  712. aClass ifNil: [ ^ nil ].
  713. ^ self classesCache
  714. at: aClass name
  715. ifAbsentPut: [ self newCacheFor: aClass ]
  716. !
  717. classesCache
  718. ^ classesCache ifNil: [ classesCache := HashedCollection new ]
  719. ! !
  720. !HLSelectorsCache methodsFor: 'actions'!
  721. observeSystem
  722. SystemAnnouncer current
  723. on: MethodAdded
  724. do: [ :ann | self onMethodAdded: ann method ];
  725. on: MethodRemoved
  726. do: [ :ann | self onMethodRemoved: ann method ]
  727. ! !
  728. !HLSelectorsCache methodsFor: 'factory'!
  729. newCacheFor: aClass
  730. ^ HLClassCache
  731. on: aClass
  732. selectorsCache: self
  733. ! !
  734. !HLSelectorsCache methodsFor: 'initialization'!
  735. initialize
  736. super initialize.
  737. self observeSystem
  738. ! !
  739. !HLSelectorsCache methodsFor: 'private'!
  740. invalidateCacheFor: aMethod
  741. (self cacheFor: aMethod methodClass)
  742. invalidateSelector: aMethod selector
  743. ! !
  744. !HLSelectorsCache methodsFor: 'reactions'!
  745. onMethodAdded: aMethod
  746. self invalidateCacheFor: aMethod
  747. !
  748. onMethodRemoved: aMethod
  749. self invalidateCacheFor: aMethod
  750. ! !
  751. !HLSelectorsCache methodsFor: 'testing'!
  752. isOverridden: aMethod
  753. ^ (self cacheFor: aMethod methodClass)
  754. isOverridden: aMethod
  755. !
  756. isOverride: aMethod
  757. ^ (self cacheFor: aMethod methodClass)
  758. isOverride: aMethod
  759. ! !
  760. HLSelectorsCache class instanceVariableNames: 'current'!
  761. !HLSelectorsCache class methodsFor: 'accessing'!
  762. current
  763. ^ current ifNil: [ current := super new ]
  764. !
  765. flush
  766. current := nil
  767. ! !
  768. !HLSelectorsCache class methodsFor: 'instance creation'!
  769. new
  770. self shouldNotImplement
  771. ! !
  772. !CompiledMethod methodsFor: '*Helios-Browser'!
  773. isOverridden
  774. | selector |
  775. selector := self selector.
  776. self methodClass allSubclassesDo: [ :each |
  777. (each includesSelector: selector)
  778. ifTrue: [ ^ true ] ].
  779. ^ false
  780. !
  781. isOverride
  782. | superclass |
  783. superclass := self methodClass superclass.
  784. superclass ifNil: [ ^ false ].
  785. ^ (self methodClass superclass lookupSelector: self selector) isNil
  786. ! !