1
0

Helios-Browser.st 21 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006
  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. selectItem: aClass
  141. self model selectedClass: aClass
  142. !
  143. showInstance: aBoolean
  144. self model showInstance: aBoolean
  145. ! !
  146. !HLClassesListWidget methodsFor: 'reactions'!
  147. onClassSelected: aClass
  148. self selectedItem: aClass.
  149. aClass ifNil: [ ^ self ].
  150. self focus
  151. !
  152. onPackageSelected: aPackage
  153. self selectedItem: nil.
  154. self items: (aPackage
  155. ifNil: [ #() ]
  156. ifNotNil: [ (aPackage classes
  157. collect: [ :each | each theNonMetaClass ]) asSet asArray ]).
  158. self refresh
  159. !
  160. onShowInstanceToggled
  161. self refresh
  162. ! !
  163. !HLClassesListWidget methodsFor: 'rendering'!
  164. renderButtonsOn: html
  165. html div
  166. class: 'btn-group';
  167. at: 'data-toggle' put: 'buttons-radio';
  168. with: [
  169. html button
  170. class: (String streamContents: [ :str |
  171. str nextPutAll: 'btn'.
  172. self showInstance ifTrue: [
  173. str nextPutAll: ' active'] ]);
  174. with: 'Instance';
  175. onClick: [ self showInstance: true ].
  176. html button
  177. class: (String streamContents: [ :str |
  178. str nextPutAll: 'btn'.
  179. self model showInstance ifFalse: [
  180. str nextPutAll: ' active'] ]);
  181. with: 'Class';
  182. onClick: [ self model showInstance: false ] ].
  183. html button
  184. class: 'btn';
  185. at: 'data-toggle' put: 'button';
  186. with: 'Comment'
  187. !
  188. renderItem: aClass level: anInteger on: html
  189. | li |
  190. li := html li.
  191. li
  192. at: 'list-data' put: (self items indexOf: aClass);
  193. class: (self cssClassForItem: aClass);
  194. with: [
  195. html a
  196. with: [
  197. (html tag: 'i') class: (self iconForItem: aClass).
  198. self renderItemLabel: aClass level: anInteger on: html ];
  199. onClick: [
  200. self activateListItem: li asJQuery ] ].
  201. (self getChildrenOf: aClass) do: [ :each |
  202. self renderItem: each level: anInteger + 1 on: html ]
  203. !
  204. renderItem: aClass on: html
  205. super renderItem: aClass on: html.
  206. (self getChildrenOf: aClass) do: [ :each |
  207. self renderItem: each level: 1 on: html ]
  208. !
  209. renderItemLabel: aClass level: anInteger on: html
  210. html span asJQuery html: (String streamContents: [ :str |
  211. anInteger timesRepeat: [
  212. str nextPutAll: '    '].
  213. str nextPutAll: aClass name ])
  214. !
  215. renderItemLabel: aClass on: html
  216. self renderItemLabel: aClass level: 0 on: html
  217. !
  218. renderListOn: html
  219. (self getRootClassesOf: self items)
  220. do: [ :each | self renderItem: each on: html ]
  221. ! !
  222. HLBrowserListWidget subclass: #HLMethodsListWidget
  223. instanceVariableNames: ''
  224. package: 'Helios-Browser'!
  225. !HLMethodsListWidget methodsFor: 'accessing'!
  226. allProtocol
  227. ^ self model allProtocol
  228. !
  229. iconForItem: aSelector
  230. | override overriden method |
  231. method := self methodForSelector: aSelector.
  232. override := self isOverride: method.
  233. overriden := self isOverridden: method.
  234. ^ override
  235. ifTrue: [ overriden
  236. ifTrue: [ 'icon-resize-vertical' ]
  237. ifFalse: [ 'icon-arrow-up' ] ]
  238. ifFalse: [
  239. overriden
  240. ifTrue: [ 'icon-arrow-down' ]
  241. ifFalse: [ 'icon-none' ] ]
  242. !
  243. methodForSelector: aSelector
  244. ^ self model selectedClass
  245. methodDictionary at: aSelector
  246. !
  247. methodsInProtocol: aString
  248. ^ aString = self allProtocol
  249. ifTrue: [ self model selectedClass methods ]
  250. ifFalse: [ self model selectedClass methodsInProtocol: aString ]
  251. !
  252. overrideSelectors
  253. ^ self selectorsCache
  254. at: 'override'
  255. ifAbsentPut: [
  256. self model selectedClass allSuperclasses
  257. inject: Set new into: [ :acc :each | acc addAll: each selectors; yourself ] ]
  258. !
  259. overridenSelectors
  260. ^ self selectorsCache
  261. at: 'overriden'
  262. ifAbsentPut: [
  263. self model selectedClass allSubclasses
  264. inject: Set new into: [ :acc :each | acc addAll: each selectors; yourself ] ]
  265. !
  266. selectorsCache
  267. ^ self class selectorsCache
  268. !
  269. selectorsInProtocol: aString
  270. ^ (self methodsInProtocol: aString)
  271. collect: [ :each | each selector ]
  272. ! !
  273. !HLMethodsListWidget methodsFor: 'actions'!
  274. observeModel
  275. self model announcer on: HLProtocolSelected do: [ :ann |
  276. self onProtocolSelected: ann item ].
  277. self model announcer on: HLShowInstanceToggled do: [ :ann |
  278. self onProtocolSelected: nil ].
  279. self model announcer on: HLMethodSelected do: [ :ann |
  280. self onMethodSelected: ann item ]
  281. !
  282. observeSystem
  283. SystemAnnouncer current
  284. on: MethodAdded
  285. do: [ :ann | self onMethodAdded: ann method ];
  286. on: MethodRemoved
  287. do: [ :ann | self onMethodRemoved: ann method ]
  288. !
  289. selectItem: aSelector
  290. self model selectedMethod: (self methodForSelector: aSelector)
  291. ! !
  292. !HLMethodsListWidget methodsFor: 'cache'!
  293. flushSelectorsCache
  294. selectorsCache := Dictionary new
  295. ! !
  296. !HLMethodsListWidget methodsFor: 'initialization'!
  297. initialize
  298. super initialize.
  299. self flushSelectorsCache
  300. ! !
  301. !HLMethodsListWidget methodsFor: 'reactions'!
  302. onMethodAdded: aMethod
  303. self items detect: [ :each | each = aMethod selector ] ifNone: [ ^ self ].
  304. self refresh
  305. !
  306. onMethodRemoved: aMethod
  307. self items detect: [ :each | each selector = aMethod selector ] ifNone: [ ^ self ].
  308. self refresh
  309. !
  310. onMethodSelected: aMethod
  311. self selectedItem: aMethod.
  312. aMethod ifNil: [ ^ self ].
  313. self focus
  314. !
  315. onProtocolSelected: aString
  316. self selectedItem: nil.
  317. self items: (self model selectedClass
  318. ifNil: [ #() ]
  319. ifNotNil: [ aString
  320. ifNil: [ #() ]
  321. ifNotNil: [ self selectorsInProtocol: aString ] ]).
  322. self refresh
  323. ! !
  324. !HLMethodsListWidget methodsFor: 'rendering'!
  325. renderContentOn: html
  326. self model showInstance
  327. ifFalse: [ html div
  328. class: 'class_side';
  329. with: [ super renderContentOn: html ] ]
  330. ifTrue: [ super renderContentOn: html ]
  331. !
  332. renderItemLabel: aSelector on: html
  333. html with: aSelector
  334. ! !
  335. !HLMethodsListWidget methodsFor: 'testing'!
  336. isOverridden: aMethod
  337. ^ self selectorsCache isOverridden: aMethod
  338. !
  339. isOverride: aMethod
  340. ^ self selectorsCache isOverride: aMethod
  341. ! !
  342. HLMethodsListWidget class instanceVariableNames: 'selectorsCache'!
  343. !HLMethodsListWidget class methodsFor: 'accessing'!
  344. selectorsCache
  345. ^ HLSelectorsCache current
  346. ! !
  347. HLBrowserListWidget subclass: #HLPackagesListWidget
  348. instanceVariableNames: ''
  349. package: 'Helios-Browser'!
  350. !HLPackagesListWidget methodsFor: 'accessing'!
  351. initializeItems
  352. ^ items := self model packages sort:[:a :b|
  353. a name < b name]
  354. !
  355. items
  356. ^ items ifNil: [self initializeItems]
  357. ! !
  358. !HLPackagesListWidget methodsFor: 'actions'!
  359. focusClassesListWidget
  360. self model announcer announce: HLClassesListFocus new
  361. !
  362. observeModel
  363. self model announcer on: HLPackageSelected do: [ :ann |
  364. self onPackageSelected: ann item ]
  365. !
  366. selectItem: aPackage
  367. self model selectedPackage: aPackage
  368. ! !
  369. !HLPackagesListWidget methodsFor: 'reactions'!
  370. onPackageSelected: aPackage
  371. self selectedItem: aPackage.
  372. self focus
  373. ! !
  374. !HLPackagesListWidget methodsFor: 'rendering'!
  375. renderButtonsOn: html
  376. html span class: 'info'; with: 'Auto commit'.
  377. html div
  378. class: 'btn-group switch';
  379. at: 'data-toggle' put: 'buttons-radio';
  380. with: [
  381. html button
  382. class: (String streamContents: [ :str |
  383. str nextPutAll: 'btn' ]);
  384. with: 'On'.
  385. html button
  386. class: (String streamContents: [ :str |
  387. str nextPutAll: 'btn active' ]);
  388. with: 'Off' ].
  389. html a
  390. class: 'btn';
  391. with: 'Commit'.
  392. ! !
  393. HLBrowserListWidget subclass: #HLProtocolsListWidget
  394. instanceVariableNames: ''
  395. package: 'Helios-Browser'!
  396. !HLProtocolsListWidget methodsFor: 'accessing'!
  397. allProtocol
  398. ^ self model allProtocol
  399. !
  400. selectedItem
  401. ^ super selectedItem" ifNil: [ self allProtocol ]"
  402. ! !
  403. !HLProtocolsListWidget methodsFor: 'actions'!
  404. observeModel
  405. self model announcer on: HLClassSelected do: [ :ann |
  406. self onClassSelected: ann item ].
  407. self model announcer on: HLShowInstanceToggled do: [ :ann |
  408. self onClassSelected: self model selectedClass ].
  409. self model announcer on: HLProtocolSelected do: [ :ann |
  410. self onProtocolSelected: ann item ]
  411. !
  412. selectItem: aString
  413. self model selectedProtocol: aString
  414. ! !
  415. !HLProtocolsListWidget methodsFor: 'reactions'!
  416. onClassSelected: aClass
  417. self selectedItem: nil.
  418. self items: (aClass
  419. ifNil: [ Array with: self allProtocol ]
  420. ifNotNil: [
  421. (Array with: self allProtocol)
  422. addAll: aClass protocols;
  423. yourself ]).
  424. self refresh
  425. !
  426. onProtocolSelected: aString
  427. self selectedItem: aString.
  428. aString ifNil: [ ^ self ].
  429. self focus
  430. ! !
  431. !HLProtocolsListWidget methodsFor: 'rendering'!
  432. renderContentOn: html
  433. self model showInstance
  434. ifFalse: [ html div
  435. class: 'class_side';
  436. with: [ super renderContentOn: html ] ]
  437. ifTrue: [ super renderContentOn: html ]
  438. ! !
  439. Object subclass: #HLBrowserModel
  440. instanceVariableNames: 'announcer environment selectedPackage selectedClass selectedProtocol selectedSelector showInstance showComment'
  441. package: 'Helios-Browser'!
  442. !HLBrowserModel methodsFor: 'accessing'!
  443. allProtocol
  444. ^ '-- All --'
  445. !
  446. announcer
  447. ^ announcer ifNil: [ announcer := Announcer new ]
  448. !
  449. environment
  450. ^ environment ifNil: [ HLManager current environment ]
  451. !
  452. environment: anEnvironment
  453. environment := anEnvironment
  454. !
  455. packages
  456. ^ self environment packages
  457. !
  458. selectedClass
  459. ^ selectedClass
  460. !
  461. selectedClass: aClass
  462. selectedClass = aClass ifTrue: [ ^ self ].
  463. aClass
  464. ifNil: [ selectedClass := nil ]
  465. ifNotNil: [
  466. self showInstance
  467. ifTrue: [ selectedClass := aClass theNonMetaClass ]
  468. ifFalse: [ selectedClass := aClass theMetaClass ] ].
  469. self selectedProtocol: nil.
  470. self announcer announce: (HLClassSelected on: self selectedClass)
  471. !
  472. selectedMethod
  473. ^ self selectedClass
  474. ifNotNil: [ self selectedClass methodDictionary at: selectedSelector ]
  475. !
  476. selectedMethod: aCompiledMethod
  477. selectedSelector = aCompiledMethod ifTrue: [ ^ self ].
  478. aCompiledMethod
  479. ifNil: [ selectedSelector := nil ]
  480. ifNotNil: [
  481. selectedSelector = aCompiledMethod selector ifTrue: [ ^ self ].
  482. selectedSelector := aCompiledMethod selector ].
  483. self announcer announce: (HLMethodSelected on: aCompiledMethod)
  484. !
  485. selectedPackage
  486. ^ selectedPackage
  487. !
  488. selectedPackage: aPackage
  489. selectedPackage = aPackage ifTrue: [ ^ self ].
  490. selectedPackage := aPackage.
  491. self selectedClass: nil.
  492. self announcer announce: (HLPackageSelected on: aPackage)
  493. !
  494. selectedProtocol
  495. ^ selectedProtocol
  496. !
  497. selectedProtocol: aString
  498. selectedProtocol = aString ifTrue: [ ^ self ].
  499. selectedProtocol := aString.
  500. self selectedMethod: nil.
  501. self announcer announce: (HLProtocolSelected on: aString)
  502. !
  503. showComment
  504. ^ showComment ifNil: [ false ]
  505. !
  506. showComment: aBoolean
  507. showComment := aBoolean.
  508. self announcer announce: HLShowCommentToggled new
  509. !
  510. showInstance
  511. ^ showInstance ifNil: [ true ]
  512. !
  513. showInstance: aBoolean
  514. showInstance := aBoolean.
  515. self selectedClass ifNotNil: [
  516. self selectedClass: (aBoolean
  517. ifTrue: [self selectedClass theNonMetaClass ]
  518. ifFalse: [ self selectedClass theMetaClass ]) ].
  519. self announcer announce: HLShowInstanceToggled new
  520. ! !
  521. !HLBrowserModel class methodsFor: 'actions'!
  522. on: anEnvironment
  523. ^ self new
  524. environment: anEnvironment;
  525. yourself
  526. ! !
  527. HLWidget subclass: #HLBrowserSourceWidget
  528. instanceVariableNames: 'model methodContents codeWidget'
  529. package: 'Helios-Browser'!
  530. !HLBrowserSourceWidget methodsFor: 'accessing'!
  531. codeWidget
  532. ^ codeWidget ifNil: [ codeWidget := HLCodeWidget new ]
  533. !
  534. contents
  535. ^ self codeWidget contents
  536. !
  537. contents: aString
  538. self methodContents: aString.
  539. self codeWidget contents: aString
  540. !
  541. methodContents
  542. ^ methodContents ifNil: [ methodContents := '' ]
  543. !
  544. methodContents: aString
  545. methodContents := aString
  546. !
  547. model
  548. ^ model
  549. !
  550. model: aBrowserModel
  551. model := aBrowserModel.
  552. self observeModel
  553. ! !
  554. !HLBrowserSourceWidget methodsFor: 'actions'!
  555. observeModel
  556. self model announcer on: HLMethodSelected do: [ :ann |
  557. self onMethodSelected: ann item ].
  558. self model announcer on: HLClassSelected do: [ :ann |
  559. self onClassSelected: ann item ].
  560. self model announcer on: HLProtocolSelected do: [ :ann |
  561. self onProtocolSelected: ann item ]
  562. !
  563. observeSystem
  564. SystemAnnouncer current
  565. on: MethodModified
  566. do: [ :ann | self onMethodModified: ann method ]
  567. ! !
  568. !HLBrowserSourceWidget methodsFor: 'initialization'!
  569. initialize
  570. super initialize.
  571. self observeSystem
  572. ! !
  573. !HLBrowserSourceWidget methodsFor: 'reactions'!
  574. onClassSelected: aClass
  575. aClass ifNil: [ ^ self contents: '' ].
  576. self contents: aClass definition
  577. !
  578. onMethodModified: aMethod
  579. self model selectedClass = aMethod methodClass ifFalse: [ ^ self ].
  580. self model selectedMethod selector = aMethod selector ifFalse: [ ^ self ].
  581. self refresh
  582. !
  583. onMethodSelected: aCompiledMethod
  584. aCompiledMethod ifNil: [ ^ self contents: '' ].
  585. self contents: aCompiledMethod source
  586. !
  587. onProtocolSelected: aString
  588. self model selectedClass ifNil: [ ^ self contents: '' ].
  589. self contents: self model selectedClass definition
  590. ! !
  591. !HLBrowserSourceWidget methodsFor: 'rendering'!
  592. renderContentOn: html
  593. self codeWidget renderOn: html
  594. ! !
  595. !HLBrowserSourceWidget methodsFor: 'testing'!
  596. hasModification
  597. ^ (self methodContents = self contents) not
  598. ! !
  599. !HLBrowserSourceWidget methodsFor: 'updating'!
  600. refresh
  601. self hasModification ifTrue: [ ^ self ].
  602. self contents: self model selectedMethod source.
  603. super refresh
  604. ! !
  605. !HLBrowserSourceWidget class methodsFor: 'instance creation'!
  606. on: aBrowserModel
  607. ^ self new
  608. model: aBrowserModel;
  609. yourself
  610. ! !
  611. Object subclass: #HLClassCache
  612. instanceVariableNames: 'class selectorsCache overrideCache overriddenCache'
  613. package: 'Helios-Browser'!
  614. !HLClassCache methodsFor: 'accessing'!
  615. overriddenCache
  616. ^ overriddenCache ifNil: [ overriddenCache := HashedCollection new ]
  617. !
  618. overrideCache
  619. ^ overrideCache ifNil: [ overrideCache := HashedCollection new ]
  620. !
  621. selectorsCache
  622. ^ selectorsCache
  623. !
  624. selectorsCache: aCache
  625. selectorsCache := aCache
  626. !
  627. theClass
  628. ^ class
  629. !
  630. theClass: aClass
  631. class := aClass
  632. ! !
  633. !HLClassCache methodsFor: 'actions'!
  634. invalidateChildrenSelector: aSelector
  635. self theClass subclasses do: [ :each |
  636. (self selectorsCache cacheFor: each)
  637. removeSelector: aSelector;
  638. invalidateChildrenSelector: aSelector ]
  639. !
  640. invalidateParentSelector: aSelector
  641. self theClass superclass ifNotNil: [
  642. (self selectorsCache cacheFor: self theClass superclass)
  643. removeSelector: aSelector;
  644. invalidateParentSelector: aSelector ]
  645. !
  646. invalidateSelector: aSelector
  647. self
  648. invalidateParentSelector: aSelector;
  649. invalidateChildrenSelector: aSelector;
  650. removeSelector: aSelector
  651. ! !
  652. !HLClassCache methodsFor: 'private'!
  653. removeSelector: aSelector
  654. self overriddenCache
  655. removeKey: aSelector
  656. ifAbsent: [ ].
  657. self overrideCache
  658. removeKey: aSelector
  659. ifAbsent: [ ]
  660. ! !
  661. !HLClassCache methodsFor: 'testing'!
  662. isOverridden: aMethod
  663. ^ self overriddenCache
  664. at: aMethod selector
  665. ifAbsentPut: [ aMethod isOverridden ]
  666. !
  667. isOverride: aMethod
  668. ^ self overrideCache
  669. at: aMethod selector
  670. ifAbsentPut: [ aMethod isOverride ]
  671. ! !
  672. !HLClassCache class methodsFor: 'instance creation'!
  673. on: aClass selectorsCache: aSelectorsCache
  674. ^ self new
  675. theClass: aClass;
  676. selectorsCache: aSelectorsCache;
  677. yourself
  678. ! !
  679. Object subclass: #HLSelectorsCache
  680. instanceVariableNames: 'classesCache'
  681. package: 'Helios-Browser'!
  682. !HLSelectorsCache methodsFor: 'accessing'!
  683. cacheFor: aClass
  684. aClass ifNil: [ ^ nil ].
  685. ^ self classesCache
  686. at: aClass name
  687. ifAbsentPut: [ self newCacheFor: aClass ]
  688. !
  689. classesCache
  690. ^ classesCache ifNil: [ classesCache := HashedCollection new ]
  691. ! !
  692. !HLSelectorsCache methodsFor: 'actions'!
  693. observeSystem
  694. SystemAnnouncer current
  695. on: MethodAdded
  696. do: [ :ann | self onMethodAdded: ann method ];
  697. on: MethodRemoved
  698. do: [ :ann | self onMethodRemoved: ann method ]
  699. ! !
  700. !HLSelectorsCache methodsFor: 'factory'!
  701. newCacheFor: aClass
  702. ^ HLClassCache
  703. on: aClass
  704. selectorsCache: self
  705. ! !
  706. !HLSelectorsCache methodsFor: 'initialization'!
  707. initialize
  708. super initialize.
  709. self observeSystem
  710. ! !
  711. !HLSelectorsCache methodsFor: 'private'!
  712. invalidateCacheFor: aMethod
  713. (self cacheFor: aMethod methodClass)
  714. invalidateSelector: aMethod selector
  715. ! !
  716. !HLSelectorsCache methodsFor: 'reactions'!
  717. onMethodAdded: aMethod
  718. self invalidateCacheFor: aMethod
  719. !
  720. onMethodRemoved: aMethod
  721. self invalidateCacheFor: aMethod
  722. ! !
  723. !HLSelectorsCache methodsFor: 'testing'!
  724. isOverridden: aMethod
  725. ^ (self cacheFor: aMethod methodClass)
  726. isOverridden: aMethod
  727. !
  728. isOverride: aMethod
  729. ^ (self cacheFor: aMethod methodClass)
  730. isOverride: aMethod
  731. ! !
  732. HLSelectorsCache class instanceVariableNames: 'current'!
  733. !HLSelectorsCache class methodsFor: 'accessing'!
  734. current
  735. ^ current ifNil: [ current := super new ]
  736. !
  737. flush
  738. current := nil
  739. ! !
  740. !HLSelectorsCache class methodsFor: 'instance creation'!
  741. new
  742. self shouldNotImplement
  743. ! !
  744. !CompiledMethod methodsFor: '*Helios-Browser'!
  745. isOverridden
  746. | selector |
  747. selector := self selector.
  748. self methodClass allSubclassesDo: [ :each |
  749. (each includesSelector: selector)
  750. ifTrue: [ ^ true ] ].
  751. ^ false
  752. !
  753. isOverride
  754. | superclass |
  755. superclass := self methodClass superclass.
  756. superclass ifNil: [ ^ false ].
  757. ^ (self methodClass superclass lookupSelector: self selector) isNil
  758. ! !