36
|
1 |
"{ Package: 'Programming Tools' }"
|
|
2 |
|
|
3 |
"
|
|
4 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
|
5 |
All Rights Reserved
|
|
6 |
|
|
7 |
This software is furnished under a license and may be used
|
|
8 |
only in accordance with the terms of that license and with the
|
|
9 |
inclusion of the above copyright notice. This software may not
|
|
10 |
be provided or otherwise made available to, or used by, any
|
|
11 |
other person. No title to or ownership of the software is
|
|
12 |
hereby transferred.
|
|
13 |
"
|
|
14 |
|
|
15 |
StandardSystemView subclass:#SystemBrowser
|
|
16 |
instanceVariableNames:'classCategoryListView classListView
|
|
17 |
methodCategoryListView methodListView
|
|
18 |
classMethodListView
|
|
19 |
codeView classToggle instanceToggle
|
|
20 |
currentClassCategory currentClassHierarchy
|
|
21 |
currentClass
|
|
22 |
currentMethodCategory currentMethod
|
|
23 |
showInstance actualClass fullClass
|
|
24 |
enterBox questBox
|
|
25 |
selectBox lastMethodCategory'
|
|
26 |
classVariableNames:''
|
|
27 |
poolDictionaries:''
|
|
28 |
category:'Interface-Browsers'
|
|
29 |
!
|
|
30 |
|
|
31 |
SystemBrowser comment:'
|
|
32 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
|
33 |
All Rights Reserved
|
|
34 |
|
|
35 |
$Header: /cvs/stx/stx/libtool/SystemBrowser.st,v 1.10 1994-08-13 18:39:07 claus Exp $
|
|
36 |
'!
|
|
37 |
|
|
38 |
!SystemBrowser class methodsFor:'documentation'!
|
|
39 |
|
|
40 |
copyright
|
|
41 |
"
|
|
42 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
|
43 |
All Rights Reserved
|
|
44 |
|
|
45 |
This software is furnished under a license and may be used
|
|
46 |
only in accordance with the terms of that license and with the
|
|
47 |
inclusion of the above copyright notice. This software may not
|
|
48 |
be provided or otherwise made available to, or used by, any
|
|
49 |
other person. No title to or ownership of the software is
|
|
50 |
hereby transferred.
|
|
51 |
"
|
|
52 |
!
|
|
53 |
|
|
54 |
version
|
|
55 |
"
|
|
56 |
$Header: /cvs/stx/stx/libtool/SystemBrowser.st,v 1.10 1994-08-13 18:39:07 claus Exp $
|
|
57 |
"
|
|
58 |
!
|
|
59 |
|
|
60 |
documentation
|
|
61 |
"
|
|
62 |
this class implements all kinds of class browsers.
|
|
63 |
Stypically, it is started with SystemBrowser open, but there are many other startup
|
|
64 |
messages, to launch special browsers.
|
|
65 |
See the extra document 'doc/misc/sbrowser.doc' for how to use this browser.
|
|
66 |
|
|
67 |
written winter 89 by claus
|
|
68 |
"
|
|
69 |
! !
|
|
70 |
|
|
71 |
!SystemBrowser class methodsFor:'general startup'!
|
|
72 |
|
|
73 |
open
|
|
74 |
"launch a standard browser"
|
|
75 |
|
|
76 |
^ self openOnDisplay:Display
|
|
77 |
|
|
78 |
"SystemBrowser open"
|
|
79 |
!
|
|
80 |
|
|
81 |
openOnDisplay:aDisplay
|
|
82 |
"launch a standard browser on another display.
|
|
83 |
Does not work currently - still being developped."
|
|
84 |
|
|
85 |
^ self newWithLabel:(self classResources string:'System Browser')
|
|
86 |
setupBlock:[:browser | browser setupForAll]
|
|
87 |
on:aDisplay
|
|
88 |
|
|
89 |
"
|
|
90 |
SystemBrowser openOnDisplay:(XWorkstation new initializeFor:'porty:0')
|
|
91 |
"
|
|
92 |
! !
|
|
93 |
|
|
94 |
!SystemBrowser class methodsFor:'startup'!
|
|
95 |
|
|
96 |
browseFullClasses
|
|
97 |
"launch a browser showing all methods at once"
|
|
98 |
|
|
99 |
^ self newWithLabel:'Full Class Browser'
|
|
100 |
setupBlock:[:browser | browser setupForFullClass]
|
|
101 |
|
|
102 |
"SystemBrowser browseFullClasses"
|
|
103 |
!
|
|
104 |
|
|
105 |
browseClassCategory:aClassCategory
|
|
106 |
"launch a browser for all classes under aCategory"
|
|
107 |
|
|
108 |
^ self newWithLabel:aClassCategory
|
|
109 |
setupBlock:[:browser | browser setupForClassCategory:aClassCategory]
|
|
110 |
|
|
111 |
"SystemBrowser browseClassCategory:'Kernel-Objects'"
|
|
112 |
!
|
|
113 |
|
|
114 |
browseClass:aClass
|
|
115 |
"launch a browser for aClass"
|
|
116 |
|
|
117 |
^ self newWithLabel:aClass name
|
|
118 |
setupBlock:[:browser | browser setupForClass:aClass]
|
|
119 |
|
|
120 |
"SystemBrowser browseClass:Object"
|
|
121 |
!
|
|
122 |
|
|
123 |
browseClassHierarchy:aClass
|
|
124 |
"launch a browser for aClass and all its superclasses"
|
|
125 |
|
|
126 |
^ self newWithLabel:(aClass name , '-' , 'hierarchy')
|
|
127 |
setupBlock:[:browser | browser setupForClassHierarchy:aClass]
|
|
128 |
|
|
129 |
"SystemBrowser browseClassHierarchy:Number"
|
|
130 |
!
|
|
131 |
|
|
132 |
browseClasses:aList title:title
|
|
133 |
"launch a browser for all classes in aList"
|
|
134 |
|
|
135 |
^ self newWithLabel:title
|
|
136 |
setupBlock:[:browser | browser setupForClassList:aList]
|
|
137 |
|
|
138 |
"
|
|
139 |
SystemBrowser browseClasses:(Array with:Object
|
|
140 |
with:Float)
|
|
141 |
title:'two classes'
|
|
142 |
"
|
|
143 |
!
|
|
144 |
|
|
145 |
browseClass:aClass methodCategory:aCategory
|
|
146 |
"launch a browser for all methods under aCategory in aClass"
|
|
147 |
|
|
148 |
^ self newWithLabel:(aClass name , ' ' , aCategory)
|
|
149 |
setupBlock:[:browser | browser setupForClass:aClass methodCategory:aCategory]
|
|
150 |
|
|
151 |
"SystemBrowser browseClass:String methodCategory:'copying'"
|
|
152 |
!
|
|
153 |
|
|
154 |
browseClass:aClass selector:selector
|
|
155 |
"launch a browser for the method at selector in aClass"
|
|
156 |
|
|
157 |
^ self newWithLabel:(aClass name , ' ' , selector)
|
|
158 |
setupBlock:[:browser | browser setupForClass:aClass selector:selector]
|
|
159 |
|
|
160 |
"SystemBrowser browseClass:Object selector:#printString"
|
|
161 |
!
|
|
162 |
|
|
163 |
browseMethods:aList title:aString
|
|
164 |
"launch a browser for an explicit list of class/selectors"
|
|
165 |
|
|
166 |
(aList size == 0) ifTrue:[
|
|
167 |
self showNoneFound:aString.
|
|
168 |
^ nil
|
|
169 |
].
|
|
170 |
aList sort.
|
|
171 |
^ self newWithLabel:aString
|
|
172 |
setupBlock:[:browser | browser setupForList:aList]
|
|
173 |
|
|
174 |
"
|
|
175 |
SystemBrowser browseMethods:#('Object printOn:'
|
|
176 |
'Collection add:')
|
|
177 |
title:'some methods'
|
|
178 |
"
|
|
179 |
!
|
|
180 |
|
|
181 |
browseMethodCategory:aCategory
|
|
182 |
"launch a browser for all methods where category = aCategory"
|
|
183 |
|
|
184 |
|searchBlock|
|
|
185 |
|
|
186 |
aCategory includesMatchCharacters ifTrue:[
|
|
187 |
searchBlock := [:c :m :s | aCategory match:m category].
|
|
188 |
] ifFalse:[
|
|
189 |
searchBlock := [:c :m :s | m category = aCategory]
|
|
190 |
].
|
|
191 |
|
|
192 |
self browseMethodsWhere:searchBlock title:('all methods with category of ' , aCategory)
|
|
193 |
|
|
194 |
"
|
|
195 |
SystemBrowser browseMethodCategory:'printing & storing'
|
|
196 |
SystemBrowser browseMethodCategory:'print*'
|
|
197 |
"
|
|
198 |
!
|
|
199 |
|
|
200 |
browseAllSelect:aBlock
|
|
201 |
"launch a browser for all methods where aBlock returns true.
|
|
202 |
The block is called with 3 arguments, class, method and seelctor."
|
|
203 |
|
|
204 |
^ self browseMethodsWhere:aBlock title:'selected messages'
|
|
205 |
!
|
|
206 |
|
|
207 |
browseMethodsWhere:aBlock title:title
|
|
208 |
"launch a browser for all methods where aBlock returns true.
|
|
209 |
The block is called with 3 arguments, class, method and seelctor."
|
|
210 |
|
|
211 |
^ self browseMethodsIn:(Smalltalk allClasses) where:aBlock title:title
|
|
212 |
!
|
|
213 |
|
|
214 |
browseMethodsOf:aClass where:aBlock title:title
|
|
215 |
"launch a browser for all instance- and classmethods in aClass
|
|
216 |
where aBlock evaluates to true.
|
|
217 |
The block is called with 3 arguments, class, method and seelctor."
|
|
218 |
|
|
219 |
^ self browseMethodsIn:(Array with:aClass) where:aBlock title:title
|
|
220 |
!
|
|
221 |
|
|
222 |
browseMethodsFrom:aClass where:aBlock title:title
|
|
223 |
"launch a browser for all instance- and classmethods in aClass
|
|
224 |
and all its subclasses where aBlock evaluates to true.
|
|
225 |
The block is called with 3 arguments, class, method and seelctor."
|
|
226 |
|
|
227 |
^ self browseMethodsIn:(aClass withAllSubclasses) where:aBlock title:title
|
|
228 |
!
|
|
229 |
|
|
230 |
browseMethodsIn:aCollectionOfClasses where:aBlock title:title
|
|
231 |
"launch a browser for all instance- and classmethods from
|
|
232 |
all classes in aCollectionOfClasses where aBlock evaluates to true.
|
|
233 |
The block is called with 3 arguments, class, method and seelctor."
|
|
234 |
|
|
235 |
^ self browseMethodsIn:aCollectionOfClasses inst:true class:true where:aBlock title:title
|
|
236 |
!
|
|
237 |
|
|
238 |
browseMethodsIn:aCollectionOfClasses inst:wantInst class:wantClass where:aBlock title:title
|
|
239 |
"launch a browser for all instance- (if wantInst is true) and/or
|
|
240 |
classmethods (if wantClass is true) from classes in aCollectionOfClasses,
|
|
241 |
where aBlock evaluates to true.
|
|
242 |
The block is called with 3 arguments, class, method and seelctor."
|
|
243 |
|
|
244 |
|list prio checkedClasses checkBlock|
|
|
245 |
|
|
246 |
"
|
|
247 |
since this may take a long time, lower my priority ...
|
|
248 |
"
|
|
249 |
prio := Processor activeProcess priority.
|
|
250 |
Processor activeProcess priority:(prio - 1).
|
|
251 |
|
|
252 |
checkBlock := [:cls |
|
|
253 |
|methodArray selectorArray|
|
|
254 |
|
|
255 |
(checkedClasses includes:cls) ifFalse:[
|
|
256 |
methodArray := cls methodArray.
|
|
257 |
selectorArray := cls selectorArray.
|
|
258 |
|
|
259 |
1 to:methodArray size do:[:index |
|
|
260 |
|method sel|
|
|
261 |
|
|
262 |
method := methodArray at:index.
|
|
263 |
sel := selectorArray at:index.
|
|
264 |
(aBlock value:cls value:method value:sel) ifTrue:[
|
|
265 |
list add:(cls name , ' ' , sel)
|
|
266 |
]
|
|
267 |
].
|
|
268 |
checkedClasses add:cls.
|
|
269 |
]
|
|
270 |
].
|
|
271 |
|
|
272 |
[
|
|
273 |
checkedClasses := IdentitySet new.
|
|
274 |
list := OrderedCollection new.
|
|
275 |
aCollectionOfClasses do:[:aClass |
|
|
276 |
wantInst ifTrue:[checkBlock value:aClass].
|
|
277 |
wantClass ifTrue:[checkBlock value:(aClass class)]
|
|
278 |
]
|
|
279 |
] valueNowOrOnUnwindDo:[
|
|
280 |
Processor activeProcess priority:prio.
|
|
281 |
].
|
|
282 |
|
|
283 |
^ self browseMethods:list title:title
|
|
284 |
!
|
|
285 |
|
|
286 |
browseInstMethodsOf:aClass where:aBlock title:title
|
|
287 |
"launch a browser for all instance methods in aClass
|
|
288 |
where aBlock evaluates to true"
|
|
289 |
|
|
290 |
^ self browseMethodsIn:(Array with:aClass) inst:true class:false where:aBlock title:title
|
|
291 |
!
|
|
292 |
|
|
293 |
browseInstMethodsFrom:aClass where:aBlock title:title
|
|
294 |
"launch a browser for all instance methods in aClass and all subclasses
|
|
295 |
where aBlock evaluates to true"
|
|
296 |
|
|
297 |
^ self browseMethodsIn:(aClass withAllSubclasses) inst:true class:false where:aBlock title:title
|
|
298 |
!
|
|
299 |
|
|
300 |
browseInstMethodsIn:aCollectionOfClasses where:aBlock title:title
|
|
301 |
"launch a browser for all instance methods of all classes in
|
|
302 |
aCollectionOfClasses where aBlock evaluates to true"
|
|
303 |
|
|
304 |
^ self browseMethodsIn:aCollectionOfClasses inst:true class:false
|
|
305 |
where:aBlock title:title
|
|
306 |
! !
|
|
307 |
|
|
308 |
!SystemBrowser class methodsFor:'special search startup'!
|
|
309 |
|
|
310 |
browseImplementorsOf:aSelectorString in:aCollectionOfClasses title:title
|
|
311 |
"launch a browser for all implementors of aSelector in
|
|
312 |
the classes contained in aCollectionOfClasses and its metaclasses"
|
|
313 |
|
|
314 |
|list sel|
|
|
315 |
|
|
316 |
list := OrderedCollection new.
|
|
317 |
|
|
318 |
((aSelectorString ~= '*') and:[aSelectorString includesMatchCharacters]) ifTrue:[
|
|
319 |
"a matchString"
|
|
320 |
|
|
321 |
aCollectionOfClasses do:[:aClass |
|
|
322 |
aClass selectorArray do:[:aSelector |
|
|
323 |
(aSelectorString match:aSelector) ifTrue:[
|
|
324 |
list add:(aClass name , ' ' , aSelector)
|
|
325 |
]
|
|
326 |
].
|
|
327 |
aClass class selectorArray do:[:aSelector |
|
|
328 |
(aSelectorString match:aSelector) ifTrue:[
|
|
329 |
list add:(aClass name , 'class ' , aSelector)
|
|
330 |
]
|
|
331 |
]
|
|
332 |
]
|
|
333 |
] ifFalse:[
|
|
334 |
"can do a faster search"
|
|
335 |
|
|
336 |
aSelectorString knownAsSymbol ifFalse:[
|
|
337 |
self showNoneFound:title.
|
|
338 |
^ nil
|
|
339 |
].
|
|
340 |
|
|
341 |
sel := aSelectorString asSymbol.
|
|
342 |
aCollectionOfClasses do:[:aClass |
|
|
343 |
(aClass implements:sel) ifTrue:[
|
|
344 |
list add:(aClass name , ' ' , aSelectorString)
|
|
345 |
].
|
|
346 |
(aClass class implements:sel) ifTrue:[
|
|
347 |
list add:(aClass name , 'class ' , aSelectorString)
|
|
348 |
]
|
|
349 |
]
|
|
350 |
].
|
|
351 |
^ self browseMethods:list title:title
|
|
352 |
|
|
353 |
"
|
|
354 |
SystemBrowser browseImplementorsOf:#+
|
|
355 |
in:(Array with:Number
|
|
356 |
with:Float
|
|
357 |
with:SmallInteger)
|
|
358 |
title:'some implementors of +'
|
|
359 |
"
|
|
360 |
!
|
|
361 |
|
|
362 |
browseImplementorsOf:aSelectorString
|
|
363 |
"launch a browser for all implementors of aSelector"
|
|
364 |
|
|
365 |
^ self browseImplementorsOf:aSelectorString
|
|
366 |
in:(Smalltalk allClasses)
|
|
367 |
title:('implementors of: ' , aSelectorString)
|
|
368 |
|
|
369 |
"
|
|
370 |
SystemBrowser browseImplementorsOf:#+
|
|
371 |
"
|
|
372 |
!
|
|
373 |
|
|
374 |
browseImplementorsOf:aSelectorString under:aClass
|
|
375 |
"launch a browser for all implementors of aSelector in aClass
|
|
376 |
and its subclasses"
|
|
377 |
|
|
378 |
^ self browseImplementorsOf:aSelectorString
|
|
379 |
in:(aClass withAllSubclasses)
|
|
380 |
title:('implementors of: ' ,
|
|
381 |
aSelectorString ,
|
|
382 |
' (in or below ' , aClass name , ')')
|
|
383 |
|
|
384 |
"
|
|
385 |
SystemBrowser browseImplementorsOf:#+ under:Integer
|
|
386 |
"
|
|
387 |
!
|
|
388 |
|
|
389 |
browseAllCallsOn:aSelectorString in:aCollectionOfClasses title:title
|
|
390 |
"launch a browser for all senders of aSelector in aCollectionOfClasses"
|
|
391 |
|
|
392 |
|sel browser searchBlock|
|
|
393 |
|
|
394 |
((aSelectorString ~= '*') and:[aSelectorString includesMatchCharacters]) ifTrue:[
|
|
395 |
"a matchString"
|
|
396 |
searchBlock := [:lits |
|
|
397 |
|found|
|
|
398 |
|
|
399 |
found := false.
|
|
400 |
lits notNil ifTrue:[
|
|
401 |
lits do:[:aLiteral |
|
|
402 |
found ifFalse:[
|
|
403 |
(aLiteral isMemberOf:Symbol) ifTrue:[
|
|
404 |
found := (aSelectorString match:aLiteral)
|
|
405 |
]
|
|
406 |
]
|
|
407 |
]
|
|
408 |
].
|
|
409 |
found
|
|
410 |
].
|
|
411 |
browser := self browseMethodsIn:aCollectionOfClasses
|
|
412 |
where:[:class :method :s | searchBlock value:(method literals)]
|
|
413 |
title:title
|
|
414 |
] ifFalse:[
|
|
415 |
aSelectorString knownAsSymbol ifFalse:[
|
|
416 |
"
|
|
417 |
Transcript showCr:'none found.'.
|
|
418 |
"
|
|
419 |
self showNoneFound:title.
|
|
420 |
^ nil
|
|
421 |
].
|
|
422 |
|
|
423 |
sel := aSelectorString asSymbol.
|
|
424 |
browser := self browseMethodsIn:aCollectionOfClasses
|
|
425 |
where:[:class :method :s | method sends:sel]
|
|
426 |
title:title
|
|
427 |
].
|
|
428 |
|
|
429 |
browser notNil ifTrue:[
|
|
430 |
browser setSearchPattern:aSelectorString
|
|
431 |
].
|
|
432 |
^ browser
|
|
433 |
!
|
|
434 |
|
|
435 |
browseAllCallsOn:aSelectorString
|
|
436 |
"launch a browser for all senders of aSelector"
|
|
437 |
|
|
438 |
^ self browseAllCallsOn:aSelectorString
|
|
439 |
in:(Smalltalk allClasses)
|
|
440 |
title:('senders of ' , aSelectorString)
|
|
441 |
|
|
442 |
"
|
|
443 |
SystemBrowser browseAllCallsOn:#+
|
|
444 |
"
|
|
445 |
!
|
|
446 |
|
|
447 |
browseCallsOn:aSelectorString under:aClass
|
|
448 |
"launch a browser for all senders of aSelector in aClass and subclasses"
|
|
449 |
|
|
450 |
^ self browseAllCallsOn:aSelectorString
|
|
451 |
in:(aClass withAllSubclasses)
|
|
452 |
title:('senders of: ' ,
|
|
453 |
aSelectorString ,
|
|
454 |
' (in or below ' , aClass name , ')')
|
|
455 |
|
|
456 |
"
|
|
457 |
SystemBrowser browseAllCallsOn:#+ under:Number
|
|
458 |
"
|
|
459 |
!
|
|
460 |
|
|
461 |
browseForSymbol:aSymbol title:title warnIfNone:doWarn
|
|
462 |
"launch a browser for all methods referencing aSymbol"
|
|
463 |
|
|
464 |
|browser searchBlock sym|
|
|
465 |
|
|
466 |
(aSymbol includesMatchCharacters) ifTrue:[
|
|
467 |
"a matchString"
|
|
468 |
searchBlock := [:lits |
|
|
469 |
|found|
|
|
470 |
|
|
471 |
found := false.
|
|
472 |
lits notNil ifTrue:[
|
|
473 |
lits do:[:aLiteral |
|
|
474 |
found ifFalse:[
|
|
475 |
(aLiteral isMemberOf:Symbol) ifTrue:[
|
|
476 |
found := (aSymbol match:aLiteral)
|
|
477 |
]
|
|
478 |
]
|
|
479 |
]
|
|
480 |
].
|
|
481 |
found
|
|
482 |
].
|
|
483 |
] ifFalse:[
|
|
484 |
"
|
|
485 |
can do a faster search
|
|
486 |
"
|
|
487 |
aSymbol knownAsSymbol ifFalse:[
|
|
488 |
self showNoneFound:title.
|
|
489 |
^ nil
|
|
490 |
].
|
|
491 |
|
|
492 |
sym := aSymbol asSymbol.
|
|
493 |
searchBlock := [:lits |
|
|
494 |
|found|
|
|
495 |
|
|
496 |
found := false.
|
|
497 |
lits notNil ifTrue:[
|
|
498 |
lits do:[:aLiteral |
|
|
499 |
found ifFalse:[
|
|
500 |
(aLiteral isMemberOf:Symbol) ifTrue:[
|
|
501 |
found := (sym == aLiteral)
|
|
502 |
]
|
|
503 |
]
|
|
504 |
]
|
|
505 |
].
|
|
506 |
found
|
|
507 |
].
|
|
508 |
].
|
|
509 |
browser := self browseMethodsWhere:[:c :m :s | searchBlock value:(m literals)] title:title.
|
|
510 |
browser notNil ifTrue:[
|
|
511 |
browser setSearchPattern:aSymbol
|
|
512 |
].
|
|
513 |
^ browser
|
|
514 |
!
|
|
515 |
|
|
516 |
browseForSymbol:aSymbol
|
|
517 |
"launch a browser for all methods referencing aSymbol"
|
|
518 |
|
|
519 |
^ self browseForSymbol:aSymbol title:('users of ' , aSymbol) warnIfNone:true
|
|
520 |
!
|
|
521 |
|
|
522 |
browseReferendsOf:aGlobalName warnIfNone:doWarn
|
|
523 |
"launch a browser for all methods referencing a global
|
|
524 |
named aGlobalName.
|
|
525 |
"
|
|
526 |
|
|
527 |
^ self browseForSymbol:aGlobalName title:('users of: ' , aGlobalName) warnIfNone:doWarn
|
|
528 |
!
|
|
529 |
|
|
530 |
browseReferendsOf:aGlobalName
|
|
531 |
"launch a browser for all methods referencing a global
|
|
532 |
named aGlobalName.
|
|
533 |
"
|
|
534 |
|
|
535 |
^ self browseReferendsOf:aGlobalName warnIfNone:true
|
|
536 |
|
|
537 |
"
|
|
538 |
Browser browseReferendsOf:#Transcript
|
|
539 |
"
|
|
540 |
!
|
|
541 |
|
|
542 |
browseForString:aString in:aCollectionOfClasses
|
|
543 |
"launch a browser for all methods in aCollectionOfClasses containing a string"
|
|
544 |
|
|
545 |
|browser searchBlock title|
|
|
546 |
|
|
547 |
title := 'methods containing: ' , aString displayString.
|
|
548 |
|
|
549 |
(aString includesMatchCharacters) ifTrue:[
|
|
550 |
"a matchString"
|
|
551 |
searchBlock := [:lits |
|
|
552 |
|found|
|
|
553 |
|
|
554 |
found := false.
|
|
555 |
lits notNil ifTrue:[
|
|
556 |
lits do:[:aLiteral |
|
|
557 |
found ifFalse:[
|
|
558 |
(aLiteral isMemberOf:String) ifTrue:[
|
|
559 |
found := (aString match:aLiteral)
|
|
560 |
]
|
|
561 |
]
|
|
562 |
]
|
|
563 |
].
|
|
564 |
found
|
|
565 |
].
|
|
566 |
] ifFalse:[
|
|
567 |
searchBlock := [:lits |
|
|
568 |
|found|
|
|
569 |
|
|
570 |
found := false.
|
|
571 |
lits notNil ifTrue:[
|
|
572 |
lits do:[:aLiteral |
|
|
573 |
found ifFalse:[
|
|
574 |
(aLiteral isMemberOf:String) ifTrue:[
|
|
575 |
found := (aLiteral = aString)
|
|
576 |
]
|
|
577 |
]
|
|
578 |
]
|
|
579 |
].
|
|
580 |
found
|
|
581 |
].
|
|
582 |
].
|
|
583 |
browser := self browseMethodsIn:aCollectionOfClasses
|
|
584 |
where:[:c :m :s | searchBlock value:(m literals)]
|
|
585 |
title:title.
|
|
586 |
|
|
587 |
browser notNil ifTrue:[
|
|
588 |
browser setSearchPattern:aString
|
|
589 |
].
|
|
590 |
^ browser
|
|
591 |
|
|
592 |
"SystemBrowser browseForString:'*all*'"
|
|
593 |
"SystemBrowser browseForString:'*should*'"
|
|
594 |
"SystemBrowser browseForString:'*[eE]rror*'"
|
|
595 |
!
|
|
596 |
|
|
597 |
browseForString:aString
|
|
598 |
"launch a browser for all methods containing a string"
|
|
599 |
|
|
600 |
^ self browseForString:aString in:(Smalltalk allClasses)
|
|
601 |
!
|
|
602 |
|
|
603 |
aproposSearch:aString in:aCollectionOfClasses
|
|
604 |
"browse all methods, which have aString in their selector or
|
|
605 |
in the methods comment.
|
|
606 |
This is relatively slow, since all source must be processed."
|
|
607 |
|
|
608 |
|matchString list|
|
|
609 |
|
|
610 |
matchString := '*' , aString , '*'.
|
|
611 |
|
|
612 |
list := OrderedCollection new.
|
|
613 |
|
|
614 |
^ self browseMethodsIn:aCollectionOfClasses
|
|
615 |
where:[:class :method :sel |
|
|
616 |
(matchString match:sel) ifTrue:[
|
|
617 |
list add:(class name , '>>' , sel)
|
|
618 |
] ifFalse:[
|
|
619 |
(matchString match:(method comment)) ifTrue:[
|
|
620 |
list add:(class name , '>>' , sel)
|
|
621 |
]
|
|
622 |
]
|
|
623 |
]
|
|
624 |
title:('apropos: ' , aString)
|
|
625 |
|
|
626 |
"SystemBrowser aproposSearch:'append'"
|
|
627 |
"SystemBrowser aproposSearch:'add'"
|
|
628 |
"SystemBrowser aproposSearch:'sort'"
|
|
629 |
!
|
|
630 |
|
|
631 |
aproposSearch:aString
|
|
632 |
"browse all methods, which have aString in their selector or
|
|
633 |
in the methods comment.
|
|
634 |
This is relatively slow, since all source must be processed."
|
|
635 |
|
|
636 |
^ self aproposSearch:aString in:(Smalltalk allClasses)
|
|
637 |
!
|
|
638 |
|
|
639 |
browseInstRefsTo:aString in:aCollectionOfClasses modificationsOnly:modsOnly title:title
|
|
640 |
"launch a browser for all methods in aClass where the instVar named
|
|
641 |
aString is referenced; if modsOnly is true, browse only methods where the
|
|
642 |
instvar is modified"
|
|
643 |
|
|
644 |
|parser result instvars searchBlock browser|
|
|
645 |
|
|
646 |
searchBlock := [:c :m :s |
|
|
647 |
result := false.
|
|
648 |
parser := Parser parseMethod:(m source) in:c.
|
|
649 |
parser notNil ifTrue:[
|
|
650 |
modsOnly ifTrue:[
|
|
651 |
instvars := parser modifiedInstVars
|
|
652 |
] ifFalse:[
|
|
653 |
instvars := parser usedInstVars
|
|
654 |
].
|
|
655 |
instvars notNil ifTrue:[
|
|
656 |
aString includesMatchCharacters ifTrue:[
|
|
657 |
instvars do:[:iv |
|
|
658 |
(aString match:iv) ifTrue:[result := true]
|
|
659 |
]
|
|
660 |
] ifFalse:[
|
|
661 |
result := instvars includes:aString
|
|
662 |
]
|
|
663 |
]
|
|
664 |
].
|
|
665 |
result
|
|
666 |
].
|
|
667 |
browser := self browseInstMethodsIn:aCollectionOfClasses where:searchBlock title:title.
|
|
668 |
|
|
669 |
browser notNil ifTrue:[
|
|
670 |
browser setSearchPattern:aString
|
|
671 |
].
|
|
672 |
^ browser
|
|
673 |
!
|
|
674 |
|
|
675 |
browseInstRefsTo:aString in:aCollectionOfClasses modificationsOnly:modsOnly
|
|
676 |
"launch a browser for all methods in aClass where the instVar named
|
|
677 |
aString is referenced; if modsOnly is true, browse only methods where the
|
|
678 |
instvar is modified"
|
|
679 |
|
|
680 |
|title|
|
|
681 |
|
|
682 |
modsOnly ifTrue:[
|
|
683 |
title := 'modifications of '
|
|
684 |
] ifFalse:[
|
|
685 |
title := 'references to '
|
|
686 |
].
|
|
687 |
^ self browseInstRefsTo:aString
|
|
688 |
in:aCollectionOfClasses
|
|
689 |
modificationsOnly:modsOnly
|
|
690 |
title:(title , aString)
|
|
691 |
!
|
|
692 |
|
|
693 |
browseInstRefsTo:aString under:aClass modificationsOnly:modsOnly
|
|
694 |
"launch a browser for all methods in aClass and subclasses
|
|
695 |
where the instVar named aString is referenced;
|
|
696 |
if modsOnly is true, browse only methods where the instvar is modified"
|
|
697 |
|
|
698 |
^ self browseInstRefsTo:aString in:(aClass withAllSubclasses) modificationsOnly:modsOnly
|
|
699 |
!
|
|
700 |
|
|
701 |
browseClassRefsTo:aString in:aCollectionOfClasses modificationsOnly:modsOnly title:title
|
|
702 |
"launch a browser for all methods in aCollectionOfClasses,
|
|
703 |
where the classVar named aString is referenced;
|
|
704 |
if modsOnly is true, browse only methods where the classvar is modified"
|
|
705 |
|
|
706 |
|parser result classvars searchBlock browser|
|
|
707 |
|
|
708 |
searchBlock := [:c :m :s |
|
|
709 |
result := false.
|
|
710 |
parser := Parser parseMethod:(m source) in:c.
|
|
711 |
parser notNil ifTrue:[
|
|
712 |
modsOnly ifTrue:[
|
|
713 |
classvars := parser modifiedClassVars
|
|
714 |
] ifFalse:[
|
|
715 |
classvars := parser usedClassVars
|
|
716 |
].
|
|
717 |
classvars notNil ifTrue:[
|
|
718 |
aString includesMatchCharacters ifTrue:[
|
|
719 |
classvars do:[:cv |
|
|
720 |
(aString match:cv) ifTrue:[result := true]
|
|
721 |
]
|
|
722 |
] ifFalse:[
|
|
723 |
result := classvars includes:aString
|
|
724 |
]
|
|
725 |
]
|
|
726 |
].
|
|
727 |
result
|
|
728 |
].
|
|
729 |
browser := self browseMethodsIn:aCollectionOfClasses where:searchBlock title:title.
|
|
730 |
|
|
731 |
browser notNil ifTrue:[
|
|
732 |
browser setSearchPattern:aString
|
|
733 |
].
|
|
734 |
^ browser
|
|
735 |
!
|
|
736 |
|
|
737 |
browseClassRefsTo:aString in:aCollectionOfClasses modificationsOnly:modsOnly
|
|
738 |
"launch a browser for all methods in aClass where the classVar named
|
|
739 |
aString is referenced; if modsOnly is true, browse only methods where the
|
|
740 |
classvar is modified"
|
|
741 |
|
|
742 |
|title|
|
|
743 |
|
|
744 |
modsOnly ifTrue:[
|
|
745 |
title := 'modifications of '
|
|
746 |
] ifFalse:[
|
|
747 |
title := 'references to '
|
|
748 |
].
|
|
749 |
^ self browseClassRefsTo:aString in:aCollectionOfClasses modificationsOnly:modsOnly title:(title , aString)
|
|
750 |
!
|
|
751 |
|
|
752 |
browseClassRefsTo:aString under:aClass modificationsOnly:modsOnly
|
|
753 |
"launch a browser for all methods in aClass and subclasses
|
|
754 |
where the classVar named aString is referenced;
|
|
755 |
if modsOnly is true, browse only methods where the classvar is modified"
|
|
756 |
|
|
757 |
^ self browseClassRefsTo:aString in:(aClass withAllSubclasses) modificationsOnly:modsOnly
|
|
758 |
! !
|
|
759 |
|
|
760 |
!SystemBrowser class methodsFor:'private'!
|
|
761 |
|
|
762 |
showNoneFound:what
|
|
763 |
"/ DialogView warn:(self classResources string:('no ' , what , ' found')).
|
|
764 |
self showNoneFound
|
|
765 |
!
|
|
766 |
|
|
767 |
showNoneFound
|
|
768 |
DialogView warn:(self classResources string:'None found').
|
|
769 |
!
|
|
770 |
|
|
771 |
newWithLabel:aString setupBlock:aBlock on:aWorkstation
|
|
772 |
"common helper method for all creation methods"
|
|
773 |
|
|
774 |
|newBrowser|
|
|
775 |
|
|
776 |
newBrowser := self on:aWorkstation.
|
|
777 |
newBrowser label:aString.
|
|
778 |
aBlock value:newBrowser.
|
|
779 |
|
|
780 |
newBrowser open.
|
|
781 |
^ newBrowser
|
|
782 |
!
|
|
783 |
|
|
784 |
newWithLabel:aString setupBlock:aBlock
|
|
785 |
"common helper method for all creation methods"
|
|
786 |
|
|
787 |
^ self newWithLabel:aString setupBlock:aBlock on:Display
|
|
788 |
! !
|
|
789 |
|
|
790 |
!SystemBrowser methodsFor:'initialize / release'!
|
|
791 |
|
|
792 |
initialize
|
|
793 |
super initialize.
|
|
794 |
|
|
795 |
self icon:(Form fromFile:(resources at:'ICON_FILE' default:'SBrowser.xbm')
|
|
796 |
resolution:100).
|
|
797 |
|
|
798 |
showInstance := true.
|
|
799 |
fullClass := false.
|
|
800 |
|
|
801 |
"inform me, when Smalltalk changes"
|
|
802 |
Smalltalk addDependent:self
|
|
803 |
!
|
|
804 |
|
|
805 |
destroy
|
|
806 |
"relese dependant - destroy popups"
|
|
807 |
|
|
808 |
Smalltalk removeDependent:self.
|
|
809 |
currentClass notNil ifTrue:[
|
|
810 |
currentClass removeDependent:self.
|
|
811 |
currentClass := nil
|
|
812 |
].
|
|
813 |
enterBox notNil ifTrue:[enterBox destroy. enterBox := nil].
|
|
814 |
questBox notNil ifTrue:[questBox destroy. questBox := nil].
|
|
815 |
selectBox notNil ifTrue:[selectBox destroy. selectBox := nil].
|
|
816 |
super destroy
|
|
817 |
!
|
|
818 |
|
|
819 |
terminate
|
|
820 |
(self checkSelectionChangeAllowed) ifTrue:[
|
|
821 |
super terminate
|
|
822 |
]
|
|
823 |
!
|
|
824 |
|
|
825 |
createTogglesIn:aFrame
|
|
826 |
"create and setup the class/instance toggles"
|
|
827 |
|
|
828 |
|bw halfSpacing|
|
|
829 |
|
|
830 |
instanceToggle := Toggle label:(resources at:'instance') in:aFrame.
|
|
831 |
bw := instanceToggle borderWidth.
|
|
832 |
halfSpacing := [
|
|
833 |
(self is3D and:[style ~~ #st80]) ifTrue:[
|
|
834 |
ViewSpacing // 2
|
|
835 |
] ifFalse:[
|
|
836 |
0
|
|
837 |
]
|
|
838 |
].
|
|
839 |
instanceToggle extent:[(aFrame width // 2 - halfSpacing value) @ instanceToggle height].
|
|
840 |
instanceToggle origin:[bw negated + halfSpacing value
|
|
841 |
@
|
|
842 |
(aFrame height - instanceToggle heightIncludingBorder + bw)].
|
|
843 |
|
|
844 |
instanceToggle turnOn.
|
|
845 |
instanceToggle pressAction:[self instanceProtocol].
|
|
846 |
instanceToggle releaseAction:[self classProtocol].
|
|
847 |
|
|
848 |
classToggle := Toggle label:(resources at:'class') in:aFrame.
|
|
849 |
classToggle extent:[(aFrame width - (aFrame width // 2) - halfSpacing value) @ classToggle height].
|
|
850 |
classToggle origin:[(aFrame width // 2 + halfSpacing value)
|
|
851 |
@
|
|
852 |
(aFrame height - classToggle heightIncludingBorder + bw)].
|
|
853 |
|
|
854 |
classToggle turnOff.
|
|
855 |
classToggle pressAction:[self classProtocol].
|
|
856 |
classToggle releaseAction:[self instanceProtocol]
|
|
857 |
!
|
|
858 |
|
|
859 |
createClassListViewIn:frame
|
|
860 |
"setup the classlist subview, with its toggles"
|
|
861 |
|
|
862 |
|v|
|
|
863 |
|
|
864 |
self createTogglesIn:frame.
|
|
865 |
|
|
866 |
v := ScrollableView for:SelectionInListView in:frame.
|
|
867 |
v origin:(0.0 @ 0.0)
|
|
868 |
extent:[frame width
|
|
869 |
@
|
|
870 |
(frame height
|
|
871 |
- instanceToggle height
|
|
872 |
- instanceToggle borderWidth)].
|
|
873 |
|
|
874 |
classListView := v scrolledView
|
|
875 |
!
|
|
876 |
|
|
877 |
createCodeViewIn:aView
|
|
878 |
"setup the code view"
|
|
879 |
|v|
|
|
880 |
|
|
881 |
v := HVScrollableView for:CodeView miniScrollerH:true miniScrollerV:false in:aView.
|
|
882 |
v origin:(0.0 @ 0.25) corner:(1.0 @ 1.0).
|
|
883 |
codeView := v scrolledView
|
|
884 |
!
|
|
885 |
|
|
886 |
setupActions
|
|
887 |
"/ |v|
|
|
888 |
|
|
889 |
"/ v := classCategoryListView.
|
|
890 |
"/ v notNil ifTrue:[
|
|
891 |
"/ v action:[:lineNr | self classCategorySelection:lineNr].
|
|
892 |
"/ v selectConditionBlock:[self checkSelectionChangeAllowed].
|
|
893 |
"/ v ignoreReselect:false.
|
|
894 |
"/ ].
|
|
895 |
"/ v := classListView.
|
|
896 |
"/ v notNil ifTrue:[
|
|
897 |
"/ v action:[:lineNr | self classSelection:lineNr].
|
|
898 |
"/ v selectConditionBlock:[self checkSelectionChangeAllowed].
|
|
899 |
"/ v ignoreReselect:false.
|
|
900 |
"/ ].
|
|
901 |
"/ v := methodCategoryListView.
|
|
902 |
"/ v notNil ifTrue:[
|
|
903 |
"/ v action:[:lineNr | self methodCategorySelection:lineNr].
|
|
904 |
"/ v selectConditionBlock:[self checkSelectionChangeAllowed].
|
|
905 |
"/ v ignoreReselect:false.
|
|
906 |
"/ ].
|
|
907 |
"/ v := methodListView.
|
|
908 |
"/ v notNil ifTrue:[
|
|
909 |
"/ v action:[:lineNr | self methodSelection:lineNr].
|
|
910 |
"/ v selectConditionBlock:[self checkSelectionChangeAllowed].
|
|
911 |
"/ v ignoreReselect:false.
|
|
912 |
"/ ].
|
|
913 |
"/ v := classMethodListView.
|
|
914 |
"/ v notNil ifTrue:[
|
|
915 |
"/ v action:[:lineNr | self listSelection:lineNr].
|
|
916 |
"/ v selectConditionBlock:[self checkSelectionChangeAllowed].
|
|
917 |
"/ v ignoreReselect:false.
|
|
918 |
"/ ]
|
|
919 |
!
|
|
920 |
|
|
921 |
setupForAll
|
|
922 |
"create subviews for a full browser"
|
|
923 |
|
|
924 |
|vpanel hpanel frame v|
|
|
925 |
|
|
926 |
vpanel := VariableVerticalPanel origin:(0.0 @ 0.0) corner:(1.0 @ 1.0)
|
|
927 |
in:self.
|
|
928 |
hpanel := View origin:(0.0 @ 0.0) corner:(1.0 @ 0.25) in:vpanel.
|
|
929 |
|
|
930 |
v := HVScrollableView for:SelectionInListView
|
|
931 |
miniScrollerH:true miniScrollerV:false
|
|
932 |
in:hpanel.
|
|
933 |
v origin:(0.0 @ 0.0) corner:(0.25 @ 1.0).
|
|
934 |
classCategoryListView := v scrolledView.
|
|
935 |
"/ classCategoryListView contents:(self listOfAllClassCategories).
|
|
936 |
|
|
937 |
frame := View origin:(0.25 @ 0.0) corner:(0.5 @ 1.0) in:hpanel.
|
|
938 |
self createClassListViewIn:frame.
|
|
939 |
|
|
940 |
v := HVScrollableView for:SelectionInListView miniScrollerH:true miniScrollerV:false in:hpanel.
|
|
941 |
v origin:(0.5 @ 0.0) corner:(0.75 @ 1.0).
|
|
942 |
methodCategoryListView := v scrolledView.
|
|
943 |
|
|
944 |
v := HVScrollableView for:SelectionInListView miniScrollerH:true miniScrollerV:false in:hpanel.
|
|
945 |
v origin:(0.75 @ 0.0) corner:(1.0 @ 1.0).
|
|
946 |
methodListView := v scrolledView.
|
|
947 |
|
|
948 |
"/ self setupActions.
|
|
949 |
self createCodeViewIn:vpanel
|
|
950 |
!
|
|
951 |
|
|
952 |
setupForFullClass
|
|
953 |
"setup subviews to browse a class as full text"
|
|
954 |
|
|
955 |
|vpanel hpanel v|
|
|
956 |
|
|
957 |
vpanel := VariableVerticalPanel origin:(0.0 @ 0.0)
|
|
958 |
corner:(1.0 @ 1.0)
|
|
959 |
in:self.
|
|
960 |
|
|
961 |
hpanel := View origin:(0.0 @ 0.0) corner:(1.0 @ 0.25) in:vpanel.
|
|
962 |
|
|
963 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
964 |
v origin:(0.0 @ 0.0) corner:(0.5 @ 1.0).
|
|
965 |
classCategoryListView := v scrolledView.
|
|
966 |
classCategoryListView contents:(self listOfAllClassCategories).
|
|
967 |
|
|
968 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
969 |
v origin:(0.5 @ 0.0) corner:(1.0 @ 1.0).
|
|
970 |
classListView := v scrolledView.
|
|
971 |
|
|
972 |
"/ self setupActions.
|
|
973 |
self createCodeViewIn:vpanel.
|
|
974 |
|
|
975 |
fullClass := true.
|
|
976 |
self updateCodeView
|
|
977 |
!
|
|
978 |
|
|
979 |
setupForClassCategory:aClassCategory
|
|
980 |
"setup subviews to browse a class category"
|
|
981 |
|
|
982 |
|vpanel hpanel frame v|
|
|
983 |
|
|
984 |
vpanel := VariableVerticalPanel origin:(0.0 @ 0.0)
|
|
985 |
corner:(1.0 @ 1.0)
|
|
986 |
in:self.
|
|
987 |
|
|
988 |
hpanel := View origin:(0.0 @ 0.0) corner:(1.0 @ 0.25) in:vpanel.
|
|
989 |
frame := View origin:(0.0 @ 0.0) corner:(0.33 @ 1.0) in:hpanel.
|
|
990 |
|
|
991 |
self createClassListViewIn:frame.
|
|
992 |
|
|
993 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
994 |
v origin:(0.33 @ 0.0) corner:(0.66 @ 1.0).
|
|
995 |
methodCategoryListView := v scrolledView.
|
|
996 |
|
|
997 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
998 |
v origin:(0.66 @ 0.0) corner:(1.0 @ 1.0).
|
|
999 |
methodListView := v scrolledView.
|
|
1000 |
|
|
1001 |
"/ self setupActions.
|
|
1002 |
self createCodeViewIn:vpanel.
|
|
1003 |
|
|
1004 |
currentClassCategory := aClassCategory.
|
|
1005 |
self updateClassList.
|
|
1006 |
self updateMethodCategoryList.
|
|
1007 |
self updateMethodList.
|
|
1008 |
self updateCodeView
|
|
1009 |
!
|
|
1010 |
|
|
1011 |
setupForClassList:aList
|
|
1012 |
"setup subviews to browse classes from a list"
|
|
1013 |
|
|
1014 |
|vpanel hpanel frame l v|
|
|
1015 |
|
|
1016 |
vpanel := VariableVerticalPanel
|
|
1017 |
origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:self.
|
|
1018 |
|
|
1019 |
hpanel := View origin:(0.0 @ 0.0) corner:(1.0 @ 0.25) in:vpanel.
|
|
1020 |
frame := View origin:(0.0 @ 0.0) corner:(0.33 @ 1.0) in:hpanel.
|
|
1021 |
|
|
1022 |
self createClassListViewIn:frame.
|
|
1023 |
|
|
1024 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
1025 |
v origin:(0.33 @ 0.0) corner:(0.66 @ 1.0).
|
|
1026 |
methodCategoryListView := v scrolledView.
|
|
1027 |
|
|
1028 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
1029 |
v origin:(0.66 @ 0.0) corner:(1.0 @ 1.0).
|
|
1030 |
methodListView := v scrolledView.
|
|
1031 |
|
|
1032 |
"/ self setupActions.
|
|
1033 |
self createCodeViewIn:vpanel.
|
|
1034 |
|
|
1035 |
l := aList collect:[:entry | entry name].
|
|
1036 |
classListView list:(l sort).
|
|
1037 |
|
|
1038 |
self updateMethodCategoryList.
|
|
1039 |
self updateMethodList.
|
|
1040 |
self updateCodeView
|
|
1041 |
!
|
|
1042 |
|
|
1043 |
setupForClassHierarchy:aClass
|
|
1044 |
"setup subviews to browse a class hierarchy"
|
|
1045 |
|
|
1046 |
|vpanel hpanel frame v|
|
|
1047 |
|
|
1048 |
vpanel := VariableVerticalPanel origin:(0.0 @ 0.0)
|
|
1049 |
corner:(1.0 @ 1.0)
|
|
1050 |
in:self.
|
|
1051 |
|
|
1052 |
hpanel := View origin:(0.0 @ 0.0) corner:(1.0 @ 0.25) in:vpanel.
|
|
1053 |
frame := View origin:(0.0 @ 0.0) corner:(0.33 @ 1.0) in:hpanel.
|
|
1054 |
|
|
1055 |
self createClassListViewIn:frame.
|
|
1056 |
|
|
1057 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
1058 |
v origin:(0.33 @ 0.0) corner:(0.66 @ 1.0).
|
|
1059 |
methodCategoryListView := v scrolledView.
|
|
1060 |
|
|
1061 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
1062 |
v origin:(0.66 @ 0.0) corner:(1.0 @ 1.0).
|
|
1063 |
methodListView := v scrolledView.
|
|
1064 |
|
|
1065 |
"/ self setupActions.
|
|
1066 |
self createCodeViewIn:vpanel.
|
|
1067 |
|
|
1068 |
currentClassHierarchy := aClass.
|
|
1069 |
self updateClassList.
|
|
1070 |
self updateMethodCategoryList.
|
|
1071 |
self updateMethodList.
|
|
1072 |
self updateCodeView
|
|
1073 |
!
|
|
1074 |
|
|
1075 |
setupForClass:aClass
|
|
1076 |
"create subviews for browsing a single class"
|
|
1077 |
|
|
1078 |
|vpanel hpanel frame v|
|
|
1079 |
|
|
1080 |
vpanel := VariableVerticalPanel origin:(0.0 @ 0.0)
|
|
1081 |
corner:(1.0 @ 1.0)
|
|
1082 |
in:self.
|
|
1083 |
|
|
1084 |
hpanel := View origin:(0.0 @ 0.0) corner:(1.0 @ 0.25) in:vpanel.
|
|
1085 |
frame := View origin:(0.0 @ 0.0) corner:(0.5 @ 1.0)in:hpanel.
|
|
1086 |
|
|
1087 |
self createTogglesIn:frame.
|
|
1088 |
|
|
1089 |
v := ScrollableView for:SelectionInListView in:frame.
|
|
1090 |
v origin:(0.0 @ 0.0)
|
|
1091 |
extent:[frame width
|
|
1092 |
@
|
|
1093 |
(frame height - instanceToggle heightIncludingBorder)].
|
|
1094 |
methodCategoryListView := v scrolledView.
|
|
1095 |
|
|
1096 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
1097 |
v origin:(0.5 @ 0.0) corner:(1.0 @ 1.0).
|
|
1098 |
methodListView := v scrolledView.
|
|
1099 |
|
|
1100 |
"/ self setupActions.
|
|
1101 |
self createCodeViewIn:vpanel.
|
|
1102 |
|
|
1103 |
self switchToClass:aClass.
|
|
1104 |
actualClass := aClass.
|
|
1105 |
self updateMethodCategoryList.
|
|
1106 |
self updateMethodList.
|
|
1107 |
self updateCodeView
|
|
1108 |
!
|
|
1109 |
|
|
1110 |
setupForClass:aClass methodCategory:aMethodCategory
|
|
1111 |
"setup subviews to browse a method category"
|
|
1112 |
|
|
1113 |
|vpanel v|
|
|
1114 |
|
|
1115 |
vpanel := VariableVerticalPanel
|
|
1116 |
origin:(0.0 @ 0.0) corner:(1.0 @ 1.0)
|
|
1117 |
in:self.
|
|
1118 |
|
|
1119 |
v := ScrollableView for:SelectionInListView in:vpanel.
|
|
1120 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 0.25).
|
|
1121 |
methodListView := v scrolledView.
|
|
1122 |
|
|
1123 |
"/ self setupActions.
|
|
1124 |
self createCodeViewIn:vpanel.
|
|
1125 |
|
|
1126 |
currentClassCategory := aClass category.
|
|
1127 |
self switchToClass:aClass.
|
|
1128 |
actualClass := aClass.
|
|
1129 |
currentMethodCategory := aMethodCategory.
|
|
1130 |
self updateMethodList.
|
|
1131 |
self updateCodeView
|
|
1132 |
!
|
|
1133 |
|
|
1134 |
setupForClass:aClass selector:selector
|
|
1135 |
"setup subviews to browse a single method"
|
|
1136 |
|
|
1137 |
|v|
|
|
1138 |
|
|
1139 |
v := ScrollableView for:CodeView in:self.
|
|
1140 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
1141 |
codeView := v scrolledView.
|
|
1142 |
|
|
1143 |
currentClassCategory := aClass category.
|
|
1144 |
self switchToClass:aClass.
|
|
1145 |
actualClass := aClass.
|
|
1146 |
currentMethod := currentClass compiledMethodAt:selector.
|
|
1147 |
currentMethodCategory := currentMethod category.
|
|
1148 |
self updateCodeView
|
|
1149 |
!
|
|
1150 |
|
|
1151 |
setupForList:aList
|
|
1152 |
"setup subviews to browse methods from a list"
|
|
1153 |
|
|
1154 |
|vpanel v|
|
|
1155 |
|
|
1156 |
vpanel := VariableVerticalPanel
|
|
1157 |
origin:(0.0 @ 0.0)
|
|
1158 |
corner:(1.0 @ 1.0)
|
|
1159 |
in:self.
|
|
1160 |
|
|
1161 |
v := ScrollableView for:SelectionInListView in:vpanel.
|
|
1162 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 0.25).
|
|
1163 |
classMethodListView := v scrolledView.
|
|
1164 |
classMethodListView contents:aList.
|
|
1165 |
|
|
1166 |
"/ self setupActions.
|
|
1167 |
self createCodeViewIn:vpanel.
|
|
1168 |
|
|
1169 |
self updateCodeView
|
|
1170 |
! !
|
|
1171 |
|
|
1172 |
!SystemBrowser methodsFor:'realization'!
|
|
1173 |
|
|
1174 |
realize
|
|
1175 |
|v|
|
|
1176 |
|
|
1177 |
super realize.
|
|
1178 |
|
|
1179 |
v := classCategoryListView.
|
|
1180 |
v notNil ifTrue:[
|
|
1181 |
v action:[:lineNr | self classCategorySelection:lineNr].
|
|
1182 |
v selectConditionBlock:[self checkSelectionChangeAllowed].
|
|
1183 |
v ignoreReselect:false.
|
|
1184 |
v contents:(self listOfAllClassCategories).
|
|
1185 |
self initializeClassCategoryMenu
|
|
1186 |
].
|
|
1187 |
|
|
1188 |
v := classListView.
|
|
1189 |
v notNil ifTrue:[
|
|
1190 |
v action:[:lineNr | self classSelection:lineNr].
|
|
1191 |
v selectConditionBlock:[self checkSelectionChangeAllowed].
|
|
1192 |
v ignoreReselect:false.
|
|
1193 |
self initializeClassMenu
|
|
1194 |
].
|
|
1195 |
|
|
1196 |
v := methodCategoryListView.
|
|
1197 |
v notNil ifTrue:[
|
|
1198 |
v action:[:lineNr | self methodCategorySelection:lineNr].
|
|
1199 |
v selectConditionBlock:[self checkSelectionChangeAllowed].
|
|
1200 |
v ignoreReselect:false.
|
|
1201 |
self initializeMethodCategoryMenu
|
|
1202 |
].
|
|
1203 |
|
|
1204 |
v := methodListView.
|
|
1205 |
v notNil ifTrue:[
|
|
1206 |
v action:[:lineNr | self methodSelection:lineNr].
|
|
1207 |
v selectConditionBlock:[self checkSelectionChangeAllowed].
|
|
1208 |
v ignoreReselect:false.
|
|
1209 |
self initializeMethodMenu
|
|
1210 |
].
|
|
1211 |
|
|
1212 |
v := classMethodListView.
|
|
1213 |
v notNil ifTrue:[
|
|
1214 |
v action:[:lineNr | self listSelection:lineNr].
|
|
1215 |
v selectConditionBlock:[self checkSelectionChangeAllowed].
|
|
1216 |
v ignoreReselect:false.
|
|
1217 |
self initializeClassMethodMenu
|
|
1218 |
]
|
|
1219 |
! !
|
|
1220 |
|
|
1221 |
!SystemBrowser methodsFor:'private'!
|
|
1222 |
|
|
1223 |
checkSelectionChangeAllowed
|
|
1224 |
"return true, if selection change is ok;
|
|
1225 |
its not ok, if code has been changed.
|
|
1226 |
in this case, return the result of a user query"
|
|
1227 |
|
|
1228 |
|box|
|
|
1229 |
|
|
1230 |
codeView modified ifFalse:[
|
|
1231 |
^ true
|
|
1232 |
].
|
|
1233 |
box := questBox.
|
|
1234 |
box isNil ifTrue:[
|
|
1235 |
box := questBox := YesNoBox title:''
|
|
1236 |
].
|
|
1237 |
|
|
1238 |
box title:(resources at:'contents in codeview has not been accepted.\\Modifications will be lost when continuing.') withCRs.
|
|
1239 |
box okText:(resources at:'continue').
|
|
1240 |
box noText:(resources at:'abort').
|
|
1241 |
box yesAction:[^ true] noAction:[^ false].
|
|
1242 |
box showAtPointer
|
|
1243 |
!
|
|
1244 |
|
|
1245 |
switchToClass:newClass
|
|
1246 |
currentClass notNil ifTrue:[
|
|
1247 |
currentClass removeDependent:self
|
|
1248 |
].
|
|
1249 |
currentClass := newClass.
|
|
1250 |
currentClass notNil ifTrue:[
|
|
1251 |
currentClass addDependent:self
|
|
1252 |
]
|
|
1253 |
!
|
|
1254 |
|
|
1255 |
showExplanation:someText
|
|
1256 |
"show explanation from Parser"
|
|
1257 |
|
|
1258 |
self notify:someText
|
|
1259 |
!
|
|
1260 |
|
|
1261 |
setSearchPattern:aString
|
|
1262 |
codeView setSearchPattern:aString
|
|
1263 |
!
|
|
1264 |
|
|
1265 |
selectorToSearchFor
|
|
1266 |
"look in codeView and methodListView for a search-string when searching for selectors"
|
|
1267 |
|
|
1268 |
|sel t|
|
|
1269 |
|
|
1270 |
sel := codeView selection.
|
|
1271 |
sel notNil ifTrue:[
|
|
1272 |
sel := sel asString.
|
|
1273 |
t := Parser selectorInExpression:sel.
|
|
1274 |
t notNil ifTrue:[
|
|
1275 |
sel := t
|
|
1276 |
].
|
|
1277 |
sel := sel withoutSpaces
|
|
1278 |
] ifFalse:[
|
|
1279 |
methodListView notNil ifTrue:[
|
|
1280 |
sel := methodListView selectionValue
|
|
1281 |
] ifFalse:[
|
|
1282 |
classMethodListView notNil ifTrue:[
|
|
1283 |
sel := classMethodListView selectionValue.
|
|
1284 |
sel notNil ifTrue:[
|
|
1285 |
sel := self selectorFromClassMethodString:sel
|
|
1286 |
]
|
|
1287 |
]
|
|
1288 |
].
|
|
1289 |
sel notNil ifTrue:[
|
|
1290 |
sel := sel withoutSpaces
|
|
1291 |
] ifFalse:[
|
|
1292 |
sel := ''
|
|
1293 |
]
|
|
1294 |
].
|
|
1295 |
^ sel
|
|
1296 |
!
|
|
1297 |
|
|
1298 |
stringToSearchFor
|
|
1299 |
"look in codeView and methodListView for a search-string when searching for classes/names"
|
|
1300 |
|
|
1301 |
|sel|
|
|
1302 |
|
|
1303 |
sel := codeView selection.
|
|
1304 |
sel notNil ifTrue:[
|
|
1305 |
sel := sel asString withoutSpaces
|
|
1306 |
] ifFalse:[
|
|
1307 |
sel isNil ifTrue:[
|
|
1308 |
currentClass notNil ifTrue:[
|
|
1309 |
sel := currentClass name
|
|
1310 |
]
|
|
1311 |
].
|
|
1312 |
sel notNil ifTrue:[
|
|
1313 |
sel := sel withoutSpaces
|
|
1314 |
] ifFalse:[
|
|
1315 |
sel := ''
|
|
1316 |
]
|
|
1317 |
].
|
|
1318 |
^ sel
|
|
1319 |
!
|
|
1320 |
|
|
1321 |
findClassOfVariable:aVariableName accessWith:aSelector
|
|
1322 |
"this method returns the class, in which a variable
|
|
1323 |
is defined;
|
|
1324 |
needs either #instVarNames or #classVarNames as aSelector."
|
|
1325 |
|
|
1326 |
|cls homeClass|
|
|
1327 |
|
|
1328 |
"
|
|
1329 |
first, find the class, where the variable is declared
|
|
1330 |
"
|
|
1331 |
cls := currentClass.
|
|
1332 |
[cls notNil] whileTrue:[
|
|
1333 |
((cls perform:aSelector) includes:aVariableName) ifTrue:[
|
|
1334 |
homeClass := cls.
|
|
1335 |
cls := nil.
|
|
1336 |
] ifFalse:[
|
|
1337 |
cls := cls superclass
|
|
1338 |
]
|
|
1339 |
].
|
|
1340 |
homeClass isNil ifTrue:[
|
|
1341 |
"nope, must be one below ... (could optimize a bit, by searching down
|
|
1342 |
for the declaring class ...
|
|
1343 |
"
|
|
1344 |
homeClass := currentClass
|
|
1345 |
] ifFalse:[
|
|
1346 |
Transcript showCr:'starting search in ' , homeClass name.
|
|
1347 |
].
|
|
1348 |
^ homeClass
|
|
1349 |
!
|
|
1350 |
|
|
1351 |
listBoxTitle:title okText:okText list:aList
|
|
1352 |
"convenient method: setup a listBox"
|
|
1353 |
|
|
1354 |
|box|
|
|
1355 |
|
|
1356 |
box := selectBox.
|
|
1357 |
box isNil ifTrue:[
|
|
1358 |
box := selectBox := ListSelectionBox
|
|
1359 |
title:''
|
|
1360 |
okText:(resources string:'ok')
|
|
1361 |
abortText:(resources string:'abort')
|
|
1362 |
action:[:aString | ]
|
|
1363 |
].
|
|
1364 |
box title:(resources string:title).
|
|
1365 |
box list:aList.
|
|
1366 |
!
|
|
1367 |
|
|
1368 |
enterBoxTitle:title okText:okText
|
|
1369 |
"convenient method: setup enterBox"
|
|
1370 |
|
|
1371 |
|box|
|
|
1372 |
|
|
1373 |
box := enterBox.
|
|
1374 |
box isNil ifTrue:[
|
|
1375 |
box := enterBox := EnterBox new
|
|
1376 |
].
|
|
1377 |
box title:(resources string:title) okText:(resources string:okText).
|
|
1378 |
box initialText:''
|
|
1379 |
!
|
|
1380 |
|
|
1381 |
enterBoxForSearchSelectorTitle:title
|
|
1382 |
"convenient method: setup enterBox with text from codeView or selected
|
|
1383 |
method for browsing based on a selector"
|
|
1384 |
|
|
1385 |
self enterBoxTitle:title okText:'search'.
|
|
1386 |
enterBox initialText:(self selectorToSearchFor)
|
|
1387 |
!
|
|
1388 |
|
|
1389 |
enterBoxForBrowseSelectorTitle:title
|
|
1390 |
"convenient method: setup enterBox with text from codeView or selected
|
|
1391 |
method for browsing based on a selector"
|
|
1392 |
|
|
1393 |
self enterBoxTitle:title okText:'browse'.
|
|
1394 |
enterBox initialText:(self selectorToSearchFor)
|
|
1395 |
!
|
|
1396 |
|
|
1397 |
enterBoxForBrowseTitle:title
|
|
1398 |
"convenient method: setup enterBox with text from codeView or selected
|
|
1399 |
method for method browsing based on className/variable"
|
|
1400 |
|
|
1401 |
self enterBoxTitle:title okText:'browse'.
|
|
1402 |
enterBox initialText:(self stringToSearchFor)
|
|
1403 |
!
|
|
1404 |
|
|
1405 |
enterBoxForCodeSelectionTitle:title okText:okText
|
|
1406 |
"convenient method: setup enterBox with text from codeview"
|
|
1407 |
|
|
1408 |
|sel|
|
|
1409 |
|
|
1410 |
self enterBoxTitle:(resources string:title) okText:(resources string:okText).
|
|
1411 |
sel := codeView selection.
|
|
1412 |
sel notNil ifTrue:[
|
|
1413 |
enterBox initialText:(sel asString withoutSeparators)
|
|
1414 |
] ifFalse:[
|
|
1415 |
enterBox initialText:nil
|
|
1416 |
]
|
|
1417 |
!
|
|
1418 |
|
|
1419 |
enterBoxForMethodCategory:title
|
|
1420 |
"convenient method: setup enterBox with initial being current method category"
|
|
1421 |
|
|
1422 |
|sel|
|
|
1423 |
|
|
1424 |
self enterBoxTitle:title okText:'browse'.
|
|
1425 |
sel := codeView selection.
|
|
1426 |
sel isNil ifTrue:[
|
|
1427 |
currentMethodCategory notNil ifTrue:[
|
|
1428 |
sel := currentMethodCategory
|
|
1429 |
]
|
|
1430 |
].
|
|
1431 |
sel notNil ifTrue:[
|
|
1432 |
enterBox initialText:(sel asString withoutSpaces)
|
|
1433 |
]
|
|
1434 |
!
|
|
1435 |
|
|
1436 |
newClassCategory:aString
|
|
1437 |
|categories|
|
|
1438 |
|
|
1439 |
categories := classCategoryListView list.
|
|
1440 |
(categories includes:aString) ifFalse:[
|
|
1441 |
categories add:aString.
|
|
1442 |
categories sort.
|
|
1443 |
classCategoryListView setContents:categories.
|
|
1444 |
currentClassCategory := aString.
|
|
1445 |
classCategoryListView selectElement:aString.
|
|
1446 |
self switchToClass:nil.
|
|
1447 |
actualClass := nil.
|
|
1448 |
self classCategorySelectionChanged
|
|
1449 |
]
|
|
1450 |
!
|
|
1451 |
|
|
1452 |
listOfAllClassCategories
|
|
1453 |
"return a list of all class categories"
|
|
1454 |
|
|
1455 |
|newList cat|
|
|
1456 |
|
|
1457 |
newList := Text with:'* all *' with:'* hierarchy *'.
|
|
1458 |
Smalltalk allBehaviorsDo:[:aClass |
|
|
1459 |
cat := aClass category.
|
|
1460 |
cat isNil ifTrue:[
|
|
1461 |
cat := '* no category *'
|
|
1462 |
].
|
|
1463 |
newList indexOf:cat ifAbsent:[newList add:cat]
|
|
1464 |
].
|
|
1465 |
newList sort.
|
|
1466 |
^ newList
|
|
1467 |
!
|
|
1468 |
|
|
1469 |
listOfClassHierarchyOf:aClass
|
|
1470 |
"return a hierarchy class-list"
|
|
1471 |
|
|
1472 |
^ (aClass allSuperclasses reverse ,
|
|
1473 |
(Array with:aClass),
|
|
1474 |
aClass allSubclassesInOrder) collect:[:c | c name]
|
|
1475 |
|
|
1476 |
"
|
|
1477 |
|newList theClass|
|
|
1478 |
|
|
1479 |
theClass := aClass.
|
|
1480 |
newList := Text with:theClass name.
|
|
1481 |
[theClass ~~ Object] whileTrue:[
|
|
1482 |
theClass := theClass superclass.
|
|
1483 |
newList add:theClass name
|
|
1484 |
].
|
|
1485 |
newList reverse.
|
|
1486 |
^ newList
|
|
1487 |
"
|
|
1488 |
!
|
|
1489 |
|
|
1490 |
listOfAllClassesInCategory:aCategory
|
|
1491 |
"return a list of all classes in a given category"
|
|
1492 |
|
|
1493 |
|newList classList searchCategory string|
|
|
1494 |
|
|
1495 |
newList := Text new.
|
|
1496 |
(aCategory = '* all *') ifTrue:[
|
|
1497 |
Smalltalk allBehaviorsDo:[:aClass |
|
|
1498 |
string := aClass name.
|
|
1499 |
newList indexOf:string ifAbsent:[newList add:string]
|
|
1500 |
]
|
|
1501 |
] ifFalse:[
|
|
1502 |
(aCategory = '* hierarchy *') ifTrue:[
|
|
1503 |
classList := Text new.
|
|
1504 |
self classHierarchyDo:[:aClass :lvl|
|
|
1505 |
string := aClass name.
|
|
1506 |
classList indexOf:string ifAbsent:[
|
|
1507 |
classList add:string.
|
|
1508 |
newList add:(String new:lvl) , string
|
|
1509 |
]
|
|
1510 |
].
|
|
1511 |
^ newList
|
|
1512 |
] ifFalse:[
|
|
1513 |
(aCategory = '* no category *') ifTrue:[
|
|
1514 |
searchCategory := nil
|
|
1515 |
] ifFalse:[
|
|
1516 |
searchCategory := aCategory
|
|
1517 |
].
|
|
1518 |
Smalltalk allBehaviorsDo:[:aClass |
|
|
1519 |
aClass isMeta ifFalse:[
|
|
1520 |
(aClass category = searchCategory) ifTrue:[
|
|
1521 |
string := aClass name.
|
|
1522 |
newList indexOf:string ifAbsent:[newList add:string]
|
|
1523 |
]
|
|
1524 |
]
|
|
1525 |
]
|
|
1526 |
]
|
|
1527 |
].
|
|
1528 |
(newList size == 0) ifTrue:[^ nil].
|
|
1529 |
^ newList sort
|
|
1530 |
!
|
|
1531 |
|
|
1532 |
classHierarchyDo:aBlock
|
|
1533 |
"eavluate the 2-arg block for every class,
|
|
1534 |
starting at Object; passing class and nesting level to the block."
|
|
1535 |
|
|
1536 |
|classes s classDict l|
|
|
1537 |
|
|
1538 |
classes := Smalltalk allClasses.
|
|
1539 |
classDict := IdentityDictionary new:classes size.
|
|
1540 |
classes do:[:aClass |
|
|
1541 |
s := aClass superclass.
|
|
1542 |
s notNil ifTrue:[
|
|
1543 |
l := classDict at:s ifAbsent:[nil].
|
|
1544 |
l isNil ifTrue:[
|
|
1545 |
l := OrderedCollection new:5.
|
|
1546 |
classDict at:s put:l
|
|
1547 |
].
|
|
1548 |
l add:aClass
|
|
1549 |
]
|
|
1550 |
].
|
|
1551 |
self classHierarchyOf:Object level:0 do:aBlock using:classDict
|
|
1552 |
!
|
|
1553 |
|
|
1554 |
classHierarchyOf:aClass level:level do:aBlock using:aDictionary
|
|
1555 |
"evaluate the 2-arg block for every subclass of aClass,
|
|
1556 |
passing class and nesting level to the block."
|
|
1557 |
|
|
1558 |
|names subclasses|
|
|
1559 |
|
|
1560 |
aBlock value:aClass value:level.
|
|
1561 |
subclasses := aDictionary at:aClass ifAbsent:[nil].
|
|
1562 |
(subclasses size == 0) ifFalse:[
|
|
1563 |
names := subclasses collect:[:class | class name].
|
|
1564 |
names sortWith:subclasses.
|
|
1565 |
subclasses do:[:aSubClass |
|
|
1566 |
self classHierarchyOf:aSubClass level:(level + 1) do:aBlock using:aDictionary
|
|
1567 |
]
|
|
1568 |
]
|
|
1569 |
!
|
|
1570 |
|
|
1571 |
listOfAllMethodCategoriesInClass:aClass
|
|
1572 |
"answer a list of all method categories of the argument, aClass"
|
|
1573 |
|
|
1574 |
|newList cat|
|
|
1575 |
|
|
1576 |
newList := Text new.
|
|
1577 |
aClass methodArray do:[:aMethod |
|
|
1578 |
cat := aMethod category.
|
|
1579 |
cat isNil ifTrue:[
|
|
1580 |
cat := '* no category *'
|
|
1581 |
].
|
|
1582 |
(newList includes:cat) ifFalse:[newList add:cat]
|
|
1583 |
].
|
|
1584 |
(newList size == 0) ifTrue:[^ nil].
|
|
1585 |
newList add:'* all *'.
|
|
1586 |
^ newList sort
|
|
1587 |
!
|
|
1588 |
|
|
1589 |
listOfAllSelectorsInCategory:aCategory ofClass:aClass
|
|
1590 |
"answer a list of all selectors in a given method category
|
|
1591 |
of the argument, aClass"
|
|
1592 |
|
|
1593 |
|newList searchCategory selector|
|
|
1594 |
|
|
1595 |
(aCategory = '* all *') ifTrue:[
|
|
1596 |
newList := aClass selectorArray asText
|
|
1597 |
] ifFalse:[
|
|
1598 |
(aCategory = '* no category *') ifTrue:[
|
|
1599 |
searchCategory := nil
|
|
1600 |
] ifFalse:[
|
|
1601 |
searchCategory := aCategory
|
|
1602 |
].
|
|
1603 |
newList := Text new.
|
|
1604 |
aClass methodArray do:[:aMethod |
|
|
1605 |
(aMethod category = searchCategory) ifTrue:[
|
|
1606 |
selector := aClass selectorForMethod:aMethod.
|
|
1607 |
selector notNil ifTrue:[
|
|
1608 |
aMethod isWrapped ifTrue:[
|
|
1609 |
selector := selector , ' !!'
|
|
1610 |
].
|
|
1611 |
(newList includes:selector) ifFalse:[
|
|
1612 |
newList add:selector
|
|
1613 |
]
|
|
1614 |
]
|
|
1615 |
]
|
|
1616 |
]
|
|
1617 |
].
|
|
1618 |
(newList size == 0) ifTrue:[^ nil].
|
|
1619 |
^ newList sort
|
|
1620 |
!
|
|
1621 |
|
|
1622 |
templateFor:className in:cat
|
|
1623 |
"return a class definition template - be smart in what is offered initially"
|
|
1624 |
|
|
1625 |
|aString name i|
|
|
1626 |
|
|
1627 |
name := 'NewClass'.
|
|
1628 |
i := 1.
|
|
1629 |
[name knownAsSymbol and:[Smalltalk includesKey:name asSymbol]] whileTrue:[
|
|
1630 |
i := i + 1.
|
|
1631 |
name := 'NewClass' , i printString
|
|
1632 |
].
|
|
1633 |
|
|
1634 |
aString := className , ' subclass:#' , name , '
|
|
1635 |
instanceVariableNames: ''''
|
|
1636 |
classVariableNames: ''''
|
|
1637 |
poolDictionaries: ''''
|
|
1638 |
category: '''.
|
|
1639 |
|
|
1640 |
cat notNil ifTrue:[
|
|
1641 |
aString := aString , cat
|
|
1642 |
].
|
|
1643 |
aString := aString , ''''.
|
|
1644 |
^ aString
|
|
1645 |
!
|
|
1646 |
|
|
1647 |
template
|
|
1648 |
"return a method definition template"
|
|
1649 |
|
|
1650 |
^
|
|
1651 |
'message selector and argument names
|
|
1652 |
"comment stating purpose of message"
|
|
1653 |
|
|
1654 |
|
|
1655 |
|temporaries|
|
|
1656 |
statements
|
|
1657 |
'
|
|
1658 |
!
|
|
1659 |
|
|
1660 |
compileCode:someCode
|
|
1661 |
(ReadStream on:someCode) fileIn
|
|
1662 |
! !
|
|
1663 |
|
|
1664 |
!SystemBrowser methodsFor:'user interaction'!
|
|
1665 |
|
|
1666 |
instanceProtocol
|
|
1667 |
showInstance ifFalse:[
|
|
1668 |
self checkSelectionChangeAllowed ifTrue:[
|
|
1669 |
classToggle turnOff.
|
|
1670 |
instanceToggle turnOn.
|
|
1671 |
showInstance := true.
|
|
1672 |
currentClass notNil ifTrue:[
|
|
1673 |
self classSelectionChanged
|
|
1674 |
].
|
|
1675 |
codeView modified:false.
|
|
1676 |
] ifFalse:[
|
|
1677 |
instanceToggle turnOff.
|
|
1678 |
classToggle turnOn
|
|
1679 |
]
|
|
1680 |
]
|
|
1681 |
!
|
|
1682 |
|
|
1683 |
classProtocol
|
|
1684 |
showInstance ifTrue:[
|
|
1685 |
self checkSelectionChangeAllowed ifTrue:[
|
|
1686 |
instanceToggle turnOff.
|
|
1687 |
classToggle turnOn.
|
|
1688 |
showInstance := false.
|
|
1689 |
currentClass notNil ifTrue:[
|
|
1690 |
self classSelectionChanged
|
|
1691 |
].
|
|
1692 |
codeView modified:false.
|
|
1693 |
] ifFalse:[
|
|
1694 |
instanceToggle turnOn.
|
|
1695 |
classToggle turnOff
|
|
1696 |
]
|
|
1697 |
]
|
|
1698 |
!
|
|
1699 |
|
|
1700 |
updateClassCategoryListWithScroll:scroll
|
|
1701 |
|oldClassCategory oldClass oldMethodCategory oldMethod
|
|
1702 |
oldSelector newCategoryList|
|
|
1703 |
|
|
1704 |
classMethodListView notNil ifTrue:[ ^ self ].
|
|
1705 |
|
|
1706 |
oldClassCategory := currentClassCategory.
|
|
1707 |
oldClass := currentClass.
|
|
1708 |
oldMethodCategory := currentMethodCategory.
|
|
1709 |
oldMethod := currentMethod.
|
|
1710 |
oldMethod notNil ifTrue:[
|
|
1711 |
oldSelector := methodListView selectionValue
|
|
1712 |
].
|
|
1713 |
|
|
1714 |
classCategoryListView notNil ifTrue:[
|
|
1715 |
newCategoryList := self listOfAllClassCategories.
|
|
1716 |
newCategoryList = classCategoryListView list ifFalse:[
|
|
1717 |
scroll ifTrue:[
|
|
1718 |
classCategoryListView contents:newCategoryList
|
|
1719 |
] ifFalse:[
|
|
1720 |
classCategoryListView setContents:newCategoryList
|
|
1721 |
]
|
|
1722 |
]
|
|
1723 |
].
|
|
1724 |
|
|
1725 |
oldClassCategory notNil ifTrue:[
|
|
1726 |
classCategoryListView notNil ifTrue:[
|
|
1727 |
classCategoryListView selectElement:oldClassCategory
|
|
1728 |
]
|
|
1729 |
].
|
|
1730 |
classListView notNil ifTrue:[
|
|
1731 |
oldClass notNil ifTrue:[
|
|
1732 |
classListView selectElement:(oldClass name)
|
|
1733 |
]
|
|
1734 |
].
|
|
1735 |
oldMethodCategory notNil ifTrue:[
|
|
1736 |
methodCategoryListView notNil ifTrue:[
|
|
1737 |
methodCategoryListView selectElement:oldMethodCategory
|
|
1738 |
].
|
|
1739 |
].
|
|
1740 |
oldSelector notNil ifTrue:[
|
|
1741 |
methodListView notNil ifTrue:[
|
|
1742 |
methodListView selectElement:oldSelector
|
|
1743 |
].
|
|
1744 |
]
|
|
1745 |
!
|
|
1746 |
|
|
1747 |
updateClassCategoryList
|
|
1748 |
self updateClassCategoryListWithScroll:true
|
|
1749 |
!
|
|
1750 |
|
|
1751 |
updateClassListWithScroll:scroll
|
|
1752 |
|classes oldClassName|
|
|
1753 |
|
|
1754 |
classListView notNil ifTrue:[
|
|
1755 |
currentClass notNil ifTrue:[
|
|
1756 |
oldClassName := currentClass name.
|
|
1757 |
currentClass := Smalltalk at:(oldClassName asSymbol).
|
|
1758 |
].
|
|
1759 |
|
|
1760 |
currentClassCategory notNil ifTrue:[
|
|
1761 |
classes := self listOfAllClassesInCategory:currentClassCategory
|
|
1762 |
] ifFalse:[
|
|
1763 |
currentClassHierarchy notNil ifTrue:[
|
|
1764 |
classes := self listOfClassHierarchyOf:currentClassHierarchy
|
|
1765 |
]
|
|
1766 |
].
|
|
1767 |
|
|
1768 |
classListView list = classes ifFalse:[
|
|
1769 |
scroll ifTrue:[
|
|
1770 |
classListView contents:classes
|
|
1771 |
] ifFalse:[
|
|
1772 |
classListView setContents:classes
|
|
1773 |
].
|
|
1774 |
oldClassName notNil ifTrue:[
|
|
1775 |
classListView setContents:classes.
|
|
1776 |
classListView selectElement:oldClassName
|
|
1777 |
].
|
|
1778 |
]
|
|
1779 |
]
|
|
1780 |
!
|
|
1781 |
|
|
1782 |
updateClassList
|
|
1783 |
self updateClassListWithScroll:true
|
|
1784 |
!
|
|
1785 |
|
|
1786 |
updateMethodCategoryListWithScroll:scroll
|
|
1787 |
|categories|
|
|
1788 |
|
|
1789 |
methodCategoryListView notNil ifTrue:[
|
|
1790 |
currentClass notNil ifTrue:[
|
|
1791 |
categories := self listOfAllMethodCategoriesInClass:actualClass
|
|
1792 |
].
|
|
1793 |
methodCategoryListView list = categories ifFalse:[
|
|
1794 |
scroll ifTrue:[
|
|
1795 |
methodCategoryListView contents:categories
|
|
1796 |
] ifFalse:[
|
|
1797 |
methodCategoryListView setContents:categories
|
|
1798 |
].
|
|
1799 |
currentMethodCategory notNil ifTrue:[
|
|
1800 |
methodCategoryListView selectElement:currentMethodCategory
|
|
1801 |
]
|
|
1802 |
]
|
|
1803 |
]
|
|
1804 |
!
|
|
1805 |
|
|
1806 |
updateMethodCategoryList
|
|
1807 |
self updateMethodCategoryListWithScroll:true
|
|
1808 |
!
|
|
1809 |
|
|
1810 |
updateMethodListWithScroll:scroll
|
|
1811 |
|selectors scr first last|
|
|
1812 |
|
|
1813 |
methodListView notNil ifTrue:[
|
|
1814 |
currentMethodCategory notNil ifTrue:[
|
|
1815 |
selectors := self listOfAllSelectorsInCategory:currentMethodCategory
|
|
1816 |
ofClass:actualClass
|
|
1817 |
].
|
|
1818 |
scr := scroll.
|
|
1819 |
first := methodListView firstLineShown.
|
|
1820 |
first ~~ 1 ifTrue:[
|
|
1821 |
last := methodListView lastLineShown.
|
|
1822 |
selectors size <= (last - first + 1) ifTrue:[
|
|
1823 |
scr := true
|
|
1824 |
]
|
|
1825 |
].
|
|
1826 |
methodListView list = selectors ifFalse:[
|
|
1827 |
scr ifTrue:[
|
|
1828 |
methodListView contents:selectors
|
|
1829 |
] ifFalse:[
|
|
1830 |
methodListView setContents:selectors
|
|
1831 |
]
|
|
1832 |
].
|
|
1833 |
]
|
|
1834 |
!
|
|
1835 |
|
|
1836 |
updateMethodList
|
|
1837 |
self updateMethodListWithScroll:true
|
|
1838 |
!
|
|
1839 |
|
|
1840 |
updateCodeView
|
|
1841 |
|code aStream|
|
|
1842 |
|
|
1843 |
fullClass ifTrue:[
|
|
1844 |
currentClass notNil ifTrue:[
|
|
1845 |
" this is too slow for big classes ...
|
|
1846 |
code := String new:1000.
|
|
1847 |
aStream := WriteStream on:code.
|
|
1848 |
currentClass fileOutOn:aStream
|
|
1849 |
"
|
|
1850 |
aStream := FileStream newFileNamed:'__temp'.
|
|
1851 |
aStream isNil ifTrue:[
|
|
1852 |
self notify:'cannot create temporary file.'.
|
|
1853 |
codeView contents:nil.
|
|
1854 |
codeView modified:false.
|
|
1855 |
^ self
|
|
1856 |
].
|
|
1857 |
currentClass fileOutOn:aStream.
|
|
1858 |
aStream close.
|
|
1859 |
aStream := FileStream oldFileNamed:'__temp'.
|
|
1860 |
aStream isNil ifTrue:[
|
|
1861 |
self notify:'oops - cannot reopen temp file'.
|
|
1862 |
codeView contents:nil.
|
|
1863 |
codeView modified:false.
|
|
1864 |
^ self
|
|
1865 |
].
|
|
1866 |
code := aStream contents.
|
|
1867 |
aStream close.
|
|
1868 |
OperatingSystem removeFile:'__temp'
|
|
1869 |
]
|
|
1870 |
] ifFalse:[
|
|
1871 |
currentMethod notNil ifTrue:[
|
|
1872 |
code := currentMethod source
|
|
1873 |
]
|
|
1874 |
].
|
|
1875 |
codeView contents:code.
|
|
1876 |
codeView modified:false
|
|
1877 |
!
|
|
1878 |
|
|
1879 |
classSelectionChanged
|
|
1880 |
|oldMethodCategory oldMethod|
|
|
1881 |
|
|
1882 |
self withWaitCursorDo:[
|
|
1883 |
oldMethodCategory := currentMethodCategory.
|
|
1884 |
oldMethod := currentMethod.
|
|
1885 |
|
|
1886 |
showInstance ifTrue:[
|
|
1887 |
actualClass := currentClass
|
|
1888 |
] ifFalse:[
|
|
1889 |
actualClass := currentClass class
|
|
1890 |
].
|
|
1891 |
currentMethodCategory := nil.
|
|
1892 |
currentMethod := nil.
|
|
1893 |
|
|
1894 |
self updateMethodCategoryList.
|
|
1895 |
oldMethodCategory notNil ifTrue:[
|
|
1896 |
methodCategoryListView selectElement:oldMethodCategory.
|
|
1897 |
methodCategoryListView selection notNil ifTrue:[
|
|
1898 |
currentMethodCategory := oldMethodCategory.
|
|
1899 |
self methodCategorySelectionChanged
|
|
1900 |
]
|
|
1901 |
].
|
|
1902 |
self updateMethodList.
|
|
1903 |
self updateCodeView.
|
|
1904 |
|
|
1905 |
fullClass ifTrue:[
|
|
1906 |
codeView acceptAction:[:theCode |
|
|
1907 |
codeView cursor:Cursor execute.
|
|
1908 |
Object abortSignal catch:[
|
|
1909 |
self compileCode:theCode asString.
|
|
1910 |
codeView modified:false.
|
|
1911 |
].
|
|
1912 |
codeView cursor:Cursor normal.
|
|
1913 |
].
|
|
1914 |
codeView explainAction:nil
|
|
1915 |
] ifFalse:[
|
|
1916 |
self classDefinition.
|
|
1917 |
codeView acceptAction:[:theCode |
|
|
1918 |
codeView cursor:Cursor execute.
|
|
1919 |
Object abortSignal catch:[
|
|
1920 |
(Compiler evaluate:theCode asString notifying:codeView)
|
|
1921 |
isBehavior ifTrue:[
|
|
1922 |
self classCategoryUpdate.
|
|
1923 |
self updateClassListWithScroll:false.
|
|
1924 |
codeView modified:false.
|
|
1925 |
].
|
|
1926 |
].
|
|
1927 |
codeView cursor:Cursor normal.
|
|
1928 |
].
|
|
1929 |
codeView explainAction:nil
|
|
1930 |
].
|
|
1931 |
classCategoryListView notNil ifTrue:[
|
|
1932 |
(currentClassCategory = currentClass category) ifFalse:[
|
|
1933 |
currentClassCategory := currentClass category.
|
|
1934 |
classCategoryListView selectElement:currentClassCategory
|
|
1935 |
]
|
|
1936 |
].
|
|
1937 |
|
|
1938 |
"set self for doits. This allows accessing the current class
|
|
1939 |
as self, and access to the class variables by name."
|
|
1940 |
|
|
1941 |
codeView doItAction:[:theCode |
|
|
1942 |
|compiler|
|
|
1943 |
|
|
1944 |
currentClass isNil ifTrue:[
|
|
1945 |
compiler := Compiler
|
|
1946 |
] ifFalse:[
|
|
1947 |
compiler := currentClass compiler
|
|
1948 |
].
|
|
1949 |
compiler
|
|
1950 |
evaluate:theCode
|
|
1951 |
in:nil
|
|
1952 |
receiver:currentClass
|
|
1953 |
notifying:codeView
|
|
1954 |
logged:false
|
|
1955 |
ifFail:nil
|
|
1956 |
]
|
|
1957 |
]
|
|
1958 |
!
|
|
1959 |
|
|
1960 |
classCategorySelectionChanged
|
|
1961 |
"class category has changed - update dependant views"
|
|
1962 |
|
|
1963 |
self withWaitCursorDo:[
|
|
1964 |
self switchToClass:nil.
|
|
1965 |
actualClass := nil.
|
|
1966 |
currentMethodCategory := nil.
|
|
1967 |
currentMethod := nil.
|
|
1968 |
|
|
1969 |
self updateClassList.
|
|
1970 |
self updateMethodCategoryList.
|
|
1971 |
self updateMethodList.
|
|
1972 |
self updateCodeView.
|
|
1973 |
|
|
1974 |
codeView explainAction:nil.
|
|
1975 |
codeView acceptAction:nil
|
|
1976 |
]
|
|
1977 |
!
|
|
1978 |
|
|
1979 |
classCategorySelection:lineNr
|
|
1980 |
"user clicked on a class category line - show classes.
|
|
1981 |
If switching to hierarchy or all, keep current selections"
|
|
1982 |
|
|
1983 |
|newCategory oldClass classIndex index|
|
|
1984 |
|
|
1985 |
newCategory := classCategoryListView selectionValue.
|
|
1986 |
(newCategory startsWith:'*') ifTrue:[
|
|
1987 |
"etiher all or hierarchy;
|
|
1988 |
remember current selections and switch after showing class list"
|
|
1989 |
oldClass := currentClass
|
|
1990 |
].
|
|
1991 |
currentClassCategory := newCategory.
|
|
1992 |
oldClass isNil ifTrue:[
|
|
1993 |
self classCategorySelectionChanged
|
|
1994 |
] ifFalse:[
|
|
1995 |
self withWaitCursorDo:[
|
|
1996 |
self updateClassList
|
|
1997 |
].
|
|
1998 |
"stupid - search for class name in (indented) list"
|
|
1999 |
index := 1.
|
|
2000 |
classListView list do:[:elem |
|
|
2001 |
(elem endsWith:(oldClass name)) ifTrue:[
|
|
2002 |
classIndex := index
|
|
2003 |
].
|
|
2004 |
index := index + 1
|
|
2005 |
].
|
|
2006 |
classIndex notNil ifTrue:[
|
|
2007 |
classListView selection:classIndex.
|
|
2008 |
self switchToClass:(Smalltalk at:(oldClass name asSymbol))
|
|
2009 |
]
|
|
2010 |
]
|
|
2011 |
!
|
|
2012 |
|
|
2013 |
classSelection:lineNr
|
|
2014 |
"user clicked on a class line - show method categories"
|
|
2015 |
|
|
2016 |
|classSymbol cls|
|
|
2017 |
|
|
2018 |
classSymbol := classListView selectionValue withoutSpaces asSymbol.
|
|
2019 |
(Smalltalk includesKey:classSymbol) ifTrue:[
|
|
2020 |
cls := Smalltalk at:classSymbol
|
|
2021 |
].
|
|
2022 |
cls notNil ifTrue:[
|
|
2023 |
self switchToClass:cls.
|
|
2024 |
self classSelectionChanged
|
|
2025 |
]
|
|
2026 |
!
|
|
2027 |
|
|
2028 |
methodCategorySelectionChanged
|
|
2029 |
"method category selection has changed - update dependant views"
|
|
2030 |
|
|
2031 |
self withWaitCursorDo:[
|
|
2032 |
currentMethod := nil.
|
|
2033 |
|
|
2034 |
self updateMethodList.
|
|
2035 |
self updateCodeView.
|
|
2036 |
|
|
2037 |
currentMethodCategory notNil ifTrue:[
|
|
2038 |
methodCategoryListView selectElement:currentMethodCategory
|
|
2039 |
].
|
|
2040 |
|
|
2041 |
codeView acceptAction:[:theCode |
|
|
2042 |
codeView cursor:Cursor execute.
|
|
2043 |
Object abortSignal catch:[
|
|
2044 |
actualClass compiler compile:theCode asString
|
|
2045 |
forClass:actualClass
|
|
2046 |
inCategory:currentMethodCategory
|
|
2047 |
notifying:codeView.
|
|
2048 |
codeView modified:false.
|
|
2049 |
self updateMethodListWithScroll:false.
|
|
2050 |
].
|
|
2051 |
codeView cursor:Cursor normal.
|
|
2052 |
].
|
|
2053 |
codeView explainAction:[:theCode :theSelection |
|
|
2054 |
self showExplanation:(Explainer explain:theSelection
|
|
2055 |
in:theCode
|
|
2056 |
forClass:actualClass)
|
|
2057 |
]
|
|
2058 |
]
|
|
2059 |
!
|
|
2060 |
|
|
2061 |
methodCategorySelection:lineNr
|
|
2062 |
"user clicked on a method category line - show selectors"
|
|
2063 |
|
|
2064 |
currentClass isNil ifTrue:[^ self].
|
|
2065 |
|
|
2066 |
currentMethodCategory := methodCategoryListView selectionValue.
|
|
2067 |
self methodCategorySelectionChanged
|
|
2068 |
!
|
|
2069 |
|
|
2070 |
methodSelectionChanged
|
|
2071 |
"method selection has changed - update dependant views"
|
|
2072 |
|
|
2073 |
self withWaitCursorDo:[
|
|
2074 |
self updateCodeView.
|
|
2075 |
codeView acceptAction:[:theCode |
|
|
2076 |
codeView cursor:Cursor execute.
|
|
2077 |
Object abortSignal catch:[
|
|
2078 |
actualClass compiler compile:theCode asString
|
|
2079 |
forClass:actualClass
|
|
2080 |
inCategory:currentMethodCategory
|
|
2081 |
notifying:codeView.
|
|
2082 |
codeView modified:false.
|
|
2083 |
self updateMethodListWithScroll:false.
|
|
2084 |
].
|
|
2085 |
codeView cursor:Cursor normal.
|
|
2086 |
].
|
|
2087 |
codeView explainAction:[:theCode :theSelection |
|
|
2088 |
self showExplanation:(Explainer explain:theSelection
|
|
2089 |
in:theCode
|
|
2090 |
forClass:actualClass)
|
|
2091 |
].
|
|
2092 |
methodListView notNil ifTrue:[
|
|
2093 |
(currentMethod notNil and:[currentMethod isWrapped]) ifTrue:[
|
|
2094 |
self initializeMethodMenu2
|
|
2095 |
] ifFalse:[
|
|
2096 |
self initializeMethodMenu
|
|
2097 |
]
|
|
2098 |
]
|
|
2099 |
]
|
|
2100 |
!
|
|
2101 |
|
|
2102 |
methodSelection:lineNr
|
|
2103 |
"user clicked on a method line - show code"
|
|
2104 |
|
|
2105 |
|selectorString selectorSymbol|
|
|
2106 |
|
|
2107 |
currentClass isNil ifTrue:[^ self].
|
|
2108 |
|
|
2109 |
selectorString := methodListView selectionValue.
|
|
2110 |
"
|
|
2111 |
kludge: check if its a wrapped one
|
|
2112 |
"
|
|
2113 |
(selectorString endsWith:' !!') ifTrue:[
|
|
2114 |
selectorString := selectorString copyTo:(selectorString size - 2)
|
|
2115 |
].
|
|
2116 |
selectorSymbol := selectorString asSymbol.
|
|
2117 |
currentMethod := actualClass compiledMethodAt:selectorSymbol.
|
|
2118 |
|
|
2119 |
methodCategoryListView notNil ifTrue:[
|
|
2120 |
currentMethod notNil ifTrue:[
|
|
2121 |
(currentMethodCategory = currentMethod category) ifFalse:[
|
|
2122 |
currentMethodCategory := currentMethod category.
|
|
2123 |
methodCategoryListView selectElement:currentMethodCategory
|
|
2124 |
]
|
|
2125 |
]
|
|
2126 |
].
|
|
2127 |
|
|
2128 |
self methodSelectionChanged
|
|
2129 |
!
|
|
2130 |
|
|
2131 |
classFromClassMethodString:aString
|
|
2132 |
"helper for classMethod-list - extract class name from the string"
|
|
2133 |
|
|
2134 |
|pos|
|
|
2135 |
|
|
2136 |
pos := aString indexOf:(Character space).
|
|
2137 |
^ aString copyTo:(pos - 1)
|
|
2138 |
!
|
|
2139 |
|
|
2140 |
selectorFromClassMethodString:aString
|
|
2141 |
"helper for classMethod-list - extract selector from the string"
|
|
2142 |
|
|
2143 |
|pos|
|
|
2144 |
|
|
2145 |
pos := aString indexOf:(Character space).
|
|
2146 |
^ aString copyFrom:(pos + 1)
|
|
2147 |
!
|
|
2148 |
|
|
2149 |
listSelection:lineNr
|
|
2150 |
"user clicked on a class/method line - show code"
|
|
2151 |
|
|
2152 |
|string classString selectorString|
|
|
2153 |
|
|
2154 |
string := classMethodListView selectionValue.
|
|
2155 |
classString := self classFromClassMethodString:string.
|
|
2156 |
selectorString := self selectorFromClassMethodString:string.
|
|
2157 |
((classString ~= 'Metaclass') and:[classString endsWith:'class']) ifTrue:[
|
|
2158 |
classString := classString copyTo:(classString size - 5).
|
|
2159 |
self switchToClass:(Smalltalk at:classString asSymbol).
|
|
2160 |
actualClass := currentClass class
|
|
2161 |
] ifFalse:[
|
|
2162 |
self switchToClass:(Smalltalk at:classString asSymbol).
|
|
2163 |
actualClass := currentClass
|
|
2164 |
].
|
|
2165 |
currentClass isNil ifTrue:[
|
|
2166 |
self warn:'oops class is gone'
|
|
2167 |
] ifFalse:[
|
|
2168 |
currentClassCategory := currentClass category.
|
|
2169 |
currentMethod := actualClass compiledMethodAt:(selectorString asSymbol).
|
|
2170 |
currentMethodCategory := currentMethod category.
|
|
2171 |
|
|
2172 |
self methodSelectionChanged
|
|
2173 |
]
|
|
2174 |
! !
|
|
2175 |
|
|
2176 |
!SystemBrowser methodsFor:'class category menu'!
|
|
2177 |
|
|
2178 |
initializeClassCategoryMenu
|
|
2179 |
|labels|
|
|
2180 |
|
|
2181 |
labels := resources array:#(
|
|
2182 |
'fileOut'
|
|
2183 |
'fileOut each'
|
|
2184 |
"
|
|
2185 |
'fileOut binary'
|
|
2186 |
"
|
|
2187 |
'printOut'
|
|
2188 |
'printOut protocol'
|
|
2189 |
'-'
|
|
2190 |
'spawn'
|
|
2191 |
'spawn class'
|
|
2192 |
'-'
|
|
2193 |
'update'
|
|
2194 |
'find class ...'
|
|
2195 |
'-'
|
|
2196 |
'new class category ...'
|
|
2197 |
'rename ...'
|
|
2198 |
'remove').
|
|
2199 |
|
|
2200 |
classCategoryListView
|
|
2201 |
middleButtonMenu:(PopUpMenu
|
|
2202 |
labels:labels
|
|
2203 |
selectors:#(classCategoryFileOut
|
|
2204 |
classCategoryFileOutEach
|
|
2205 |
"
|
|
2206 |
classCategoryBinaryFileOut
|
|
2207 |
"
|
|
2208 |
classCategoryPrintOut
|
|
2209 |
classCategoryPrintOutProtocol
|
|
2210 |
nil
|
|
2211 |
classCategorySpawn
|
|
2212 |
classCategorySpawnFullClass
|
|
2213 |
nil
|
|
2214 |
classCategoryUpdate
|
|
2215 |
classCategoryFindClass
|
|
2216 |
nil
|
|
2217 |
classCategoryNewCategory
|
|
2218 |
classCategoryRename
|
|
2219 |
classCategoryRemove)
|
|
2220 |
receiver:self
|
|
2221 |
for:classCategoryListView)
|
|
2222 |
!
|
|
2223 |
|
|
2224 |
allClassesInCurrentCategoryInOrderDo:aBlock
|
|
2225 |
"evaluate aBlock for all classes in the current class category;
|
|
2226 |
superclasses come first - then subclasses"
|
|
2227 |
|
|
2228 |
|classes|
|
|
2229 |
|
|
2230 |
currentClassCategory notNil ifTrue:[
|
|
2231 |
classes := OrderedCollection new.
|
|
2232 |
Smalltalk allClassesDo:[:aClass |
|
|
2233 |
aClass isMeta ifFalse:[
|
|
2234 |
(aClass category = currentClassCategory) ifTrue:[
|
|
2235 |
classes add:aClass
|
|
2236 |
]
|
|
2237 |
]
|
|
2238 |
].
|
|
2239 |
classes topologicalSort:[:a :b | b isSubclassOf:a].
|
|
2240 |
classes do:aBlock
|
|
2241 |
]
|
|
2242 |
!
|
|
2243 |
|
|
2244 |
allClassesInCurrentCategoryDo:aBlock
|
|
2245 |
"evaluate aBlock for all classes in the current class category;
|
|
2246 |
superclasses come first - then subclasses"
|
|
2247 |
|
|
2248 |
currentClassCategory notNil ifTrue:[
|
|
2249 |
Smalltalk allClassesDo:[:aClass |
|
|
2250 |
aClass isMeta ifFalse:[
|
|
2251 |
(aClass category = currentClassCategory) ifTrue:[
|
|
2252 |
aBlock value:aClass
|
|
2253 |
]
|
|
2254 |
]
|
|
2255 |
].
|
|
2256 |
]
|
|
2257 |
!
|
|
2258 |
|
|
2259 |
classCategoryUpdate
|
|
2260 |
"update class category list and dependants"
|
|
2261 |
|
|
2262 |
|oldClassName oldMethodCategory|
|
|
2263 |
|
|
2264 |
classCategoryListView notNil ifTrue:[
|
|
2265 |
currentClass notNil ifTrue:[
|
|
2266 |
oldClassName := currentClass name.
|
|
2267 |
(oldClassName endsWith:'-old') ifTrue:[
|
|
2268 |
oldClassName := oldClassName copyTo:(oldClassName size - 4)
|
|
2269 |
]
|
|
2270 |
].
|
|
2271 |
oldMethodCategory := currentMethodCategory.
|
|
2272 |
|
|
2273 |
classCategoryListView setContents:(self listOfAllClassCategories).
|
|
2274 |
currentClassCategory notNil ifTrue:[
|
|
2275 |
classCategoryListView selectElement:currentClassCategory.
|
|
2276 |
self classCategorySelectionChanged.
|
|
2277 |
oldClassName notNil ifTrue:[
|
|
2278 |
classListView selectElement:oldClassName.
|
|
2279 |
self switchToClass:(Smalltalk at:oldClassName asSymbol).
|
|
2280 |
self classSelectionChanged.
|
|
2281 |
oldMethodCategory notNil ifTrue:[
|
|
2282 |
methodCategoryListView selectElement:oldMethodCategory.
|
|
2283 |
currentMethodCategory := oldMethodCategory.
|
|
2284 |
self methodCategorySelectionChanged
|
|
2285 |
]
|
|
2286 |
]
|
|
2287 |
]
|
|
2288 |
]
|
|
2289 |
!
|
|
2290 |
|
|
2291 |
classCategoryPrintOutProtocol
|
|
2292 |
|printStream|
|
|
2293 |
|
|
2294 |
self allClassesInCurrentCategoryInOrderDo:[:aClass |
|
|
2295 |
printStream := Printer new.
|
|
2296 |
aClass printOutProtocolOn:printStream.
|
|
2297 |
printStream close
|
|
2298 |
]
|
|
2299 |
!
|
|
2300 |
|
|
2301 |
classCategoryPrintOut
|
|
2302 |
|printStream|
|
|
2303 |
|
|
2304 |
self allClassesInCurrentCategoryDo:[:aClass |
|
|
2305 |
printStream := Printer new.
|
|
2306 |
aClass printOutOn:printStream.
|
|
2307 |
printStream close
|
|
2308 |
]
|
|
2309 |
!
|
|
2310 |
|
|
2311 |
classCategoryFileOut
|
|
2312 |
"create a file 'categoryName' consisting of all classes in current category"
|
|
2313 |
|
|
2314 |
|aStream fileName project|
|
|
2315 |
|
|
2316 |
currentClassCategory isNil ifTrue:[
|
|
2317 |
^ self warn:'select a class category first'.
|
|
2318 |
].
|
|
2319 |
|
|
2320 |
fileName := currentClassCategory asString.
|
|
2321 |
fileName replaceAll:Character space by:$_.
|
|
2322 |
Project notNil ifTrue:[
|
|
2323 |
project := Project current.
|
|
2324 |
project notNil ifTrue:[
|
|
2325 |
fileName := project directory , Filename separator asString , fileName.
|
|
2326 |
].
|
|
2327 |
].
|
|
2328 |
|
|
2329 |
aStream := FileStream newFileNamed:fileName.
|
|
2330 |
aStream isNil ifTrue:[
|
|
2331 |
^ self warn:(resources string:'cannot create: %1' with:fileName)
|
|
2332 |
].
|
|
2333 |
self withWaitCursorDo:[
|
|
2334 |
self label:('System Browser writing: ' , fileName).
|
|
2335 |
self allClassesInCurrentCategoryInOrderDo:[:aClass |
|
|
2336 |
aClass fileOutOn:aStream.
|
|
2337 |
].
|
|
2338 |
aStream close.
|
|
2339 |
self label:'System Browser'.
|
|
2340 |
]
|
|
2341 |
!
|
|
2342 |
|
|
2343 |
classCategoryFileOutEach
|
|
2344 |
self withWaitCursorDo:[
|
|
2345 |
self allClassesInCurrentCategoryDo:[:aClass |
|
|
2346 |
self label:('System Browser saving: ' , aClass name).
|
|
2347 |
aClass fileOut
|
|
2348 |
].
|
|
2349 |
self label:'System Browser'.
|
|
2350 |
]
|
|
2351 |
!
|
|
2352 |
|
|
2353 |
classCategoryBinaryFileOut
|
|
2354 |
self withWaitCursorDo:[
|
|
2355 |
self allClassesInCurrentCategoryInOrderDo:[:aClass |
|
|
2356 |
aClass binaryFileOut
|
|
2357 |
]
|
|
2358 |
]
|
|
2359 |
!
|
|
2360 |
|
|
2361 |
classCategorySpawn
|
|
2362 |
"create a new SystemBrowser browsing current classCategory"
|
|
2363 |
|
|
2364 |
currentClassCategory notNil ifTrue:[
|
|
2365 |
self withWaitCursorDo:[
|
|
2366 |
self class browseClassCategory:currentClassCategory
|
|
2367 |
]
|
|
2368 |
]
|
|
2369 |
!
|
|
2370 |
|
|
2371 |
classCategorySpawnFullClass
|
|
2372 |
"create a new SystemBrowser browsing full class"
|
|
2373 |
|
|
2374 |
|newBrowser|
|
|
2375 |
|
|
2376 |
self withWaitCursorDo:[
|
|
2377 |
newBrowser := self class browseFullClasses
|
|
2378 |
"
|
|
2379 |
.
|
|
2380 |
currentClass notNil ifTrue:[
|
|
2381 |
newBrowser switchToClassNamed:(currentClass name)
|
|
2382 |
]
|
|
2383 |
"
|
|
2384 |
]
|
|
2385 |
!
|
|
2386 |
|
|
2387 |
classCategoryNewCategory
|
|
2388 |
self enterBoxTitle:'name of new class category:' okText:'create'.
|
|
2389 |
enterBox action:[:aString | self newClassCategory:aString].
|
|
2390 |
enterBox showAtPointer
|
|
2391 |
!
|
|
2392 |
|
|
2393 |
switchToClassNamed:aString
|
|
2394 |
|classSymbol theClass|
|
|
2395 |
|
|
2396 |
classSymbol := aString asSymbol.
|
|
2397 |
theClass := Smalltalk at:classSymbol.
|
|
2398 |
theClass isBehavior ifTrue:[
|
|
2399 |
classCategoryListView notNil ifTrue:[
|
|
2400 |
currentClassHierarchy isNil ifTrue:[
|
|
2401 |
(theClass category ~~ currentClassCategory) ifTrue:[
|
|
2402 |
currentClassCategory := theClass category.
|
|
2403 |
currentClassCategory isNil ifTrue:[
|
|
2404 |
classCategoryListView selectElement:'* no category *'
|
|
2405 |
] ifFalse:[
|
|
2406 |
classCategoryListView selectElement:currentClassCategory
|
|
2407 |
].
|
|
2408 |
self classCategorySelectionChanged
|
|
2409 |
]
|
|
2410 |
]
|
|
2411 |
].
|
|
2412 |
self switchToClass:theClass.
|
|
2413 |
classListView selectElement:aString.
|
|
2414 |
self classSelectionChanged
|
|
2415 |
]
|
|
2416 |
!
|
|
2417 |
|
|
2418 |
switchToClassNameMatching:aMatchString
|
|
2419 |
|classNames thisName|
|
|
2420 |
|
|
2421 |
classNames := OrderedCollection new.
|
|
2422 |
Smalltalk allBehaviorsDo:[:aClass |
|
|
2423 |
thisName := aClass name.
|
|
2424 |
(aMatchString match:thisName) ifTrue:[
|
|
2425 |
classNames add:thisName
|
|
2426 |
]
|
|
2427 |
].
|
|
2428 |
(classNames size == 0) ifTrue:[^ nil].
|
|
2429 |
(classNames size == 1) ifTrue:[
|
|
2430 |
^ self switchToClassNamed:(classNames at:1)
|
|
2431 |
].
|
|
2432 |
self listBoxTitle:'select class to switch to:'
|
|
2433 |
okText:'ok'
|
|
2434 |
list:classNames sort.
|
|
2435 |
selectBox action:[:aString | self switchToClassNamed:aString].
|
|
2436 |
selectBox showAtPointer
|
|
2437 |
!
|
|
2438 |
|
|
2439 |
classCategoryFindClass
|
|
2440 |
self enterBoxForCodeSelectionTitle:'class to find:' okText:'find'.
|
|
2441 |
enterBox action:[:aString | self switchToClassNameMatching:aString].
|
|
2442 |
enterBox showAtPointer
|
|
2443 |
!
|
|
2444 |
|
|
2445 |
renameCurrentClassCategoryTo:aString
|
|
2446 |
"helper - do the rename"
|
|
2447 |
|
|
2448 |
|any categories|
|
|
2449 |
|
|
2450 |
currentClassCategory notNil ifTrue:[
|
|
2451 |
any := false.
|
|
2452 |
Smalltalk allBehaviorsDo:[:aClass |
|
|
2453 |
aClass category = currentClassCategory ifTrue:[
|
|
2454 |
aClass category:aString.
|
|
2455 |
any := true
|
|
2456 |
]
|
|
2457 |
].
|
|
2458 |
any ifFalse:[
|
|
2459 |
categories := classCategoryListView list.
|
|
2460 |
categories remove:currentClassCategory.
|
|
2461 |
categories add:aString.
|
|
2462 |
categories sort.
|
|
2463 |
classCategoryListView setContents:categories.
|
|
2464 |
currentClassCategory := aString.
|
|
2465 |
classCategoryListView selectElement:aString.
|
|
2466 |
] ifTrue:[
|
|
2467 |
currentClassCategory := aString.
|
|
2468 |
self updateClassCategoryList.
|
|
2469 |
self updateClassListWithScroll:false
|
|
2470 |
]
|
|
2471 |
]
|
|
2472 |
!
|
|
2473 |
|
|
2474 |
classCategoryRename
|
|
2475 |
"launch an enterBox to rename current class category"
|
|
2476 |
|
|
2477 |
currentClassCategory isNil ifTrue:[
|
|
2478 |
^ self warn:'select a class category first'.
|
|
2479 |
].
|
|
2480 |
self enterBoxTitle:'rename class category to:' okText:'rename'.
|
|
2481 |
enterBox initialText:currentClassCategory.
|
|
2482 |
enterBox action:[:aString | self renameCurrentClassCategoryTo:aString].
|
|
2483 |
enterBox showAtPointer
|
|
2484 |
!
|
|
2485 |
|
|
2486 |
classCategoryRemove
|
|
2487 |
"remove all classes in current category"
|
|
2488 |
|
|
2489 |
|count t classesToRemove subclassesRemoved|
|
|
2490 |
|
|
2491 |
currentClassCategory isNil ifTrue:[
|
|
2492 |
^ self warn:'select a class category first'.
|
|
2493 |
].
|
|
2494 |
|
|
2495 |
classesToRemove := OrderedCollection new.
|
|
2496 |
Smalltalk allBehaviorsDo:[:aClass |
|
|
2497 |
aClass category = currentClassCategory ifTrue:[
|
|
2498 |
classesToRemove add:aClass
|
|
2499 |
]
|
|
2500 |
].
|
|
2501 |
subclassesRemoved := OrderedCollection new.
|
|
2502 |
classesToRemove do:[:aClass |
|
|
2503 |
aClass allSubclassesDo:[:aSubclass |
|
|
2504 |
(classesToRemove includes:aSubclass) ifFalse:[
|
|
2505 |
(subclassesRemoved includes:aSubclass) ifFalse:[
|
|
2506 |
subclassesRemoved add:aSubclass
|
|
2507 |
]
|
|
2508 |
]
|
|
2509 |
]
|
|
2510 |
].
|
|
2511 |
|
|
2512 |
count := classesToRemove size.
|
|
2513 |
t := resources string:'remove %1 ?' with:currentClassCategory.
|
|
2514 |
count ~~ 0 ifTrue:[
|
|
2515 |
t := t , (resources at:'\(with ') , count printString.
|
|
2516 |
count == 1 ifTrue:[
|
|
2517 |
t := t , (resources at:' class')
|
|
2518 |
] ifFalse:[
|
|
2519 |
t := t , (resources at:' classes')
|
|
2520 |
].
|
|
2521 |
t := (t , ')') withCRs
|
|
2522 |
].
|
|
2523 |
|
|
2524 |
count := subclassesRemoved size.
|
|
2525 |
count ~~ 0 ifTrue:[
|
|
2526 |
t := t , (resources at:'\(and ') , count printString.
|
|
2527 |
count == 1 ifTrue:[
|
|
2528 |
t := t , (resources at:' subclass ')
|
|
2529 |
] ifFalse:[
|
|
2530 |
t := t , (resources at:' subclasses ')
|
|
2531 |
].
|
|
2532 |
t := (t , ')') withCRs
|
|
2533 |
].
|
|
2534 |
|
|
2535 |
t := t withCRs.
|
|
2536 |
|
|
2537 |
questBox isNil ifTrue:[questBox := YesNoBox title:''].
|
|
2538 |
questBox title:t.
|
|
2539 |
questBox yesAction:[self doRemoveClasses:classesToRemove and:subclassesRemoved].
|
|
2540 |
questBox okText:(resources at:'remove').
|
|
2541 |
questBox noText:(resources at:'abort').
|
|
2542 |
questBox showAtPointer
|
|
2543 |
!
|
|
2544 |
|
|
2545 |
doRemoveClasses:classList and:subclassList
|
|
2546 |
"after querying user - do really remove classes in list1 and list2"
|
|
2547 |
|
|
2548 |
subclassList do:[:aClass |
|
|
2549 |
Smalltalk removeClass:aClass
|
|
2550 |
].
|
|
2551 |
classList do:[:aClass |
|
|
2552 |
Smalltalk removeClass:aClass
|
|
2553 |
].
|
|
2554 |
currentClassCategory := nil.
|
|
2555 |
self switchToClass:nil.
|
|
2556 |
Smalltalk changed
|
|
2557 |
! !
|
|
2558 |
|
|
2559 |
!SystemBrowser methodsFor:'class menu'!
|
|
2560 |
|
|
2561 |
initializeClassMenu
|
|
2562 |
|labels menu|
|
|
2563 |
|
|
2564 |
labels := resources array:#(
|
|
2565 |
'fileOut'
|
|
2566 |
"
|
|
2567 |
'fileOut binary'
|
|
2568 |
"
|
|
2569 |
'printOut'
|
|
2570 |
'printOut protocol'
|
|
2571 |
" 'printOut full protocol' "
|
|
2572 |
'-'
|
|
2573 |
'spawn'
|
|
2574 |
'spawn hierarchy'
|
|
2575 |
'spawn subclasses'
|
|
2576 |
'-'
|
|
2577 |
'hierarchy'
|
|
2578 |
'definition'
|
|
2579 |
'comment'
|
|
2580 |
'class instvars'
|
|
2581 |
" 'protocols' "
|
|
2582 |
'-'
|
|
2583 |
'variable search'
|
|
2584 |
'-'
|
|
2585 |
'new class'
|
|
2586 |
'new subclass'
|
|
2587 |
'rename ...'
|
|
2588 |
'remove').
|
|
2589 |
|
|
2590 |
menu := PopUpMenu labels:labels
|
|
2591 |
selectors:#(classFileOut
|
|
2592 |
"
|
|
2593 |
classBinaryFileOut
|
|
2594 |
"
|
|
2595 |
classPrintOut
|
|
2596 |
classPrintOutProtocol
|
|
2597 |
" classPrintOutFullProtocol "
|
|
2598 |
nil
|
|
2599 |
classSpawn
|
|
2600 |
classSpawnHierarchy
|
|
2601 |
classSpawnSubclasses
|
|
2602 |
nil
|
|
2603 |
classHierarchy
|
|
2604 |
classDefinition
|
|
2605 |
classComment
|
|
2606 |
classClassInstVars
|
|
2607 |
" classProtocols "
|
|
2608 |
nil
|
|
2609 |
"
|
|
2610 |
classInstVarRefs
|
|
2611 |
classClassVarRefs
|
|
2612 |
classAllInstVarRefs
|
|
2613 |
classAllClassVarRefs
|
|
2614 |
nil
|
|
2615 |
classInstVarMods
|
|
2616 |
classClassVarMods
|
|
2617 |
classAllInstVarMods
|
|
2618 |
classAllClassVarMods
|
|
2619 |
"
|
|
2620 |
variables
|
|
2621 |
nil
|
|
2622 |
classNewClass
|
|
2623 |
classNewSubclass
|
|
2624 |
classRename
|
|
2625 |
classRemove)
|
|
2626 |
receiver:self
|
|
2627 |
for:classListView.
|
|
2628 |
|
|
2629 |
classListView middleButtonMenu:menu.
|
|
2630 |
|
|
2631 |
menu subMenuAt:#variables
|
|
2632 |
put:(PopUpMenu labels:(resources array:#(
|
|
2633 |
'instvar refs ...'
|
|
2634 |
'classvar refs ...'
|
|
2635 |
'all instvar refs ...'
|
|
2636 |
'all classvar refs ...'
|
|
2637 |
'-'
|
|
2638 |
'instvar mods ...'
|
|
2639 |
'classvar mods ...'
|
|
2640 |
'all instvar mods ...'
|
|
2641 |
'all classvar mods ...'
|
|
2642 |
))
|
|
2643 |
selectors:#(
|
|
2644 |
classInstVarRefs
|
|
2645 |
classClassVarRefs
|
|
2646 |
classAllInstVarRefs
|
|
2647 |
classAllClassVarRefs
|
|
2648 |
nil
|
|
2649 |
classInstVarMods
|
|
2650 |
classClassVarMods
|
|
2651 |
classAllInstVarMods
|
|
2652 |
classAllClassVarMods
|
|
2653 |
)
|
|
2654 |
receiver:self
|
|
2655 |
for:self
|
|
2656 |
|
|
2657 |
).
|
|
2658 |
!
|
|
2659 |
|
|
2660 |
doClassMenu:aBlock
|
|
2661 |
"a helper - check if class is selected and evaluate aBlock
|
|
2662 |
while showing waitCursor"
|
|
2663 |
|
|
2664 |
currentClass isNil ifTrue:[
|
|
2665 |
^ self warn:'select a class first'.
|
|
2666 |
].
|
|
2667 |
self withWaitCursorDo:aBlock
|
|
2668 |
!
|
|
2669 |
|
|
2670 |
doClassMenuWithSelection:aBlock
|
|
2671 |
"a helper - if there is a selection, which represents a classes name,
|
|
2672 |
evaluate aBlock, passing that class as argument.
|
|
2673 |
Otherwise, check if a class is selected and evaluate aBlock with the
|
|
2674 |
current class. Otherwise report an error."
|
|
2675 |
|
|
2676 |
|clsName cls isMeta w|
|
|
2677 |
|
|
2678 |
clsName := codeView selection.
|
|
2679 |
clsName notNil ifTrue:[
|
|
2680 |
clsName := clsName asString withoutSeparators.
|
|
2681 |
(clsName endsWith:'class') ifTrue:[
|
|
2682 |
isMeta := true.
|
|
2683 |
clsName := clsName copyTo:(clsName size - 5)
|
|
2684 |
] ifFalse:[
|
|
2685 |
isMeta := false
|
|
2686 |
].
|
|
2687 |
clsName knownAsSymbol ifTrue:[
|
|
2688 |
(Smalltalk includesKey:clsName asSymbol) ifTrue:[
|
|
2689 |
cls := Smalltalk at:clsName asSymbol.
|
|
2690 |
cls isBehavior ifTrue:[
|
|
2691 |
isMeta ifTrue:[
|
|
2692 |
cls := cls class
|
|
2693 |
].
|
|
2694 |
self withWaitCursorDo:[
|
|
2695 |
aBlock value:cls.
|
|
2696 |
].
|
|
2697 |
^ self
|
|
2698 |
] ifFalse:[
|
|
2699 |
w := clsName , ' is not a class'
|
|
2700 |
]
|
|
2701 |
] ifFalse:[
|
|
2702 |
w := clsName , ' is unknown'
|
|
2703 |
].
|
|
2704 |
self warn:w.
|
|
2705 |
^ self
|
|
2706 |
].
|
|
2707 |
].
|
|
2708 |
|
|
2709 |
currentClass isNil ifTrue:[
|
|
2710 |
^ self warn:'select a class first'.
|
|
2711 |
].
|
|
2712 |
self withWaitCursorDo:[aBlock value:currentClass]
|
|
2713 |
!
|
|
2714 |
|
|
2715 |
classSpawn
|
|
2716 |
"create a new SystemBrowser browsing current class,
|
|
2717 |
or if there is a selection, spawn a browser on the selected name."
|
|
2718 |
|
|
2719 |
|browser|
|
|
2720 |
|
|
2721 |
self doClassMenuWithSelection:[:cls |
|
|
2722 |
cls isMeta ifTrue:[
|
|
2723 |
Smalltalk allClassesDo:[:aClass |
|
|
2724 |
aClass class == cls ifTrue:[
|
|
2725 |
browser := self class browseClass:aClass.
|
|
2726 |
browser classProtocol.
|
|
2727 |
^ self
|
|
2728 |
].
|
|
2729 |
].
|
|
2730 |
self warn:'oops, no class for this metaclass'.
|
|
2731 |
^ self
|
|
2732 |
].
|
|
2733 |
self class browseClass:cls
|
|
2734 |
]
|
|
2735 |
!
|
|
2736 |
|
|
2737 |
classSpawnHierarchy
|
|
2738 |
"create a new HierarchyBrowser browsing current class"
|
|
2739 |
|
|
2740 |
self doClassMenuWithSelection:[:cls |
|
|
2741 |
self class browseClassHierarchy:cls
|
|
2742 |
]
|
|
2743 |
!
|
|
2744 |
|
|
2745 |
classSpawnSubclasses
|
|
2746 |
"create a new browser browsing current class's subclasses"
|
|
2747 |
|
|
2748 |
|subs|
|
|
2749 |
|
|
2750 |
self doClassMenuWithSelection:[:cls |
|
|
2751 |
subs := cls allSubclasses.
|
|
2752 |
(subs notNil and:[subs size ~~ 0]) ifTrue:[
|
|
2753 |
self class browseClasses:subs title:('subclasses of ' , cls name)
|
|
2754 |
]
|
|
2755 |
]
|
|
2756 |
!
|
|
2757 |
|
|
2758 |
classPrintOutFullProtocol
|
|
2759 |
|printStream|
|
|
2760 |
|
|
2761 |
self doClassMenu:[
|
|
2762 |
printStream := Printer new.
|
|
2763 |
currentClass printOutFullProtocolOn:printStream.
|
|
2764 |
printStream close
|
|
2765 |
]
|
|
2766 |
!
|
|
2767 |
|
|
2768 |
classPrintOutProtocol
|
|
2769 |
|printStream|
|
|
2770 |
|
|
2771 |
self doClassMenu:[
|
|
2772 |
printStream := Printer new.
|
|
2773 |
currentClass printOutProtocolOn:printStream.
|
|
2774 |
printStream close
|
|
2775 |
]
|
|
2776 |
!
|
|
2777 |
|
|
2778 |
classPrintOut
|
|
2779 |
|printStream|
|
|
2780 |
|
|
2781 |
self doClassMenu:[
|
|
2782 |
printStream := Printer new.
|
|
2783 |
currentClass printOutOn:printStream.
|
|
2784 |
printStream close
|
|
2785 |
]
|
|
2786 |
!
|
|
2787 |
|
|
2788 |
classBinaryFileOut
|
|
2789 |
self doClassMenu:[
|
|
2790 |
currentClass binaryFileOut
|
|
2791 |
]
|
|
2792 |
!
|
|
2793 |
|
|
2794 |
classFileOut
|
|
2795 |
self doClassMenu:[
|
|
2796 |
self label:('System Browser saving: ' , currentClass name).
|
|
2797 |
currentClass fileOut.
|
|
2798 |
self label:'System Browser'
|
|
2799 |
]
|
|
2800 |
!
|
|
2801 |
|
|
2802 |
classHierarchy
|
|
2803 |
"show current classes hierarchy in codeView"
|
|
2804 |
|
|
2805 |
|aStream|
|
|
2806 |
|
|
2807 |
self doClassMenu:[
|
|
2808 |
aStream := WriteStream on:(String new:200).
|
|
2809 |
actualClass printHierarchyOn:aStream.
|
|
2810 |
codeView contents:(aStream contents).
|
|
2811 |
codeView modified:false.
|
|
2812 |
codeView acceptAction:nil.
|
|
2813 |
codeView explainAction:nil.
|
|
2814 |
methodListView notNil ifTrue:[
|
|
2815 |
methodListView deselect
|
|
2816 |
]
|
|
2817 |
]
|
|
2818 |
!
|
|
2819 |
|
|
2820 |
classDefinition
|
|
2821 |
"show class definition in codeView and setup accept-action for
|
|
2822 |
class-definition change"
|
|
2823 |
|
|
2824 |
|aStream|
|
|
2825 |
|
|
2826 |
self doClassMenu:[
|
|
2827 |
aStream := WriteStream on:(String new:200).
|
|
2828 |
currentClass fileOutDefinitionOn:aStream.
|
|
2829 |
codeView contents:(aStream contents).
|
|
2830 |
codeView modified:false.
|
|
2831 |
codeView acceptAction:[:theCode |
|
|
2832 |
codeView cursor:Cursor execute.
|
|
2833 |
Object abortSignal catch:[
|
|
2834 |
(Compiler evaluate:theCode asString notifying:codeView)
|
|
2835 |
isBehavior ifTrue:[
|
|
2836 |
codeView modified:false.
|
|
2837 |
self classCategoryUpdate.
|
|
2838 |
self updateClassListWithScroll:false.
|
|
2839 |
]
|
|
2840 |
].
|
|
2841 |
codeView cursor:Cursor normal.
|
|
2842 |
].
|
|
2843 |
codeView explainAction:nil.
|
|
2844 |
methodListView notNil ifTrue:[
|
|
2845 |
methodListView deselect
|
|
2846 |
]
|
|
2847 |
]
|
|
2848 |
!
|
|
2849 |
|
|
2850 |
classClassInstVars
|
|
2851 |
"show class instance variables in codeView and setup accept-action
|
|
2852 |
for class-instvar-definition change"
|
|
2853 |
|
|
2854 |
|s|
|
|
2855 |
|
|
2856 |
self doClassMenu:[
|
|
2857 |
s := WriteStream on:(String new).
|
|
2858 |
currentClass fileOutClassInstVarDefinitionOn:s.
|
|
2859 |
codeView contents:(s contents).
|
|
2860 |
codeView modified:false.
|
|
2861 |
codeView acceptAction:[:theCode |
|
|
2862 |
codeView cursor:Cursor execute.
|
|
2863 |
Object abortSignal catch:[
|
|
2864 |
Compiler evaluate:theCode asString notifying:codeView.
|
|
2865 |
codeView modified:false.
|
|
2866 |
self updateClassList.
|
|
2867 |
].
|
|
2868 |
codeView cursor:Cursor normal.
|
|
2869 |
].
|
|
2870 |
codeView explainAction:nil.
|
|
2871 |
methodListView notNil ifTrue:[
|
|
2872 |
methodListView deselect
|
|
2873 |
]
|
|
2874 |
]
|
|
2875 |
!
|
|
2876 |
|
|
2877 |
classProtocols
|
|
2878 |
^ self
|
|
2879 |
!
|
|
2880 |
|
|
2881 |
classComment
|
|
2882 |
"show the classes comment in the codeView"
|
|
2883 |
|
|
2884 |
self doClassMenu:[
|
|
2885 |
codeView contents:(currentClass comment).
|
|
2886 |
codeView modified:false.
|
|
2887 |
codeView acceptAction:[:theCode |
|
|
2888 |
Object abortSignal catch:[
|
|
2889 |
currentClass comment:theCode asString.
|
|
2890 |
codeView modified:false.
|
|
2891 |
]
|
|
2892 |
].
|
|
2893 |
codeView explainAction:nil.
|
|
2894 |
methodListView notNil ifTrue:[
|
|
2895 |
methodListView deselect
|
|
2896 |
]
|
|
2897 |
]
|
|
2898 |
!
|
|
2899 |
|
|
2900 |
classInstVarRefsOrModsTitle:title mods:mods
|
|
2901 |
"show an enterbox for instvar to search for"
|
|
2902 |
|
|
2903 |
self doClassMenu:[
|
|
2904 |
self enterBoxForCodeSelectionTitle:title okText:'browse'.
|
|
2905 |
enterBox action:[:aString |
|
|
2906 |
self withWaitCursorDo:[
|
|
2907 |
self class browseInstRefsTo:aString
|
|
2908 |
in:(Array with:currentClass)
|
|
2909 |
modificationsOnly:mods
|
|
2910 |
]
|
|
2911 |
].
|
|
2912 |
enterBox showAtPointer
|
|
2913 |
]
|
|
2914 |
!
|
|
2915 |
|
|
2916 |
classInstVarRefs
|
|
2917 |
"show an enterbox for instVar to search for"
|
|
2918 |
|
|
2919 |
self classInstVarRefsOrModsTitle:'instance variable to browse references to:'
|
|
2920 |
mods:false
|
|
2921 |
!
|
|
2922 |
|
|
2923 |
classInstVarMods
|
|
2924 |
"show an enterbox for instVar to search for"
|
|
2925 |
|
|
2926 |
self classInstVarRefsOrModsTitle:'instance variable to browse modifications of:'
|
|
2927 |
mods:true
|
|
2928 |
!
|
|
2929 |
|
|
2930 |
classClassVarRefsOrModsTitle:title mods:mods
|
|
2931 |
"show an enterbox for classVar to search for"
|
|
2932 |
|
|
2933 |
self doClassMenu:[
|
|
2934 |
self enterBoxForCodeSelectionTitle:title okText:'browse'.
|
|
2935 |
enterBox action:[:aString |
|
|
2936 |
self withWaitCursorDo:[
|
|
2937 |
self class browseClassRefsTo:aString
|
|
2938 |
in:(Array with:currentClass)
|
|
2939 |
modificationsOnly:mods
|
|
2940 |
]
|
|
2941 |
].
|
|
2942 |
enterBox showAtPointer
|
|
2943 |
]
|
|
2944 |
!
|
|
2945 |
|
|
2946 |
classClassVarMods
|
|
2947 |
"show an enterbox for classVar to search for"
|
|
2948 |
|
|
2949 |
self classClassVarRefsOrModsTitle:'class variable to browse modifications of:'
|
|
2950 |
mods:true
|
|
2951 |
!
|
|
2952 |
|
|
2953 |
classClassVarRefs
|
|
2954 |
"show an enterbox for classVar to search for"
|
|
2955 |
|
|
2956 |
self classClassVarRefsOrModsTitle:'class variable to browse references to:'
|
|
2957 |
mods:false
|
|
2958 |
!
|
|
2959 |
|
|
2960 |
classAllClassOrInstVarRefsTitle:title access:access
|
|
2961 |
"show an enterbox for instVar to search for"
|
|
2962 |
|
|
2963 |
self doClassMenu:[
|
|
2964 |
self enterBoxForCodeSelectionTitle:title okText:'browse'.
|
|
2965 |
enterBox action:[:aVariableName |
|
|
2966 |
self withWaitCursorDo:[
|
|
2967 |
|homeClass|
|
|
2968 |
|
|
2969 |
homeClass := self findClassOfVariable:aVariableName
|
|
2970 |
accessWith:access.
|
|
2971 |
(self class) browseInstRefsTo:aVariableName
|
|
2972 |
under:homeClass
|
|
2973 |
modificationsOnly:false
|
|
2974 |
]
|
|
2975 |
].
|
|
2976 |
enterBox showAtPointer
|
|
2977 |
]
|
|
2978 |
!
|
|
2979 |
|
|
2980 |
classAllInstVarRefs
|
|
2981 |
"show an enterbox for instVar to search for"
|
|
2982 |
|
|
2983 |
self classAllClassOrInstVarRefsTitle:'instance variable to browse references to:'
|
|
2984 |
access:#instVarNames
|
|
2985 |
!
|
|
2986 |
|
|
2987 |
classAllClassVarRefs
|
|
2988 |
"show an enterbox for classVar to search for"
|
|
2989 |
|
|
2990 |
self classAllClassOrInstVarRefsTitle:'class variable to browse references to:'
|
|
2991 |
access:#classVarNames
|
|
2992 |
!
|
|
2993 |
|
|
2994 |
classAllInstOrClassVarModsTitle:title access:access
|
|
2995 |
"show an enterbox for instVar to search for"
|
|
2996 |
|
|
2997 |
self doClassMenu:[
|
|
2998 |
self enterBoxForCodeSelectionTitle:title okText:'browse'.
|
|
2999 |
enterBox action:[:aVariableName |
|
|
3000 |
self withWaitCursorDo:[
|
|
3001 |
|homeClass|
|
|
3002 |
|
|
3003 |
homeClass := self findClassOfVariable:aVariableName
|
|
3004 |
accessWith:access.
|
|
3005 |
(self class) browseInstRefsTo:aVariableName
|
|
3006 |
under:homeClass
|
|
3007 |
modificationsOnly:true
|
|
3008 |
]
|
|
3009 |
].
|
|
3010 |
enterBox showAtPointer
|
|
3011 |
]
|
|
3012 |
!
|
|
3013 |
|
|
3014 |
classAllInstVarMods
|
|
3015 |
"show an enterbox for instVar to search for"
|
|
3016 |
|
|
3017 |
self classAllInstOrClassVarModsTitle:'instance variable to browse modifications of:'
|
|
3018 |
access:#instVarNames.
|
|
3019 |
!
|
|
3020 |
|
|
3021 |
classAllClassVarMods
|
|
3022 |
"show an enterbox for classVar to search for"
|
|
3023 |
|
|
3024 |
self classAllInstOrClassVarModsTitle:'class variable to browse modifications of:'
|
|
3025 |
access:#classVarNames.
|
|
3026 |
!
|
|
3027 |
|
|
3028 |
classClassDefinitionTemplateFor:name in:cat
|
|
3029 |
"common helper for newClass and newSubclass
|
|
3030 |
- show a template to define class name in category cat"
|
|
3031 |
|
|
3032 |
currentMethodCategory := nil.
|
|
3033 |
currentMethod := nil.
|
|
3034 |
|
|
3035 |
classListView deselect.
|
|
3036 |
|
|
3037 |
fullClass ifFalse:[
|
|
3038 |
methodCategoryListView contents:nil.
|
|
3039 |
methodListView contents:nil
|
|
3040 |
].
|
|
3041 |
|
|
3042 |
codeView contents:(self templateFor:name in:cat).
|
|
3043 |
codeView modified:false.
|
|
3044 |
|
|
3045 |
codeView acceptAction:[:theCode |
|
|
3046 |
codeView cursor:Cursor execute.
|
|
3047 |
Object abortSignal catch:[
|
|
3048 |
|cl|
|
|
3049 |
|
|
3050 |
cl := (Compiler evaluate:theCode asString notifying:codeView).
|
|
3051 |
cl isBehavior ifTrue:[
|
|
3052 |
codeView modified:false.
|
|
3053 |
self classCategoryUpdate.
|
|
3054 |
self updateClassListWithScroll:false.
|
|
3055 |
self switchToClassNamed:(cl name)
|
|
3056 |
]
|
|
3057 |
].
|
|
3058 |
codeView cursor:(Cursor normal).
|
|
3059 |
].
|
|
3060 |
codeView explainAction:nil.
|
|
3061 |
self switchToClass:nil
|
|
3062 |
!
|
|
3063 |
|
|
3064 |
classNewClass
|
|
3065 |
"create a class-definition prototype in codeview"
|
|
3066 |
|
|
3067 |
|nm|
|
|
3068 |
|
|
3069 |
currentClass notNil ifTrue:[
|
|
3070 |
nm := currentClass superclass name
|
|
3071 |
] ifFalse:[
|
|
3072 |
nm := 'Object'
|
|
3073 |
].
|
|
3074 |
self classClassDefinitionTemplateFor:nm in:currentClassCategory
|
|
3075 |
!
|
|
3076 |
|
|
3077 |
classNewSubclass
|
|
3078 |
"create a subclass-definition prototype in codeview"
|
|
3079 |
|
|
3080 |
currentClass isNil ifTrue:[
|
|
3081 |
^ self warn:'select a class first'.
|
|
3082 |
].
|
|
3083 |
self classClassDefinitionTemplateFor:(currentClass name)
|
|
3084 |
in:(currentClass category)
|
|
3085 |
!
|
|
3086 |
|
|
3087 |
renameCurrentClassTo:aString
|
|
3088 |
"helper - do the rename"
|
|
3089 |
|
|
3090 |
self doClassMenu:[
|
|
3091 |
|oldName oldSym newSym|
|
|
3092 |
|
|
3093 |
oldName := currentClass name.
|
|
3094 |
oldSym := oldName asSymbol.
|
|
3095 |
"
|
|
3096 |
currentClass setName:aString.
|
|
3097 |
newSym := aString asSymbol.
|
|
3098 |
Smalltalk at:oldSym put:nil.
|
|
3099 |
Smalltalk removeKey:oldSym.
|
|
3100 |
Smalltalk at:newSym put:currentClass.
|
|
3101 |
"
|
|
3102 |
"
|
|
3103 |
currentClass renameTo:aString.
|
|
3104 |
"
|
|
3105 |
Smalltalk renameClass:currentClass to:aString.
|
|
3106 |
|
|
3107 |
self updateClassList.
|
|
3108 |
self updateMethodCategoryListWithScroll:false.
|
|
3109 |
self updateMethodListWithScroll:false.
|
|
3110 |
self withWaitCursorDo:[
|
|
3111 |
Transcript showCr:('searching for users of ' , oldSym); endEntry.
|
|
3112 |
self class browseReferendsOf:oldSym warnIfNone:false
|
|
3113 |
]
|
|
3114 |
]
|
|
3115 |
!
|
|
3116 |
|
|
3117 |
classRename
|
|
3118 |
"launch an enterBox for new name and query user"
|
|
3119 |
|
|
3120 |
currentClass isNil ifTrue:[
|
|
3121 |
^ self warn:'select a class first'.
|
|
3122 |
].
|
|
3123 |
self enterBoxTitle:(resources string:'rename %1 to:' with:currentClass name) okText:'rename'.
|
|
3124 |
enterBox initialText:(currentClass name).
|
|
3125 |
enterBox action:[:aString | self renameCurrentClassTo:aString].
|
|
3126 |
enterBox showAtPointer
|
|
3127 |
!
|
|
3128 |
|
|
3129 |
doRemoveCurrentClass
|
|
3130 |
"after querying user - do really remove current class
|
|
3131 |
and all subclasses"
|
|
3132 |
|
|
3133 |
self doClassMenu:[
|
|
3134 |
currentClass allSubclassesDo:[:aSubClass |
|
|
3135 |
Smalltalk removeClass:aSubClass
|
|
3136 |
].
|
|
3137 |
Smalltalk removeClass:currentClass.
|
|
3138 |
|
|
3139 |
self switchToClass:nil.
|
|
3140 |
Smalltalk changed.
|
|
3141 |
self updateClassList.
|
|
3142 |
|
|
3143 |
"if it was the last in its category, update class category list"
|
|
3144 |
"
|
|
3145 |
classListView numberOfLines == 0 ifTrue:[
|
|
3146 |
self updateClassCategoryListWithScroll:false
|
|
3147 |
].
|
|
3148 |
"
|
|
3149 |
methodCategoryListView notNil ifTrue:[methodCategoryListView contents:nil].
|
|
3150 |
methodListView notNil ifTrue:[methodListView contents:nil].
|
|
3151 |
codeView contents:nil.
|
|
3152 |
codeView modified:false
|
|
3153 |
]
|
|
3154 |
!
|
|
3155 |
|
|
3156 |
classRemove
|
|
3157 |
"user requested remove of current class and all subclasses -
|
|
3158 |
count subclasses and let user confirm removal."
|
|
3159 |
|
|
3160 |
|count t|
|
|
3161 |
|
|
3162 |
currentClass notNil ifTrue:[
|
|
3163 |
count := 0.
|
|
3164 |
currentClass allSubclassesDo:[:aSubClass |
|
|
3165 |
count := count + 1
|
|
3166 |
].
|
|
3167 |
t := 'remove ' , currentClass name.
|
|
3168 |
count ~~ 0 ifTrue:[
|
|
3169 |
t := t , '\(with ' , count printString.
|
|
3170 |
count == 1 ifTrue:[
|
|
3171 |
t := t , ' subclass'
|
|
3172 |
] ifFalse:[
|
|
3173 |
t := t , ' subclasses'
|
|
3174 |
].
|
|
3175 |
t := (t , ')') withCRs
|
|
3176 |
].
|
|
3177 |
questBox isNil ifTrue:[questBox := YesNoBox title:''].
|
|
3178 |
questBox title:t.
|
|
3179 |
questBox yesAction:[self doRemoveCurrentClass].
|
|
3180 |
questBox okText:(resources at:'remove').
|
|
3181 |
questBox noText:(resources at:'abort').
|
|
3182 |
questBox showAtPointer
|
|
3183 |
]
|
|
3184 |
! !
|
|
3185 |
|
|
3186 |
!SystemBrowser methodsFor:'method category menu'!
|
|
3187 |
|
|
3188 |
initializeMethodCategoryMenu
|
|
3189 |
|labels|
|
|
3190 |
|
|
3191 |
labels := resources array:#(
|
|
3192 |
'fileOut'
|
|
3193 |
'fileOut all'
|
|
3194 |
'printOut'
|
|
3195 |
'-'
|
|
3196 |
'spawn'
|
|
3197 |
'spawn category'
|
|
3198 |
'-'
|
|
3199 |
'find method here ...'
|
|
3200 |
'find method ...'
|
|
3201 |
'-'
|
|
3202 |
'new category ...'
|
|
3203 |
'copy category ...'
|
|
3204 |
'create access methods'
|
|
3205 |
'rename ...'
|
|
3206 |
'remove').
|
|
3207 |
|
|
3208 |
methodCategoryListView
|
|
3209 |
middleButtonMenu:(PopUpMenu
|
|
3210 |
labels:labels
|
|
3211 |
selectors:#(
|
|
3212 |
methodCategoryFileOut
|
|
3213 |
methodCategoryFileOutAll
|
|
3214 |
methodCategoryPrintOut
|
|
3215 |
nil
|
|
3216 |
methodCategorySpawn
|
|
3217 |
methodCategorySpawnCategory
|
|
3218 |
nil
|
|
3219 |
methodCategoryFindMethod
|
|
3220 |
methodCategoryFindAnyMethod
|
|
3221 |
nil
|
|
3222 |
methodCategoryNewCategory
|
|
3223 |
methodCategoryCopyCategory
|
|
3224 |
methodCategoryCreateAccessMethods
|
|
3225 |
methodCategoryRename
|
|
3226 |
methodCategoryRemove)
|
|
3227 |
receiver:self
|
|
3228 |
for:methodCategoryListView)
|
|
3229 |
!
|
|
3230 |
|
|
3231 |
switchToMethodNamed:matchString
|
|
3232 |
|aSelector method cat index classToSearch selectors|
|
|
3233 |
|
|
3234 |
currentClass notNil ifTrue:[
|
|
3235 |
showInstance ifTrue:[
|
|
3236 |
classToSearch := currentClass
|
|
3237 |
] ifFalse:[
|
|
3238 |
classToSearch := currentClass class
|
|
3239 |
].
|
|
3240 |
selectors := classToSearch selectorArray.
|
|
3241 |
|
|
3242 |
((matchString ~= '*') and:[matchString includesMatchCharacters]) ifTrue:[
|
|
3243 |
index := selectors findFirst:[:element | matchString match:element]
|
|
3244 |
] ifFalse:[
|
|
3245 |
index := selectors indexOf:matchString
|
|
3246 |
].
|
|
3247 |
|
|
3248 |
(index ~~ 0) ifTrue:[
|
|
3249 |
aSelector := selectors at:index.
|
|
3250 |
method := classToSearch methodArray at:index.
|
|
3251 |
cat := method category.
|
|
3252 |
cat isNil ifTrue:[cat := '* all *'].
|
|
3253 |
methodCategoryListView selectElement:cat.
|
|
3254 |
currentMethodCategory := cat.
|
|
3255 |
self methodCategorySelectionChanged.
|
|
3256 |
|
|
3257 |
currentMethod := classToSearch compiledMethodAt:aSelector.
|
|
3258 |
methodListView selectElement:aSelector.
|
|
3259 |
self methodSelectionChanged
|
|
3260 |
]
|
|
3261 |
]
|
|
3262 |
!
|
|
3263 |
|
|
3264 |
switchToAnyMethodNamed:aString
|
|
3265 |
|aSelector classToStartSearch aClass nm|
|
|
3266 |
|
|
3267 |
aSelector := aString asSymbol.
|
|
3268 |
currentClass isNil ifTrue:[
|
|
3269 |
currentClassHierarchy notNil ifTrue:[
|
|
3270 |
classToStartSearch := currentClassHierarchy
|
|
3271 |
]
|
|
3272 |
] ifFalse:[
|
|
3273 |
classToStartSearch := currentClass
|
|
3274 |
].
|
|
3275 |
classToStartSearch notNil ifTrue:[
|
|
3276 |
showInstance ifFalse:[
|
|
3277 |
classToStartSearch := classToStartSearch class
|
|
3278 |
].
|
|
3279 |
aClass := classToStartSearch whichClassImplements:aSelector.
|
|
3280 |
aClass notNil ifTrue:[
|
|
3281 |
nm := aClass name.
|
|
3282 |
showInstance ifFalse:[
|
|
3283 |
((nm ~= 'Metaclass') and:[nm endsWith:'class']) ifTrue:[
|
|
3284 |
nm := nm copyTo:(nm size - 5)
|
|
3285 |
]
|
|
3286 |
].
|
|
3287 |
self switchToClassNamed:nm.
|
|
3288 |
self switchToMethodNamed:aString
|
|
3289 |
]
|
|
3290 |
]
|
|
3291 |
!
|
|
3292 |
|
|
3293 |
copyMethodsFromClass:aClassName
|
|
3294 |
|class|
|
|
3295 |
|
|
3296 |
currentClass notNil ifTrue:[
|
|
3297 |
Symbol hasInterned:aClassName ifTrue:[:sym |
|
|
3298 |
(Smalltalk includesKey:sym) ifTrue:[
|
|
3299 |
class := Smalltalk at:sym
|
|
3300 |
].
|
|
3301 |
].
|
|
3302 |
class isBehavior ifFalse:[
|
|
3303 |
self warn:(resources string:'no class named %1' with:aClassName).
|
|
3304 |
^ self
|
|
3305 |
].
|
|
3306 |
|
|
3307 |
showInstance ifFalse:[
|
|
3308 |
class := class class
|
|
3309 |
].
|
|
3310 |
|
|
3311 |
"show enterbox for category to copy from"
|
|
3312 |
|
|
3313 |
self enterBoxTitle:'name of category to copy from (matchpattern allowed, * for all):'
|
|
3314 |
okText:'copy'.
|
|
3315 |
enterBox action:[:aString | self copyMethodsFromClass:class category:aString].
|
|
3316 |
enterBox showAtPointer
|
|
3317 |
]
|
|
3318 |
!
|
|
3319 |
|
|
3320 |
copyMethodsFromClass:class category:category
|
|
3321 |
|source|
|
|
3322 |
|
|
3323 |
currentClass notNil ifTrue:[
|
|
3324 |
codeView abortAction:[^ self].
|
|
3325 |
class methodArray do:[:aMethod |
|
|
3326 |
(category match:aMethod category) ifTrue:[
|
|
3327 |
source := aMethod source.
|
|
3328 |
codeView contents:source.
|
|
3329 |
codeView modified:false.
|
|
3330 |
actualClass compiler compile:source
|
|
3331 |
forClass:actualClass
|
|
3332 |
inCategory:aMethod category
|
|
3333 |
notifying:codeView.
|
|
3334 |
self updateMethodCategoryListWithScroll:false.
|
|
3335 |
self updateMethodListWithScroll:false.
|
|
3336 |
]
|
|
3337 |
]
|
|
3338 |
]
|
|
3339 |
!
|
|
3340 |
|
|
3341 |
methodCategoryFindMethod
|
|
3342 |
self enterBoxForSearchSelectorTitle:'method selector to search for:'.
|
|
3343 |
enterBox action:[:aString | self switchToMethodNamed:aString].
|
|
3344 |
enterBox showAtPointer
|
|
3345 |
!
|
|
3346 |
|
|
3347 |
methodCategoryFindAnyMethod
|
|
3348 |
self enterBoxForSearchSelectorTitle:'method selector to search for:'.
|
|
3349 |
enterBox action:[:aString | self switchToAnyMethodNamed:aString].
|
|
3350 |
enterBox showAtPointer
|
|
3351 |
!
|
|
3352 |
|
|
3353 |
methodCategoryPrintOut
|
|
3354 |
|printStream|
|
|
3355 |
|
|
3356 |
currentClass isNil ifTrue:[
|
|
3357 |
^ self warn:'select a class first'.
|
|
3358 |
].
|
|
3359 |
currentMethodCategory isNil ifTrue:[
|
|
3360 |
^ self warn:'select a method category first'.
|
|
3361 |
].
|
|
3362 |
currentMethodCategory notNil ifTrue:[
|
|
3363 |
self withWaitCursorDo:[
|
|
3364 |
printStream := Printer new.
|
|
3365 |
actualClass printOutCategory:currentMethodCategory on:printStream.
|
|
3366 |
printStream close
|
|
3367 |
]
|
|
3368 |
]
|
|
3369 |
!
|
|
3370 |
|
|
3371 |
methodCategoryFileOut
|
|
3372 |
"fileOut all methods in the selected methodcategory of
|
|
3373 |
the current class"
|
|
3374 |
|
|
3375 |
currentClass isNil ifTrue:[
|
|
3376 |
^ self warn:'select a class first'.
|
|
3377 |
].
|
|
3378 |
currentMethodCategory isNil ifTrue:[
|
|
3379 |
^ self warn:'select a method category first'.
|
|
3380 |
].
|
|
3381 |
currentMethodCategory notNil ifTrue:[
|
|
3382 |
self withWaitCursorDo:[
|
|
3383 |
self label:('System Browser saving: ' , currentClass name , '-' , currentMethodCategory).
|
|
3384 |
actualClass fileOutCategory:currentMethodCategory.
|
|
3385 |
self label:'System Browser'.
|
|
3386 |
]
|
|
3387 |
]
|
|
3388 |
!
|
|
3389 |
|
|
3390 |
methodCategoryFileOutAll
|
|
3391 |
"fileOut all methods in the selected methodcategory of
|
|
3392 |
the current class"
|
|
3393 |
|
|
3394 |
|fileName project outStream hasMethodsInThisCategory|
|
|
3395 |
|
|
3396 |
currentMethodCategory isNil ifTrue:[
|
|
3397 |
^ self warn:'select a method category first'.
|
|
3398 |
].
|
|
3399 |
fileName := currentMethodCategory , '.st'.
|
|
3400 |
fileName replaceAll:Character space by:$_.
|
|
3401 |
Project notNil ifTrue:[
|
|
3402 |
project := Project current.
|
|
3403 |
project notNil ifTrue:[
|
|
3404 |
fileName := project directory , Filename separator asString , fileName.
|
|
3405 |
].
|
|
3406 |
].
|
|
3407 |
outStream := FileStream newFileNamed:fileName.
|
|
3408 |
outStream isNil ifTrue:[
|
|
3409 |
^ self warn:(resources string:'cannot create: %1' with:fileName)
|
|
3410 |
].
|
|
3411 |
self withWaitCursorDo:[
|
|
3412 |
self label:('System Browser saving: ' , currentMethodCategory).
|
|
3413 |
Smalltalk allClassesDo:[:class |
|
|
3414 |
hasMethodsInThisCategory := false.
|
|
3415 |
class methodArray do:[:method |
|
|
3416 |
method category = currentMethodCategory ifTrue:[
|
|
3417 |
hasMethodsInThisCategory := true
|
|
3418 |
]
|
|
3419 |
].
|
|
3420 |
hasMethodsInThisCategory ifTrue:[
|
|
3421 |
class fileOutCategory:currentMethodCategory on:outStream.
|
|
3422 |
outStream cr
|
|
3423 |
].
|
|
3424 |
hasMethodsInThisCategory := false.
|
|
3425 |
class class methodArray do:[:method |
|
|
3426 |
method category = currentMethodCategory ifTrue:[
|
|
3427 |
hasMethodsInThisCategory := true
|
|
3428 |
]
|
|
3429 |
].
|
|
3430 |
hasMethodsInThisCategory ifTrue:[
|
|
3431 |
class class fileOutCategory:currentMethodCategory on:outStream.
|
|
3432 |
outStream cr
|
|
3433 |
]
|
|
3434 |
].
|
|
3435 |
outStream close.
|
|
3436 |
self label:'System Browser'.
|
|
3437 |
].
|
|
3438 |
!
|
|
3439 |
|
|
3440 |
methodCategorySpawn
|
|
3441 |
"create a new SystemBrowser browsing current method category"
|
|
3442 |
|
|
3443 |
currentMethodCategory notNil ifTrue:[
|
|
3444 |
self withWaitCursorDo:[
|
|
3445 |
self class browseClass:actualClass
|
|
3446 |
methodCategory:currentMethodCategory
|
|
3447 |
]
|
|
3448 |
]
|
|
3449 |
!
|
|
3450 |
|
|
3451 |
methodCategorySpawnCategory
|
|
3452 |
"create a new SystemBrowser browsing all methods from all
|
|
3453 |
classes with same category as current method category"
|
|
3454 |
|
|
3455 |
self enterBoxForMethodCategory:'category to browse methods:'.
|
|
3456 |
enterBox action:[:aString | self withWaitCursorDo:[
|
|
3457 |
self class browseMethodCategory:aString
|
|
3458 |
]
|
|
3459 |
].
|
|
3460 |
enterBox showAtPointer
|
|
3461 |
!
|
|
3462 |
|
|
3463 |
newMethodCategory:aString
|
|
3464 |
|categories|
|
|
3465 |
|
|
3466 |
currentClass isNil ifTrue:[
|
|
3467 |
^ self warn:'select/create a class first'.
|
|
3468 |
].
|
|
3469 |
categories := methodCategoryListView list.
|
|
3470 |
categories isNil ifTrue:[categories := Text new].
|
|
3471 |
(categories includes:aString) ifFalse:[
|
|
3472 |
categories add:aString.
|
|
3473 |
categories sort.
|
|
3474 |
methodCategoryListView contents:categories
|
|
3475 |
].
|
|
3476 |
currentMethodCategory := aString.
|
|
3477 |
self methodCategorySelectionChanged
|
|
3478 |
!
|
|
3479 |
|
|
3480 |
methodCategoryNewCategory
|
|
3481 |
"show the enter box to add a new method category"
|
|
3482 |
|
|
3483 |
|someCategories existingCategories|
|
|
3484 |
|
|
3485 |
"a tiny little goody here ..."
|
|
3486 |
showInstance ifTrue:[
|
|
3487 |
someCategories := #('accessing'
|
|
3488 |
'initialization'
|
|
3489 |
'private'
|
|
3490 |
'printing & storing'
|
|
3491 |
'queries'
|
|
3492 |
'testing'
|
|
3493 |
)
|
|
3494 |
] ifFalse:[
|
|
3495 |
someCategories := #(
|
|
3496 |
'documentation'
|
|
3497 |
'initialization'
|
|
3498 |
'instance creation'
|
|
3499 |
).
|
|
3500 |
].
|
|
3501 |
existingCategories := methodCategoryListView list.
|
|
3502 |
existingCategories notNil ifTrue:[
|
|
3503 |
someCategories := someCategories select:[:cat | (existingCategories includes:cat) not].
|
|
3504 |
].
|
|
3505 |
|
|
3506 |
self listBoxTitle:(resources at:'name of new method category:')
|
|
3507 |
okText:(resources at:'create')
|
|
3508 |
list:someCategories.
|
|
3509 |
selectBox action:[:aString | self newMethodCategory:aString].
|
|
3510 |
selectBox showAtPointer
|
|
3511 |
!
|
|
3512 |
|
|
3513 |
methodCategoryCreateAccessMethods
|
|
3514 |
"create access methods for all instvars"
|
|
3515 |
|
|
3516 |
|source|
|
|
3517 |
|
|
3518 |
currentClass isNil ifTrue:[^ self].
|
|
3519 |
showInstance ifFalse:[
|
|
3520 |
self warn:(resources string:'select instance - and try again').
|
|
3521 |
^ self.
|
|
3522 |
].
|
|
3523 |
self withWaitCursorDo:[
|
|
3524 |
currentClass instVarNames do:[:name |
|
|
3525 |
"check, if method is not already present"
|
|
3526 |
(currentClass implements:(name asSymbol)) ifFalse:[
|
|
3527 |
source := (name , '\ "return ' , name , '"\\ ^ ' , name) withCRs.
|
|
3528 |
Compiler compile:source forClass:currentClass inCategory:'accessing'.
|
|
3529 |
] ifTrue:[
|
|
3530 |
Transcript showCr:'method ''', name , ''' already present'
|
|
3531 |
].
|
|
3532 |
(currentClass implements:((name , ':') asSymbol)) ifFalse:[
|
|
3533 |
source := (name , ':something\ "set ' , name , '"\\ ' , name , ' := something.') withCRs.
|
|
3534 |
Compiler compile:source forClass:currentClass inCategory:'accessing'.
|
|
3535 |
] ifTrue:[
|
|
3536 |
Transcript showCr:'method ''', name , ':'' already present'
|
|
3537 |
].
|
|
3538 |
].
|
|
3539 |
self updateMethodCategoryListWithScroll:false.
|
|
3540 |
self updateMethodListWithScroll:false
|
|
3541 |
]
|
|
3542 |
!
|
|
3543 |
|
|
3544 |
methodCategoryCopyCategory
|
|
3545 |
"show the enter box to copy from an existing method category"
|
|
3546 |
|
|
3547 |
|title|
|
|
3548 |
|
|
3549 |
showInstance ifTrue:[
|
|
3550 |
title := 'class to copy instance method category from:'
|
|
3551 |
] ifFalse:[
|
|
3552 |
title := 'class to copy class method category from:'
|
|
3553 |
].
|
|
3554 |
|
|
3555 |
self listBoxTitle:title
|
|
3556 |
okText:'ok'
|
|
3557 |
list:(Smalltalk allClasses collect:[:cls | cls name]) asArray sort.
|
|
3558 |
|
|
3559 |
selectBox action:[:aString | self copyMethodsFromClass:aString].
|
|
3560 |
selectBox showAtPointer
|
|
3561 |
!
|
|
3562 |
|
|
3563 |
renameCurrentMethodCategoryTo:aString
|
|
3564 |
"helper - do the rename"
|
|
3565 |
|
|
3566 |
currentMethodCategory notNil ifTrue:[
|
|
3567 |
actualClass renameCategory:currentMethodCategory to:aString.
|
|
3568 |
|
|
3569 |
"/ actualClass methodArray do:[:aMethod |
|
|
3570 |
"/ aMethod category = currentMethodCategory ifTrue:[
|
|
3571 |
"/ aMethod category:aString
|
|
3572 |
"/ ]
|
|
3573 |
"/ ].
|
|
3574 |
currentMethodCategory := aString.
|
|
3575 |
currentMethod := nil.
|
|
3576 |
self updateMethodCategoryList.
|
|
3577 |
self updateMethodListWithScroll:false
|
|
3578 |
]
|
|
3579 |
!
|
|
3580 |
|
|
3581 |
methodCategoryRename
|
|
3582 |
"launch an enterBox to rename current method category"
|
|
3583 |
|
|
3584 |
currentMethodCategory isNil ifTrue:[
|
|
3585 |
^ self warn:'select a method category first'.
|
|
3586 |
].
|
|
3587 |
|
|
3588 |
self enterBoxTitle:(resources string:'rename method category %1 to:' with:currentMethodCategory)
|
|
3589 |
okText:(resources at:'rename').
|
|
3590 |
enterBox initialText:currentMethodCategory.
|
|
3591 |
enterBox action:[:aString | self renameCurrentMethodCategoryTo:aString].
|
|
3592 |
enterBox showAtPointer
|
|
3593 |
!
|
|
3594 |
|
|
3595 |
doMethodCategoryRemove
|
|
3596 |
"actually remove all methods from current method category"
|
|
3597 |
|
|
3598 |
currentMethodCategory notNil ifTrue:[
|
|
3599 |
actualClass methodArray do:[:aMethod |
|
|
3600 |
(aMethod category = currentMethodCategory) ifTrue:[
|
|
3601 |
actualClass
|
|
3602 |
removeSelector:(actualClass selectorForMethod:aMethod)
|
|
3603 |
]
|
|
3604 |
].
|
|
3605 |
currentMethodCategory := nil.
|
|
3606 |
currentMethod := nil.
|
|
3607 |
self updateMethodCategoryList.
|
|
3608 |
self updateMethodList
|
|
3609 |
]
|
|
3610 |
!
|
|
3611 |
|
|
3612 |
methodCategoryRemove
|
|
3613 |
"show number of methods to remove and query user"
|
|
3614 |
|
|
3615 |
|count t|
|
|
3616 |
|
|
3617 |
currentMethodCategory notNil ifTrue:[
|
|
3618 |
count := 0.
|
|
3619 |
actualClass methodArray do:[:aMethod |
|
|
3620 |
(aMethod category = currentMethodCategory) ifTrue:[
|
|
3621 |
count := count + 1
|
|
3622 |
]
|
|
3623 |
].
|
|
3624 |
(count == 0) ifTrue:[
|
|
3625 |
currentMethodCategory := nil.
|
|
3626 |
currentMethod := nil.
|
|
3627 |
self updateMethodCategoryListWithScroll:false.
|
|
3628 |
self updateMethodList
|
|
3629 |
] ifFalse:[
|
|
3630 |
(count == 1) ifTrue:[
|
|
3631 |
t := resources string:'remove %1 ?\(with 1 method)' with:currentMethodCategory
|
|
3632 |
] ifFalse:[
|
|
3633 |
t := resources string:'remove %1 ?\(with %2 methods)' with:currentMethodCategory
|
|
3634 |
with:count printString.
|
|
3635 |
].
|
|
3636 |
t := t withCRs.
|
|
3637 |
|
|
3638 |
questBox isNil ifTrue:[questBox := YesNoBox title:''].
|
|
3639 |
questBox title:t.
|
|
3640 |
questBox yesAction:[self doMethodCategoryRemove].
|
|
3641 |
questBox okText:(resources at:'remove').
|
|
3642 |
questBox noText:(resources at:'abort').
|
|
3643 |
questBox showAtPointer
|
|
3644 |
]
|
|
3645 |
]
|
|
3646 |
! !
|
|
3647 |
|
|
3648 |
!SystemBrowser methodsFor:'method menu'!
|
|
3649 |
|
|
3650 |
initializeMethodMenu
|
|
3651 |
|labels|
|
|
3652 |
|
|
3653 |
labels := resources array:#(
|
|
3654 |
'fileOut'
|
|
3655 |
'printOut'
|
|
3656 |
'-'
|
|
3657 |
'spawn'
|
|
3658 |
'-'
|
|
3659 |
'senders ...'
|
|
3660 |
'implementors ...'
|
|
3661 |
'globals ...'
|
|
3662 |
"
|
|
3663 |
'strings ...'
|
|
3664 |
'apropos ...'
|
|
3665 |
"
|
|
3666 |
'-'
|
|
3667 |
'local senders ...'
|
|
3668 |
'local implementors ...'
|
|
3669 |
"
|
|
3670 |
'local strings ...'
|
|
3671 |
"
|
|
3672 |
'-'
|
|
3673 |
'breakpoint'
|
|
3674 |
'trace'
|
|
3675 |
'trace sender'
|
|
3676 |
'-'
|
|
3677 |
'new method'
|
|
3678 |
'change category ...'
|
|
3679 |
'remove').
|
|
3680 |
|
|
3681 |
methodListView
|
|
3682 |
middleButtonMenu:(PopUpMenu
|
|
3683 |
labels:labels
|
|
3684 |
selectors:#(methodFileOut
|
|
3685 |
methodPrintOut
|
|
3686 |
nil
|
|
3687 |
methodSpawn
|
|
3688 |
nil
|
|
3689 |
methodSenders
|
|
3690 |
methodImplementors
|
|
3691 |
methodGlobalReferends
|
|
3692 |
"
|
|
3693 |
methodStringSearch
|
|
3694 |
methodAproposSearch
|
|
3695 |
"
|
|
3696 |
nil
|
|
3697 |
methodLocalSenders
|
|
3698 |
methodLocalImplementors
|
|
3699 |
"
|
|
3700 |
methodLocalStringSearch
|
|
3701 |
"
|
|
3702 |
nil
|
|
3703 |
methodBreakPoint
|
|
3704 |
methodTrace
|
|
3705 |
methodTraceSender
|
|
3706 |
nil
|
|
3707 |
methodNewMethod
|
|
3708 |
methodChangeCategory
|
|
3709 |
methodRemove)
|
|
3710 |
receiver:self
|
|
3711 |
for:methodListView)
|
|
3712 |
!
|
|
3713 |
|
|
3714 |
initializeMethodMenu2
|
|
3715 |
|labels|
|
|
3716 |
|
|
3717 |
methodListView isNil ifTrue:[^ self].
|
|
3718 |
labels := resources array:#(
|
|
3719 |
'fileOut'
|
|
3720 |
'printOut'
|
|
3721 |
'-'
|
|
3722 |
'spawn'
|
|
3723 |
'-'
|
|
3724 |
'senders ...'
|
|
3725 |
'implementors ...'
|
|
3726 |
'globals ...'
|
|
3727 |
"
|
|
3728 |
'strings ...'
|
|
3729 |
'apropos ...'
|
|
3730 |
"
|
|
3731 |
'-'
|
|
3732 |
'local senders ...'
|
|
3733 |
'local implementors ...'
|
|
3734 |
"
|
|
3735 |
'local strings ...'
|
|
3736 |
"
|
|
3737 |
'-'
|
|
3738 |
'remove break/trace'
|
|
3739 |
'-'
|
|
3740 |
'new method'
|
|
3741 |
'change category ...'
|
|
3742 |
'remove').
|
|
3743 |
|
|
3744 |
methodListView
|
|
3745 |
middleButtonMenu:(PopUpMenu
|
|
3746 |
labels:labels
|
|
3747 |
selectors:#(methodFileOut
|
|
3748 |
methodPrintOut
|
|
3749 |
nil
|
|
3750 |
methodSpawn
|
|
3751 |
nil
|
|
3752 |
methodSenders
|
|
3753 |
methodImplementors
|
|
3754 |
methodGlobalReferends
|
|
3755 |
"
|
|
3756 |
methodStringSearch
|
|
3757 |
methodAproposSearch
|
|
3758 |
"
|
|
3759 |
nil
|
|
3760 |
methodLocalSenders
|
|
3761 |
methodLocalImplementors
|
|
3762 |
"
|
|
3763 |
methodLocalStringSearch
|
|
3764 |
"
|
|
3765 |
nil
|
|
3766 |
methodRemoveBreakOrTrace
|
|
3767 |
nil
|
|
3768 |
methodNewMethod
|
|
3769 |
methodChangeCategory
|
|
3770 |
methodRemove)
|
|
3771 |
receiver:self
|
|
3772 |
for:methodListView)
|
|
3773 |
!
|
|
3774 |
|
|
3775 |
methodPrintOut
|
|
3776 |
"print out the current method"
|
|
3777 |
|
|
3778 |
|printStream|
|
|
3779 |
|
|
3780 |
currentMethod isNil ifTrue:[
|
|
3781 |
^ self warn:'select a method first'.
|
|
3782 |
].
|
|
3783 |
printStream := Printer new.
|
|
3784 |
actualClass printOutSource:currentMethod source on:printStream.
|
|
3785 |
printStream close
|
|
3786 |
!
|
|
3787 |
|
|
3788 |
methodFileOut
|
|
3789 |
"file out the current method"
|
|
3790 |
|
|
3791 |
currentMethod isNil ifTrue:[
|
|
3792 |
^ self warn:'select a method first'.
|
|
3793 |
].
|
|
3794 |
self label:'System Browser saving'.
|
|
3795 |
actualClass fileOutMethod:currentMethod.
|
|
3796 |
self label:'System Browser'.
|
|
3797 |
!
|
|
3798 |
|
|
3799 |
methodImplementors
|
|
3800 |
"launch an enterBox for selector to search for"
|
|
3801 |
|
|
3802 |
self enterBoxForBrowseSelectorTitle:'selector to browse implementors of:'.
|
|
3803 |
enterBox action:[:aString | self withWaitCursorDo:[
|
|
3804 |
self class browseImplementorsOf:aString
|
|
3805 |
]
|
|
3806 |
].
|
|
3807 |
enterBox showAtPointer
|
|
3808 |
!
|
|
3809 |
|
|
3810 |
methodLocalImplementors
|
|
3811 |
"launch an enterBox for selector to search for"
|
|
3812 |
|
|
3813 |
currentClass isNil ifTrue:[
|
|
3814 |
^ self warn:'select a class first'.
|
|
3815 |
].
|
|
3816 |
|
|
3817 |
self enterBoxForBrowseSelectorTitle:'selector to browse local implementors of:'.
|
|
3818 |
enterBox action:[:aString | self withWaitCursorDo:[
|
|
3819 |
self class browseImplementorsOf:aString under:currentClass
|
|
3820 |
]
|
|
3821 |
].
|
|
3822 |
enterBox showAtPointer
|
|
3823 |
!
|
|
3824 |
|
|
3825 |
methodSenders
|
|
3826 |
"launch an enterBox for selector to search for"
|
|
3827 |
|
|
3828 |
self enterBoxForBrowseSelectorTitle:'selector to browse senders of:'.
|
|
3829 |
enterBox action:[:aString | self withWaitCursorDo:[
|
|
3830 |
self class browseAllCallsOn:aString
|
|
3831 |
]
|
|
3832 |
].
|
|
3833 |
enterBox showAtPointer
|
|
3834 |
!
|
|
3835 |
|
|
3836 |
methodLocalSenders
|
|
3837 |
"launch an enterBox for selector to search for in current class & subclasses"
|
|
3838 |
|
|
3839 |
currentClass isNil ifTrue:[
|
|
3840 |
^ self warn:'select a class first'.
|
|
3841 |
].
|
|
3842 |
self enterBoxForBrowseSelectorTitle:'selector to browse local senderss of:'.
|
|
3843 |
enterBox action:[:aString | self withWaitCursorDo:[
|
|
3844 |
self class browseCallsOn:aString under:currentClass
|
|
3845 |
]
|
|
3846 |
].
|
|
3847 |
enterBox showAtPointer
|
|
3848 |
!
|
|
3849 |
|
|
3850 |
methodGlobalReferends
|
|
3851 |
"launch an enterBox for global symbol to search for"
|
|
3852 |
|
|
3853 |
self enterBoxForBrowseTitle:'global variable to browse users of:'.
|
|
3854 |
enterBox action:[:aString | self withWaitCursorDo:[
|
|
3855 |
self class browseReferendsOf:aString asSymbol
|
|
3856 |
]
|
|
3857 |
].
|
|
3858 |
enterBox showAtPointer
|
|
3859 |
!
|
|
3860 |
|
|
3861 |
methodStringSearch
|
|
3862 |
"launch an enterBox for (sub)-string to search for"
|
|
3863 |
|
|
3864 |
self enterBoxForBrowseSelectorTitle:'string / matchString to search for:'.
|
|
3865 |
enterBox action:[:aString | self withWaitCursorDo:[
|
|
3866 |
self class browseForString:aString
|
|
3867 |
]
|
|
3868 |
].
|
|
3869 |
enterBox showAtPointer
|
|
3870 |
!
|
|
3871 |
|
|
3872 |
methodLocalStringSearch
|
|
3873 |
"launch an enterBox for (sub)-string to search for"
|
|
3874 |
|
|
3875 |
currentClass isNil ifTrue:[
|
|
3876 |
^ self warn:'select a class first'.
|
|
3877 |
].
|
|
3878 |
self enterBoxForBrowseSelectorTitle:'string / matchString to search for locally:'.
|
|
3879 |
enterBox action:[:aString | self withWaitCursorDo:[
|
|
3880 |
self class browseForString:aString in:(currentClass withAllSubclasses)
|
|
3881 |
]
|
|
3882 |
].
|
|
3883 |
enterBox showAtPointer
|
|
3884 |
!
|
|
3885 |
|
|
3886 |
methodAproposSearch
|
|
3887 |
"launch an enterBox for a keyword search"
|
|
3888 |
|
|
3889 |
self enterBoxForBrowseSelectorTitle:'keyword to search for:'.
|
|
3890 |
enterBox action:[:aString | self withWaitCursorDo:[
|
|
3891 |
self class aproposSearch:aString
|
|
3892 |
]
|
|
3893 |
].
|
|
3894 |
enterBox showAtPointer
|
|
3895 |
!
|
|
3896 |
|
|
3897 |
methodSpawn
|
|
3898 |
"create a new SystemBrowser browsing current method,
|
|
3899 |
or if the current selection is of the form 'class>>selector', spwan
|
|
3900 |
a browser on that method."
|
|
3901 |
|
|
3902 |
|s sel clsName cls browseMeta w sep|
|
|
3903 |
|
|
3904 |
sel := codeView selection.
|
|
3905 |
sel notNil ifTrue:[
|
|
3906 |
sel := sel asString withoutSeparators.
|
|
3907 |
('*>>*' match:sel) ifTrue:[
|
|
3908 |
sep := $>
|
|
3909 |
] ifFalse:[
|
|
3910 |
('* *' match:sel) ifTrue:[
|
|
3911 |
sep := Character space
|
|
3912 |
]
|
|
3913 |
].
|
|
3914 |
sep notNil ifTrue:[
|
|
3915 |
s := ReadStream on:sel.
|
|
3916 |
clsName := s upTo:sep.
|
|
3917 |
[s peek == sep] whileTrue:[s next].
|
|
3918 |
sel := s upToEnd.
|
|
3919 |
(clsName endsWith:'class') ifTrue:[
|
|
3920 |
browseMeta := true.
|
|
3921 |
clsName := clsName copyTo:(clsName size - 5)
|
|
3922 |
] ifFalse:[
|
|
3923 |
browseMeta := false
|
|
3924 |
].
|
|
3925 |
(clsName knownAsSymbol and:[sel knownAsSymbol]) ifTrue:[
|
|
3926 |
(Smalltalk includesKey:clsName asSymbol) ifTrue:[
|
|
3927 |
cls := Smalltalk at:clsName asSymbol.
|
|
3928 |
browseMeta ifTrue:[
|
|
3929 |
cls := cls class
|
|
3930 |
].
|
|
3931 |
cls isBehavior ifFalse:[
|
|
3932 |
cls := cls class
|
|
3933 |
].
|
|
3934 |
cls isBehavior ifTrue:[
|
|
3935 |
(cls implements:sel asSymbol) ifTrue:[
|
|
3936 |
self withWaitCursorDo:[
|
|
3937 |
self class browseClass:cls selector:sel asSymbol
|
|
3938 |
].
|
|
3939 |
^ self
|
|
3940 |
] ifFalse:[
|
|
3941 |
(cls class implements:sel asSymbol) ifTrue:[
|
|
3942 |
self withWaitCursorDo:[
|
|
3943 |
self class browseClass:cls class selector:sel asSymbol
|
|
3944 |
].
|
|
3945 |
^ self
|
|
3946 |
] ifFalse:[
|
|
3947 |
w := clsName , ' does not implement #' , sel
|
|
3948 |
]
|
|
3949 |
]
|
|
3950 |
] ifFalse:[
|
|
3951 |
w := clsName , ' is not a class'
|
|
3952 |
]
|
|
3953 |
] ifFalse:[
|
|
3954 |
w := clsName , ' is unknown'
|
|
3955 |
]
|
|
3956 |
] ifFalse:[
|
|
3957 |
w := clsName , ' and/or ' , sel , ' is unknown'
|
|
3958 |
].
|
|
3959 |
self warn:w.
|
|
3960 |
^ self
|
|
3961 |
].
|
|
3962 |
].
|
|
3963 |
|
|
3964 |
currentMethod isNil ifTrue:[
|
|
3965 |
^ self warn:'select a method first'.
|
|
3966 |
].
|
|
3967 |
self withWaitCursorDo:[
|
|
3968 |
self class browseClass:actualClass
|
|
3969 |
selector:(actualClass selectorForMethod:currentMethod)
|
|
3970 |
]
|
|
3971 |
!
|
|
3972 |
|
|
3973 |
methodNewMethod
|
|
3974 |
"prepare for definition of a new method - put a template into
|
|
3975 |
code view and define accept-action to compile it"
|
|
3976 |
|
|
3977 |
currentClass isNil ifTrue:[
|
|
3978 |
^ self warn:'select/create a class first'.
|
|
3979 |
].
|
|
3980 |
currentMethodCategory isNil ifTrue:[
|
|
3981 |
^ self warn:'select/create a method category first'.
|
|
3982 |
].
|
|
3983 |
|
|
3984 |
currentMethod := nil.
|
|
3985 |
|
|
3986 |
methodListView deselect.
|
|
3987 |
codeView contents:(self template).
|
|
3988 |
codeView modified:false.
|
|
3989 |
|
|
3990 |
codeView acceptAction:[:theCode |
|
|
3991 |
codeView cursor:Cursor execute.
|
|
3992 |
Object abortSignal catch:[
|
|
3993 |
actualClass compiler compile:theCode asString
|
|
3994 |
forClass:actualClass
|
|
3995 |
inCategory:currentMethodCategory
|
|
3996 |
notifying:codeView.
|
|
3997 |
codeView modified:false.
|
|
3998 |
self updateMethodListWithScroll:false.
|
|
3999 |
].
|
|
4000 |
codeView cursor:Cursor normal.
|
|
4001 |
].
|
|
4002 |
codeView explainAction:[:theCode :theSelection |
|
|
4003 |
self showExplanation:(Explainer explain:theSelection
|
|
4004 |
in:theCode
|
|
4005 |
forClass:actualClass)
|
|
4006 |
]
|
|
4007 |
!
|
|
4008 |
|
|
4009 |
methodRemove
|
|
4010 |
"remove the current method"
|
|
4011 |
|
|
4012 |
currentMethod isNil ifTrue:[
|
|
4013 |
^ self warn:'select a method first'.
|
|
4014 |
].
|
|
4015 |
actualClass
|
|
4016 |
removeSelector:(actualClass selectorForMethod:currentMethod).
|
|
4017 |
self updateMethodListWithScroll:false
|
|
4018 |
!
|
|
4019 |
|
|
4020 |
doChangeCategoryOfCurrentMethodTo:aString
|
|
4021 |
"after querying user - do really change current methods category"
|
|
4022 |
|
|
4023 |
currentMethod isNil ifTrue:[
|
|
4024 |
^ self warn:'select a method first'.
|
|
4025 |
].
|
|
4026 |
currentMethod category:aString asSymbol.
|
|
4027 |
currentClass changed.
|
|
4028 |
self updateMethodCategoryListWithScroll:false.
|
|
4029 |
self updateMethodListWithScroll:false
|
|
4030 |
!
|
|
4031 |
|
|
4032 |
methodChangeCategory
|
|
4033 |
"move the current method into another category -
|
|
4034 |
nothing done here, but a query for the new category.
|
|
4035 |
Remember the last category, to allow faster category change of a group of methods."
|
|
4036 |
|
|
4037 |
currentMethod isNil ifTrue:[
|
|
4038 |
^ self warn:'select a method first'.
|
|
4039 |
].
|
|
4040 |
self enterBoxTitle:('change category from ' , currentMethod category , ' to:')
|
|
4041 |
okText:'change'.
|
|
4042 |
lastMethodCategory isNil ifTrue:[
|
|
4043 |
enterBox initialText:(currentMethod category).
|
|
4044 |
] ifFalse:[
|
|
4045 |
enterBox initialText:lastMethodCategory
|
|
4046 |
].
|
|
4047 |
enterBox action:[:aString | lastMethodCategory := aString.
|
|
4048 |
self doChangeCategoryOfCurrentMethodTo:aString
|
|
4049 |
].
|
|
4050 |
enterBox showAtPointer
|
|
4051 |
!
|
|
4052 |
|
|
4053 |
methodRemoveBreakOrTrace
|
|
4054 |
"turn off tracing of the current method"
|
|
4055 |
|
|
4056 |
|sel|
|
|
4057 |
|
|
4058 |
currentMethod notNil ifTrue:[
|
|
4059 |
currentMethod isWrapped ifTrue:[
|
|
4060 |
currentMethod := MessageTracer unwrapMethod:currentMethod.
|
|
4061 |
sel := methodListView selection.
|
|
4062 |
self updateMethodListWithScroll:false.
|
|
4063 |
methodListView selection:sel.
|
|
4064 |
self initializeMethodMenu
|
|
4065 |
].
|
|
4066 |
]
|
|
4067 |
!
|
|
4068 |
|
|
4069 |
methodBreakPoint
|
|
4070 |
"set a breakpoint on the current method"
|
|
4071 |
|
|
4072 |
|sel|
|
|
4073 |
|
|
4074 |
currentMethod notNil ifTrue:[
|
|
4075 |
currentMethod isWrapped ifFalse:[
|
|
4076 |
currentMethod := MessageTracer trapMethod:currentMethod.
|
|
4077 |
self initializeMethodMenu2.
|
|
4078 |
sel := methodListView selection.
|
|
4079 |
self updateMethodListWithScroll:false.
|
|
4080 |
methodListView selection:sel
|
|
4081 |
].
|
|
4082 |
]
|
|
4083 |
!
|
|
4084 |
|
|
4085 |
methodTrace
|
|
4086 |
"turn on tracing of the current method"
|
|
4087 |
|
|
4088 |
|sel|
|
|
4089 |
|
|
4090 |
currentMethod notNil ifTrue:[
|
|
4091 |
currentMethod isWrapped ifFalse:[
|
|
4092 |
currentMethod := MessageTracer traceMethod:currentMethod.
|
|
4093 |
self initializeMethodMenu2.
|
|
4094 |
sel := methodListView selection.
|
|
4095 |
self updateMethodListWithScroll:false.
|
|
4096 |
methodListView selection:sel
|
|
4097 |
].
|
|
4098 |
]
|
|
4099 |
!
|
|
4100 |
|
|
4101 |
methodTraceSender
|
|
4102 |
"turn on tracing of the current method"
|
|
4103 |
|
|
4104 |
|sel|
|
|
4105 |
|
|
4106 |
currentMethod notNil ifTrue:[
|
|
4107 |
currentMethod isWrapped ifFalse:[
|
|
4108 |
currentMethod := MessageTracer traceMethodSender:currentMethod.
|
|
4109 |
self initializeMethodMenu2.
|
|
4110 |
sel := methodListView selection.
|
|
4111 |
self updateMethodListWithScroll:false.
|
|
4112 |
methodListView selection:sel
|
|
4113 |
].
|
|
4114 |
]
|
|
4115 |
! !
|
|
4116 |
|
|
4117 |
!SystemBrowser methodsFor:'class-method menu'!
|
|
4118 |
|
|
4119 |
initializeClassMethodMenu
|
|
4120 |
|labels|
|
|
4121 |
|
|
4122 |
labels := resources array:#(
|
|
4123 |
'fileOut'
|
|
4124 |
'printOut'
|
|
4125 |
'-'
|
|
4126 |
'spawn'
|
|
4127 |
'-'
|
|
4128 |
'sender ...'
|
|
4129 |
'implementors ...'
|
|
4130 |
'globals ...'
|
|
4131 |
"/ '-'
|
|
4132 |
"/ 'breakpoint'
|
|
4133 |
"/ 'trace'
|
|
4134 |
"/ 'trace sender'
|
|
4135 |
).
|
|
4136 |
|
|
4137 |
classMethodListView
|
|
4138 |
middleButtonMenu:(PopUpMenu
|
|
4139 |
labels:labels
|
|
4140 |
selectors:#(methodFileOut
|
|
4141 |
methodPrintOut
|
|
4142 |
nil
|
|
4143 |
methodSpawn
|
|
4144 |
nil
|
|
4145 |
methodSenders
|
|
4146 |
methodImplementors
|
|
4147 |
methodGlobalReferends
|
|
4148 |
"/ nil
|
|
4149 |
"/ methodBreakPoint
|
|
4150 |
"/ methodTrace
|
|
4151 |
"/ methodTraceSender
|
|
4152 |
)
|
|
4153 |
receiver:self
|
|
4154 |
for:classMethodListView)
|
|
4155 |
! !
|
|
4156 |
|
|
4157 |
!SystemBrowser methodsFor:'dependencies'!
|
|
4158 |
|
|
4159 |
update
|
|
4160 |
"handle changes from other browsers"
|
|
4161 |
|
|
4162 |
|oldClassCategory oldClassName oldMethodCategory oldMethod oldSelector|
|
|
4163 |
|
|
4164 |
self updateClassCategoryListWithScroll:false.
|
|
4165 |
"
|
|
4166 |
self updateClassListWithScroll:false.
|
|
4167 |
"
|
|
4168 |
^ self.
|
|
4169 |
|
|
4170 |
oldClassCategory := currentClassCategory.
|
|
4171 |
currentClass notNil ifTrue:[
|
|
4172 |
oldClassName := currentClass name
|
|
4173 |
].
|
|
4174 |
oldMethodCategory := currentMethodCategory.
|
|
4175 |
oldMethod := currentMethod.
|
|
4176 |
methodListView notNil ifTrue:[
|
|
4177 |
oldMethod notNil ifTrue:[
|
|
4178 |
oldSelector := methodListView selectionValue
|
|
4179 |
]
|
|
4180 |
].
|
|
4181 |
|
|
4182 |
classCategoryListView notNil ifTrue:[
|
|
4183 |
classCategoryListView setContents:(self listOfAllClassCategories).
|
|
4184 |
oldClassCategory notNil ifTrue:[
|
|
4185 |
classCategoryListView selectElement:oldClassCategory
|
|
4186 |
].
|
|
4187 |
classCategoryListView selection isNil ifTrue:[
|
|
4188 |
currentClassCategory := nil.
|
|
4189 |
self switchToClass:nil.
|
|
4190 |
oldClassName := nil
|
|
4191 |
]
|
|
4192 |
].
|
|
4193 |
classListView notNil ifTrue:[
|
|
4194 |
self updateClassListWithScroll:false.
|
|
4195 |
oldClassName notNil ifTrue:[
|
|
4196 |
classListView selectElement:oldClassName
|
|
4197 |
].
|
|
4198 |
classListView selection isNil ifTrue:[
|
|
4199 |
self switchToClass:nil.
|
|
4200 |
currentMethodCategory := nil.
|
|
4201 |
oldMethodCategory := nil
|
|
4202 |
]
|
|
4203 |
].
|
|
4204 |
methodCategoryListView notNil ifTrue:[
|
|
4205 |
self updateMethodCategoryListWithScroll:false.
|
|
4206 |
oldMethodCategory notNil ifTrue:[
|
|
4207 |
methodCategoryListView selectElement:oldMethodCategory
|
|
4208 |
].
|
|
4209 |
methodCategoryListView selection isNil ifTrue:[
|
|
4210 |
currentMethodCategory := nil.
|
|
4211 |
currentMethod := nil.
|
|
4212 |
oldSelector := nil
|
|
4213 |
]
|
|
4214 |
].
|
|
4215 |
methodListView notNil ifTrue:[
|
|
4216 |
self updateMethodListWithScroll:false.
|
|
4217 |
oldSelector notNil ifTrue:[
|
|
4218 |
methodListView selectElement:oldSelector
|
|
4219 |
].
|
|
4220 |
methodListView selection isNil ifTrue:[
|
|
4221 |
currentMethod := nil
|
|
4222 |
]
|
|
4223 |
].
|
|
4224 |
self updateCodeView
|
|
4225 |
!
|
|
4226 |
|
|
4227 |
update:someObject
|
|
4228 |
(someObject == Smalltalk) ifTrue:[self update. ^ self].
|
|
4229 |
someObject isBehavior ifTrue:[
|
|
4230 |
currentClass notNil ifTrue:[
|
|
4231 |
someObject name = currentClass name ifTrue:[
|
|
4232 |
currentClass := someObject.
|
|
4233 |
showInstance ifTrue:[
|
|
4234 |
actualClass := currentClass
|
|
4235 |
] ifFalse:[
|
|
4236 |
actualClass := currentClass class
|
|
4237 |
].
|
|
4238 |
self updateMethodCategoryListWithScroll:false.
|
|
4239 |
"dont update codeView ...."
|
|
4240 |
"self update"
|
|
4241 |
^ self
|
|
4242 |
]
|
|
4243 |
]
|
|
4244 |
]
|
|
4245 |
! !
|