author | Claus Gittinger <cg@exept.de> |
Sat, 09 Dec 1995 18:28:08 +0100 | |
changeset 256 | 5ae592de1b4f |
parent 254 | 8258536e5bcf |
child 270 | f97a37f5df7a |
permissions | -rw-r--r-- |
36 | 1 |
" |
2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
45 | 3 |
All Rights Reserved |
36 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
85 | 13 |
ApplicationModel subclass:#SystemBrowser |
75 | 14 |
instanceVariableNames:'currentClass currentMethodCategory currentMethod currentSelector |
256 | 15 |
showInstance actualClasslastMethodCategory aspect lockUpdates |
16 |
autoSearch myLabel acceptClass' |
|
52 | 17 |
classVariableNames:'CheckForInstancesWhenRemovingClasses' |
18 |
poolDictionaries:'' |
|
19 |
category:'Interface-Browsers' |
|
36 | 20 |
! |
21 |
||
203 | 22 |
!SystemBrowser class methodsFor:'documentation'! |
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
38 |
documentation |
|
39 |
" |
|
40 |
this class implements all kinds of class browsers. |
|
41 |
Typically, it is started with 'SystemBrowser open', but there are many other |
|
42 |
startup messages, to launch special browsers. |
|
43 |
See the categories 'startup' and 'special search startup' in the classes |
|
44 |
protocol. |
|
45 |
||
46 |
Alse, see the extra document 'doc/misc/sbrowser.doc' or the HTML online doc |
|
47 |
for how to use the browser. |
|
48 |
||
49 |
written winter 89 by claus. |
|
50 |
||
51 |
Notice: SystemBrowser is currently being rewritten to be an instance |
|
52 |
of ApplicationModel - this transition is not yet complete and you see |
|
53 |
here an intermediate version. The instance variables defined here are NOT |
|
54 |
currently used - instead, everything is really done in the BrowserView |
|
55 |
which (currently) keeps the real state of the browser. |
|
56 |
This will certainly change ... |
|
57 |
" |
|
58 |
! ! |
|
59 |
||
75 | 60 |
!SystemBrowser class methodsFor:'initialization'! |
61 |
||
62 |
initialize |
|
63 |
"Browser configuration; |
|
64 |
(values can be changed from your private startup file)" |
|
45 | 65 |
|
254 | 66 |
"/ self classResources. |
85 | 67 |
|
75 | 68 |
" |
69 |
setting this to false, the removeClass function will remove |
|
70 |
classes WITHOUT checking for instances. Otherwise, |
|
71 |
it will check and let you confirm in case there are instances. |
|
72 |
Checking for instances may be a bit time consuming, though. |
|
73 |
The default is true - therefore, it will check |
|
74 |
" |
|
75 |
CheckForInstancesWhenRemovingClasses := true |
|
76 |
||
77 |
" |
|
78 |
CheckForInstancesWhenRemovingClasses := true |
|
79 |
CheckForInstancesWhenRemovingClasses := false |
|
80 |
||
85 | 81 |
SystemBrowser initialize |
75 | 82 |
" |
83 |
! ! |
|
36 | 84 |
|
75 | 85 |
!SystemBrowser class methodsFor:'instance creation'! |
52 | 86 |
|
75 | 87 |
open |
88 |
"launch a standard browser" |
|
89 |
||
105 | 90 |
^ self openOnDevice:(Screen current) |
75 | 91 |
|
93 | 92 |
" |
93 |
SystemBrowser open |
|
94 |
" |
|
194 | 95 |
! |
96 |
||
97 |
openInClass:aClass selector:aSelector |
|
98 |
"launch a standard browser which immediately switches |
|
99 |
to aClass>>aSelector." |
|
100 |
||
101 |
|brwsr cls| |
|
102 |
||
103 |
brwsr := self openOnDevice:(Screen current). |
|
104 |
brwsr waitUntilVisible. |
|
105 |
cls := aClass. |
|
106 |
cls notNil ifTrue:[ |
|
107 |
cls isMeta ifTrue:[ |
|
108 |
cls := aClass soleInstance |
|
109 |
]. |
|
110 |
brwsr switchToClassNamed:cls name. |
|
111 |
brwsr updateClassCategoryList. |
|
112 |
aClass isMeta ifTrue:[ |
|
113 |
brwsr instanceProtocol:false |
|
114 |
]. |
|
115 |
brwsr updateMethodCategoryList. |
|
116 |
aSelector notNil ifTrue:[ |
|
117 |
brwsr switchToMethodNamed:aSelector. |
|
118 |
] |
|
119 |
]. |
|
120 |
^ brwsr |
|
121 |
||
122 |
" |
|
123 |
SystemBrowser openInClass:Object selector:#at:put: |
|
124 |
SystemBrowser openInClass:Object selector:nil |
|
125 |
SystemBrowser openInClass:nil selector:nil |
|
126 |
" |
|
127 |
||
128 |
"Created: 22.11.1995 / 21:04:50 / cg" |
|
203 | 129 |
! |
130 |
||
131 |
openOnDevice:aDisplay |
|
132 |
"launch a standard browser on another display." |
|
133 |
||
134 |
^ self newWithLabel:(self classResources string:'System Browser') |
|
135 |
setupBlock:[:browser | browser setupForAll] |
|
136 |
onDevice:aDisplay |
|
137 |
||
138 |
"|d| |
|
139 |
||
140 |
d := XWorkstation new initializeFor:'porty:0'. |
|
141 |
d startDispatch. |
|
142 |
SystemBrowser openOnDevice:d |
|
143 |
" |
|
36 | 144 |
! ! |
145 |
||
203 | 146 |
!SystemBrowser class methodsFor:'private helpers'! |
36 | 147 |
|
203 | 148 |
showNoneFound |
215
244f3a9b2a60
check for existing class in rename; avoid warnbox if no refs are found after rename
Claus Gittinger <cg@exept.de>
parents:
204
diff
changeset
|
149 |
super warn:(self classResources string:'None found'). |
203 | 150 |
! |
36 | 151 |
|
203 | 152 |
showNoneFound:what |
215
244f3a9b2a60
check for existing class in rename; avoid warnbox if no refs are found after rename
Claus Gittinger <cg@exept.de>
parents:
204
diff
changeset
|
153 |
super warn:(self classResources string:(what , '...\\... none found') withCRs). |
203 | 154 |
! ! |
36 | 155 |
|
203 | 156 |
!SystemBrowser class methodsFor:'private instance creation'! |
157 |
||
158 |
newWithLabel:aString setupBlock:aBlock |
|
159 |
"common helper method for all creation methods" |
|
160 |
||
161 |
^ self newWithLabel:aString setupBlock:aBlock onDevice:Screen current |
|
36 | 162 |
! |
163 |
||
203 | 164 |
newWithLabel:aString setupBlock:aBlock onDevice:aWorkstation |
165 |
"common helper method for all creation methods" |
|
36 | 166 |
|
203 | 167 |
|newBrowser| |
45 | 168 |
|
203 | 169 |
newBrowser := BrowserView onDevice:aWorkstation. |
170 |
newBrowser title:aString. |
|
171 |
aBlock value:newBrowser. |
|
45 | 172 |
|
203 | 173 |
newBrowser open. |
174 |
^ newBrowser |
|
175 |
! |
|
45 | 176 |
|
203 | 177 |
newWithLabel:aString setupSelector:aSymbol arg:arg |
178 |
"common helper method for all creation methods" |
|
36 | 179 |
|
203 | 180 |
^ self newWithLabel:aString setupSelector:aSymbol arg:arg onDevice:Screen current |
36 | 181 |
! |
182 |
||
203 | 183 |
newWithLabel:aString setupSelector:aSymbol arg:arg onDevice:aWorkstation |
184 |
"common helper method for all creation methods" |
|
185 |
||
186 |
|newBrowser| |
|
52 | 187 |
|
203 | 188 |
newBrowser := BrowserView onDevice:aWorkstation. |
189 |
newBrowser title:aString. |
|
190 |
newBrowser perform:aSymbol with:arg. |
|
191 |
newBrowser open. |
|
192 |
^ newBrowser |
|
193 |
! ! |
|
194 |
||
195 |
!SystemBrowser class methodsFor:'special search startup'! |
|
196 |
||
197 |
aproposSearch:aString |
|
198 |
"browse all methods, which have aString in their selector or |
|
199 |
in the methods comment. |
|
200 |
This is relatively slow, since all source must be processed." |
|
201 |
||
202 |
^ self aproposSearch:aString in:(Smalltalk allClasses) |
|
75 | 203 |
|
52 | 204 |
! |
205 |
||
203 | 206 |
aproposSearch:aString in:aCollectionOfClasses |
207 |
"browse all methods, which have aString in their selector or |
|
208 |
in the methods comment. |
|
209 |
This is relatively slow, since all source must be processed." |
|
52 | 210 |
|
203 | 211 |
|matchString list s searchBlock browser| |
52 | 212 |
|
203 | 213 |
matchString := '*' , aString , '*'. |
52 | 214 |
|
203 | 215 |
list := OrderedCollection new. |
52 | 216 |
|
203 | 217 |
(aString includesMatchCharacters) ifTrue:[ |
256 | 218 |
s := '*' , aString , '*'. |
219 |
"a matchString" |
|
220 |
searchBlock := [:text | (text asCollectionOfLinesfindFirst:[:line | s match:line]) ~~ 0]. |
|
203 | 221 |
] ifFalse:[ |
256 | 222 |
searchBlock := [:source | (source findString:aString) ~~ 0] |
203 | 223 |
]. |
52 | 224 |
|
203 | 225 |
browser := self browseMethodsIn:aCollectionOfClasses |
256 | 226 |
where:[:class :method :sel | |
227 |
|comment| |
|
52 | 228 |
|
256 | 229 |
Processor yield. |
230 |
(searchBlock value:sel) ifTrue:[ |
|
231 |
true |
|
232 |
] ifFalse:[ |
|
233 |
comment := method comment. |
|
234 |
comment notNil |
|
235 |
and:[searchBlock value:method comment] |
|
236 |
]. |
|
237 |
] |
|
238 |
title:(ClassResources string:'apropos: %1' with:aString). |
|
52 | 239 |
|
203 | 240 |
browser notNil ifTrue:[ |
256 | 241 |
browser autoSearch:aString |
203 | 242 |
]. |
243 |
^ browser |
|
52 | 244 |
|
245 |
" |
|
203 | 246 |
SystemBrowser aproposSearch:'append' in:(Collection withAllSubclasses) |
247 |
SystemBrowser aproposSearch:'add' in:(Collection withAllSubclasses) |
|
248 |
SystemBrowser aproposSearch:'sort' in:(Collection withAllSubclasses) |
|
249 |
SystemBrowser aproposSearch:'[Aa]bsent' in:(Collection withAllSubclasses) |
|
52 | 250 |
" |
203 | 251 |
|
256 | 252 |
"Created: 9.12.1995 / 18:02:36 / cg" |
204
6f4460d5a09d
added supersend searches; offer comparing the current version with the
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
253 |
! |
6f4460d5a09d
added supersend searches; offer comparing the current version with the
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
254 |
|
203 | 255 |
browseAllCallsOn:aSelectorString |
256 |
"launch a browser for all senders of aSelector" |
|
52 | 257 |
|
203 | 258 |
^ self browseAllCallsOn:aSelectorString |
256 | 259 |
in:(Smalltalk allClasses) |
260 |
title:(self classResources string:'senders of: %1' with:aSelectorString) |
|
52 | 261 |
|
262 |
" |
|
203 | 263 |
SystemBrowser browseAllCallsOn:#+ |
52 | 264 |
" |
256 | 265 |
|
266 |
"Created: 9.12.1995 / 18:00:41 / cg" |
|
267 |
"Modified: 9.12.1995 / 18:10:57 / cg" |
|
52 | 268 |
! |
269 |
||
270 |
browseAllCallsOn:aSelectorString in:aCollectionOfClasses title:title |
|
271 |
"launch a browser for all senders of aSelector in aCollectionOfClasses" |
|
272 |
||
273 |
|sel browser searchBlock| |
|
274 |
||
275 |
((aSelectorString ~= '*') and:[aSelectorString includesMatchCharacters]) ifTrue:[ |
|
276 |
"a matchString" |
|
93 | 277 |
searchBlock := [:class :method :s | |
278 |
|lits found| |
|
52 | 279 |
|
93 | 280 |
lits := method literals. |
52 | 281 |
found := false. |
282 |
lits notNil ifTrue:[ |
|
283 |
lits do:[:aLiteral | |
|
284 |
found ifFalse:[ |
|
285 |
(aLiteral isMemberOf:Symbol) ifTrue:[ |
|
286 |
found := (aSelectorString match:aLiteral) |
|
287 |
] |
|
288 |
] |
|
289 |
] |
|
290 |
]. |
|
291 |
found |
|
292 |
]. |
|
293 |
] ifFalse:[ |
|
66 | 294 |
sel := aSelectorString asSymbolIfInterned. |
295 |
sel isNil ifTrue:[ |
|
52 | 296 |
" |
297 |
Transcript showCr:'none found.'. |
|
298 |
" |
|
299 |
self showNoneFound:title. |
|
300 |
^ nil |
|
301 |
]. |
|
93 | 302 |
searchBlock := [:class :method :s | method sends:sel]. |
52 | 303 |
]. |
93 | 304 |
browser := self browseMethodsIn:aCollectionOfClasses |
305 |
where:searchBlock |
|
306 |
title:title. |
|
52 | 307 |
|
308 |
browser notNil ifTrue:[ |
|
309 |
|s| |
|
310 |
||
311 |
" |
|
312 |
kludge for now, if its a multipart selector, |
|
313 |
no easy search is (as yet) possible |
|
314 |
" |
|
315 |
s := aSelectorString. |
|
316 |
(s includes:$:) ifTrue:[ |
|
317 |
s := s copyTo:(s indexOf:$:) |
|
318 |
]. |
|
319 |
browser autoSearch:s |
|
320 |
]. |
|
321 |
^ browser |
|
322 |
! |
|
323 |
||
203 | 324 |
browseCallsOn:aSelectorString under:aClass |
325 |
"launch a browser for all senders of aSelector in aClass and subclasses" |
|
326 |
||
327 |
^ self browseAllCallsOn:aSelectorString |
|
256 | 328 |
in:(aClass withAllSubclasses) |
329 |
title:(self classResources string:'senders of: %1 (in and below %2)' |
|
330 |
with:aSelectorString |
|
331 |
with:aClass name) |
|
203 | 332 |
|
333 |
" |
|
256 | 334 |
SystemBrowser browseCallsOn:#+ under:Number |
203 | 335 |
" |
256 | 336 |
|
337 |
"Created: 9.12.1995 / 17:59:57 / cg" |
|
338 |
"Modified: 9.12.1995 / 18:11:10 / cg" |
|
203 | 339 |
! |
340 |
||
341 |
browseClassRefsTo:aString in:aCollectionOfClasses modificationsOnly:modsOnly |
|
342 |
"launch a browser for all methods in aClass where the classVar named |
|
343 |
aString is referenced; if modsOnly is true, browse only methods where the |
|
344 |
classvar is modified" |
|
345 |
||
346 |
^ self browseRefsTo:aString classVars:true in:aCollectionOfClasses modificationsOnly:modsOnly |
|
347 |
! |
|
348 |
||
349 |
browseClassRefsTo:varName in:aCollectionOfClasses modificationsOnly:modsOnly title:title |
|
350 |
"launch a browser for all methods in aCollectionOfClasses, |
|
351 |
where the classVar named aString is referenced; |
|
352 |
if modsOnly is true, browse only methods where the classvar is modified" |
|
353 |
||
354 |
^ self browseRefsTo:varName classVars:true in:aCollectionOfClasses modificationsOnly:modsOnly title:title |
|
355 |
! |
|
356 |
||
357 |
browseClassRefsTo:aString under:aClass modificationsOnly:modsOnly |
|
358 |
"launch a browser for all methods in aClass and subclasses |
|
359 |
where the classVar named aString is referenced; |
|
360 |
if modsOnly is true, browse only methods where the classvar is modified" |
|
361 |
||
362 |
^ self browseClassRefsTo:aString in:(aClass withAllSubclasses) modificationsOnly:modsOnly |
|
363 |
||
364 |
! |
|
365 |
||
366 |
browseForString:aString |
|
367 |
"launch a browser for all methods containing a string in their source. |
|
368 |
This may be slow, since source-code has to be scanned." |
|
369 |
||
370 |
^ self browseForString:aString in:(Smalltalk allClasses) |
|
371 |
! |
|
372 |
||
373 |
browseForString:aString in:aCollectionOfClasses |
|
374 |
"launch a browser for all methods in aCollectionOfClasses |
|
375 |
containing a string in their source. |
|
376 |
This may be slow, since source-code has to be scanned." |
|
377 |
||
378 |
|browser searchBlock title s| |
|
379 |
||
256 | 380 |
title := self classResources string:'methods containing: %1' with:aString displayString. |
203 | 381 |
|
382 |
(aString includesMatchCharacters) ifTrue:[ |
|
256 | 383 |
s := '*' , aString , '*'. |
384 |
"a matchString" |
|
385 |
searchBlock := [:c :m :sel | s match:m source] |
|
203 | 386 |
] ifFalse:[ |
256 | 387 |
searchBlock := [:c :m :sel | (m source findString:aString) ~~ 0] |
203 | 388 |
]. |
389 |
browser := self browseMethodsIn:aCollectionOfClasses where:searchBlock title:title. |
|
390 |
||
391 |
browser notNil ifTrue:[ |
|
256 | 392 |
browser autoSearch:aString |
203 | 393 |
]. |
394 |
^ browser |
|
395 |
||
396 |
" |
|
397 |
SystemBrowser browseForString:'all' in:(Array with:Object) |
|
398 |
SystemBrowser browseForString:'should' in:(Array with:Object) |
|
399 |
SystemBrowser browseForString:'[eE]rror' in:(Array with:Object) |
|
400 |
" |
|
401 |
||
256 | 402 |
"Created: 9.12.1995 / 18:03:12 / cg" |
403 |
"Modified: 9.12.1995 / 18:11:19 / cg" |
|
203 | 404 |
! |
405 |
||
406 |
browseForSymbol:aSymbol |
|
407 |
"launch a browser for all methods referencing aSymbol" |
|
408 |
||
256 | 409 |
^ self browseForSymbol:aSymbol title:(self classResources string:'users of: %1' with:aSymbol) warnIfNone:true |
410 |
||
411 |
"Created: 9.12.1995 / 18:04:34 / cg" |
|
412 |
"Modified: 9.12.1995 / 18:11:22 / cg" |
|
203 | 413 |
! |
414 |
||
415 |
browseForSymbol:aSymbol title:title warnIfNone:doWarn |
|
416 |
"launch a browser for all methods referencing aSymbol" |
|
417 |
||
418 |
|browser searchBlock sym| |
|
419 |
||
420 |
(aSymbol includesMatchCharacters) ifTrue:[ |
|
421 |
"a matchString" |
|
422 |
searchBlock := [:c :m :s | |
|
423 |
|found lits| |
|
424 |
||
425 |
lits := m literals. |
|
426 |
found := false. |
|
427 |
lits notNil ifTrue:[ |
|
428 |
lits do:[:aLiteral | |
|
429 |
found ifFalse:[ |
|
430 |
(aLiteral isMemberOf:Symbol) ifTrue:[ |
|
431 |
found := (aSymbol match:aLiteral) |
|
432 |
] |
|
433 |
] |
|
434 |
] |
|
435 |
]. |
|
436 |
found |
|
437 |
]. |
|
438 |
] ifFalse:[ |
|
439 |
" |
|
440 |
can do a faster search |
|
441 |
" |
|
442 |
sym := aSymbol asSymbolIfInterned. |
|
443 |
sym isNil ifTrue:[ |
|
444 |
self showNoneFound:title. |
|
445 |
^ nil |
|
446 |
]. |
|
447 |
||
448 |
searchBlock := [:c :m :s | |
|
449 |
|found lits| |
|
450 |
||
451 |
lits := m literals. |
|
452 |
found := false. |
|
453 |
lits notNil ifTrue:[ |
|
454 |
lits do:[:aLiteral | |
|
455 |
found ifFalse:[ |
|
456 |
(aLiteral isMemberOf:Symbol) ifTrue:[ |
|
457 |
found := (sym == aLiteral) |
|
458 |
] |
|
459 |
] |
|
460 |
] |
|
461 |
]. |
|
462 |
found |
|
463 |
]. |
|
464 |
]. |
|
215
244f3a9b2a60
check for existing class in rename; avoid warnbox if no refs are found after rename
Claus Gittinger <cg@exept.de>
parents:
204
diff
changeset
|
465 |
doWarn ifFalse:[ |
244f3a9b2a60
check for existing class in rename; avoid warnbox if no refs are found after rename
Claus Gittinger <cg@exept.de>
parents:
204
diff
changeset
|
466 |
WarningSignal handle:[:ex | |
244f3a9b2a60
check for existing class in rename; avoid warnbox if no refs are found after rename
Claus Gittinger <cg@exept.de>
parents:
204
diff
changeset
|
467 |
ex proceed |
244f3a9b2a60
check for existing class in rename; avoid warnbox if no refs are found after rename
Claus Gittinger <cg@exept.de>
parents:
204
diff
changeset
|
468 |
] do:[ |
244f3a9b2a60
check for existing class in rename; avoid warnbox if no refs are found after rename
Claus Gittinger <cg@exept.de>
parents:
204
diff
changeset
|
469 |
browser := self browseMethodsWhere:searchBlock title:title. |
244f3a9b2a60
check for existing class in rename; avoid warnbox if no refs are found after rename
Claus Gittinger <cg@exept.de>
parents:
204
diff
changeset
|
470 |
] |
244f3a9b2a60
check for existing class in rename; avoid warnbox if no refs are found after rename
Claus Gittinger <cg@exept.de>
parents:
204
diff
changeset
|
471 |
] ifTrue:[ |
244f3a9b2a60
check for existing class in rename; avoid warnbox if no refs are found after rename
Claus Gittinger <cg@exept.de>
parents:
204
diff
changeset
|
472 |
browser := self browseMethodsWhere:searchBlock title:title. |
244f3a9b2a60
check for existing class in rename; avoid warnbox if no refs are found after rename
Claus Gittinger <cg@exept.de>
parents:
204
diff
changeset
|
473 |
]. |
203 | 474 |
browser notNil ifTrue:[ |
475 |
browser autoSearch:aSymbol |
|
476 |
]. |
|
477 |
^ browser |
|
478 |
! |
|
479 |
||
52 | 480 |
browseImplementorsOf:aSelectorString |
481 |
"launch a browser for all implementors of aSelector" |
|
482 |
||
483 |
^ self browseImplementorsOf:aSelectorString |
|
256 | 484 |
in:(Smalltalk allClasses) |
485 |
title:(self classResources string:'implementors of: %1' with:aSelectorString) |
|
52 | 486 |
|
487 |
" |
|
488 |
SystemBrowser browseImplementorsOf:#+ |
|
489 |
" |
|
256 | 490 |
|
491 |
"Created: 9.12.1995 / 18:01:18 / cg" |
|
492 |
"Modified: 9.12.1995 / 18:11:28 / cg" |
|
52 | 493 |
! |
494 |
||
36 | 495 |
browseImplementorsOf:aSelectorString in:aCollectionOfClasses title:title |
496 |
"launch a browser for all implementors of aSelector in |
|
497 |
the classes contained in aCollectionOfClasses and its metaclasses" |
|
498 |
||
499 |
|list sel| |
|
500 |
||
501 |
list := OrderedCollection new. |
|
502 |
||
503 |
((aSelectorString ~= '*') and:[aSelectorString includesMatchCharacters]) ifTrue:[ |
|
45 | 504 |
"a matchString" |
505 |
||
506 |
aCollectionOfClasses do:[:aClass | |
|
507 |
aClass selectorArray do:[:aSelector | |
|
508 |
(aSelectorString match:aSelector) ifTrue:[ |
|
509 |
list add:(aClass name , ' ' , aSelector) |
|
510 |
] |
|
511 |
]. |
|
132 | 512 |
aClass isMeta ifFalse:[ |
513 |
aClass class selectorArray do:[:aSelector | |
|
514 |
(aSelectorString match:aSelector) ifTrue:[ |
|
515 |
list add:(aClass name , 'class ' , aSelector) |
|
516 |
] |
|
45 | 517 |
] |
518 |
] |
|
519 |
] |
|
36 | 520 |
] ifFalse:[ |
45 | 521 |
"can do a faster search" |
522 |
||
66 | 523 |
sel := aSelectorString asSymbolIfInterned. |
524 |
sel isNil ifTrue:[ |
|
45 | 525 |
self showNoneFound:title. |
526 |
^ nil |
|
527 |
]. |
|
528 |
||
529 |
aCollectionOfClasses do:[:aClass | |
|
530 |
(aClass implements:sel) ifTrue:[ |
|
531 |
list add:(aClass name , ' ' , aSelectorString) |
|
532 |
]. |
|
132 | 533 |
aClass isMeta ifFalse:[ |
534 |
(aClass class implements:sel) ifTrue:[ |
|
535 |
list add:(aClass name , 'class ' , aSelectorString) |
|
536 |
] |
|
45 | 537 |
] |
538 |
] |
|
36 | 539 |
]. |
540 |
^ self browseMethods:list title:title |
|
541 |
||
542 |
" |
|
543 |
SystemBrowser browseImplementorsOf:#+ |
|
45 | 544 |
in:(Array with:Number |
545 |
with:Float |
|
546 |
with:SmallInteger) |
|
547 |
title:'some implementors of +' |
|
36 | 548 |
" |
132 | 549 |
|
550 |
"Modified: 4.9.1995 / 17:33:39 / claus" |
|
36 | 551 |
! |
552 |
||
52 | 553 |
browseImplementorsOf:aSelectorString under:aClass |
554 |
"launch a browser for all implementors of aSelector in aClass |
|
555 |
and its subclasses" |
|
556 |
||
557 |
^ self browseImplementorsOf:aSelectorString |
|
256 | 558 |
in:(aClass withAllSubclasses) |
559 |
title:(self classResources string:'implementors of: %1 (in and below %2)' |
|
560 |
with:aSelectorString |
|
561 |
with:aClass name) |
|
52 | 562 |
|
563 |
" |
|
564 |
SystemBrowser browseImplementorsOf:#+ under:Integer |
|
565 |
" |
|
256 | 566 |
|
567 |
"Created: 9.12.1995 / 18:06:09 / cg" |
|
568 |
"Modified: 9.12.1995 / 18:11:38 / cg" |
|
52 | 569 |
! |
570 |
||
203 | 571 |
browseInstRefsTo:aString in:aCollectionOfClasses modificationsOnly:modsOnly |
572 |
"launch a browser for all methods in aClass where the instVar named |
|
573 |
aString is referenced; if modsOnly is true, browse only methods where the |
|
574 |
instvar is modified" |
|
45 | 575 |
|
203 | 576 |
^ self browseRefsTo:aString classVars:false in:aCollectionOfClasses modificationsOnly:modsOnly |
36 | 577 |
! |
578 |
||
203 | 579 |
browseInstRefsTo:varName in:aCollectionOfClasses modificationsOnly:modsOnly title:title |
580 |
"launch a browser for all methods in aClass where the instVar named |
|
581 |
varName is referenced; if modsOnly is true, browse only methods where the |
|
582 |
instvar is modified" |
|
52 | 583 |
|
203 | 584 |
^ self browseRefsTo:varName classVars:false in:aCollectionOfClasses modificationsOnly:modsOnly title:title |
52 | 585 |
! |
586 |
||
203 | 587 |
browseInstRefsTo:aString under:aClass modificationsOnly:modsOnly |
588 |
"launch a browser for all methods in aClass and subclasses |
|
589 |
where the instVar named aString is referenced; |
|
590 |
if modsOnly is true, browse only methods where the instvar is modified" |
|
36 | 591 |
|
203 | 592 |
^ self browseInstRefsTo:aString in:(aClass withAllSubclasses) modificationsOnly:modsOnly |
36 | 593 |
! |
594 |
||
595 |
browseReferendsOf:aGlobalName |
|
596 |
"launch a browser for all methods referencing a global |
|
597 |
named aGlobalName. |
|
598 |
" |
|
599 |
||
600 |
^ self browseReferendsOf:aGlobalName warnIfNone:true |
|
601 |
||
602 |
" |
|
603 |
Browser browseReferendsOf:#Transcript |
|
604 |
" |
|
75 | 605 |
|
36 | 606 |
! |
607 |
||
203 | 608 |
browseReferendsOf:aGlobalName warnIfNone:doWarn |
609 |
"launch a browser for all methods referencing a global |
|
610 |
named aGlobalName. |
|
611 |
" |
|
612 |
||
256 | 613 |
^ self browseForSymbol:aGlobalName title:(self classResources string:'users of: %1' with:aGlobalName) warnIfNone:doWarn |
203 | 614 |
|
256 | 615 |
"Created: 9.12.1995 / 18:06:34 / cg" |
616 |
"Modified: 9.12.1995 / 18:11:45 / cg" |
|
203 | 617 |
! |
618 |
||
619 |
browseRefsTo:aString classVars:classVars in:aCollectionOfClasses modificationsOnly:modsOnly |
|
620 |
"launch a browser for all methods in aClass where the instVar/classVar named |
|
621 |
aString is referenced; if modsOnly is true, browse only methods where the |
|
622 |
instvar is modified" |
|
623 |
||
624 |
|title| |
|
625 |
||
626 |
modsOnly ifTrue:[ |
|
256 | 627 |
title := 'modifications of: %1' |
203 | 628 |
] ifFalse:[ |
256 | 629 |
title := 'references to: %1 ' |
203 | 630 |
]. |
631 |
^ self |
|
256 | 632 |
browseRefsTo:aString |
633 |
classVars:classVars |
|
634 |
in:aCollectionOfClasses |
|
635 |
modificationsOnly:modsOnly |
|
636 |
title:(self classResources string:title with:aString) |
|
637 |
||
638 |
"Created: 9.12.1995 / 18:07:05 / cg" |
|
639 |
"Modified: 9.12.1995 / 18:11:49 / cg" |
|
203 | 640 |
! |
641 |
||
642 |
browseRefsTo:varName classVars:classVars in:aCollectionOfClasses modificationsOnly:modsOnly title:title |
|
643 |
"launch a browser for all methods in aClass where the instVar/classVar named |
|
644 |
varName is referenced; if modsOnly is true, browse only methods where the |
|
645 |
instvar is modified" |
|
646 |
||
647 |
|filter browser pattern| |
|
648 |
||
649 |
filter := self filterToSearchRefsTo:varName classVars:classVars modificationsOnly:modsOnly. |
|
650 |
browser := self browseMethodsIn:aCollectionOfClasses |
|
651 |
inst:true class:classVars where:filter title:title. |
|
652 |
||
653 |
browser notNil ifTrue:[ |
|
654 |
modsOnly ifTrue:[ |
|
655 |
pattern := varName , ' :=' |
|
656 |
] ifFalse:[ |
|
657 |
pattern := varName |
|
658 |
]. |
|
659 |
browser autoSearch:pattern |
|
660 |
]. |
|
661 |
^ browser |
|
662 |
! |
|
663 |
||
256 | 664 |
browseSuperCallsIn:aCollectionOfClasses title:title |
665 |
"launch a browser for all super sends in aCollectionOfClasses" |
|
666 |
||
667 |
|sel browser searchBlock| |
|
668 |
||
669 |
searchBlock := [:class :method :s | |
|
670 |
|parser| |
|
671 |
||
672 |
parser := Parser parseMethod:method source in:class warnings:false. |
|
673 |
parser notNil and:[parser usesSuper] |
|
674 |
]. |
|
675 |
||
676 |
browser := self browseMethodsIn:aCollectionOfClasses |
|
677 |
where:searchBlock |
|
678 |
title:title. |
|
679 |
||
680 |
browser notNil ifTrue:[ |
|
681 |
browser autoSearch:'super' |
|
682 |
]. |
|
683 |
^ browser |
|
684 |
||
685 |
"Created: 23.11.1995 / 14:08:55 / cg" |
|
686 |
! |
|
687 |
||
688 |
browseSuperCallsUnder:aClass |
|
689 |
"launch a browser for all supersends in aClass and subclasses" |
|
690 |
||
691 |
^ self browseSuperCallsIn:(aClass withAllSubclasses) |
|
692 |
title:(self classResources string:'supersends (in and below %1)' with:aClass name) |
|
693 |
||
694 |
" |
|
695 |
SystemBrowser browseSuperCallsUnder:Number |
|
696 |
" |
|
697 |
||
698 |
"Created: 23.11.1995 / 12:06:06 / cg" |
|
699 |
"Modified: 9.12.1995 / 18:11:59 / cg" |
|
700 |
! |
|
701 |
||
52 | 702 |
browseUsesOf:aClass |
703 |
|dict owners offsets |
|
704 |
sz "{ Class: SmallInteger }" |
|
705 |
n "{ Class: SmallInteger }" |
|
706 |
removeSet newDict| |
|
707 |
||
708 |
owners := ObjectMemory whoReferencesInstancesOf:aClass. |
|
709 |
||
710 |
" |
|
711 |
collect set of offsets in dict; key is class |
|
712 |
" |
|
713 |
dict := IdentityDictionary new. |
|
714 |
owners do:[:someObject | |
|
715 |
|cls create| |
|
716 |
||
717 |
someObject isContext ifFalse:[ |
|
718 |
" |
|
719 |
someObject refers to an instance of aClass; |
|
720 |
find out, which instVar(s) |
|
721 |
" |
|
722 |
cls := someObject class. |
|
723 |
cls ~~ Array ifTrue:[ |
|
724 |
n := cls instSize. |
|
725 |
create := [|s| s := Set new. dict at:cls put:s. s]. |
|
726 |
||
727 |
1 to:n do:[:i | |
|
728 |
|ref| |
|
729 |
||
730 |
ref := someObject instVarAt:i. |
|
731 |
(ref isMemberOf:aClass) ifTrue:[ |
|
732 |
offsets := dict at:cls ifAbsent:create. |
|
733 |
offsets add:i. |
|
734 |
] |
|
735 |
]. |
|
736 |
cls isVariable ifTrue:[ |
|
737 |
cls isPointers ifTrue:[ |
|
738 |
| idx "{ Class: SmallInteger }" | |
|
739 |
||
740 |
sz := someObject basicSize. |
|
741 |
idx := 1. |
|
742 |
[idx <= sz] whileTrue:[ |
|
743 |
|ref| |
|
744 |
||
745 |
ref := someObject basicAt:idx. |
|
746 |
(ref isMemberOf:aClass) ifTrue:[ |
|
747 |
offsets := dict at:cls ifAbsent:create. |
|
748 |
offsets add:0. |
|
749 |
idx := sz |
|
750 |
]. |
|
751 |
idx := idx + 1 |
|
752 |
] |
|
753 |
] |
|
754 |
] |
|
755 |
] |
|
756 |
] |
|
757 |
]. |
|
758 |
||
759 |
" |
|
760 |
merge with superclass refs |
|
761 |
" |
|
762 |
dict keysAndValuesDo:[:cls :set | |
|
763 |
cls allSuperclasses do:[:aSuperclass | |
|
764 |
|superSet| |
|
765 |
||
766 |
superSet := dict at:aSuperclass ifAbsent:[]. |
|
767 |
superSet notNil ifTrue:[ |
|
768 |
|removeSet| |
|
769 |
||
770 |
superSet := dict at:aSuperclass. |
|
771 |
removeSet := Set new. |
|
772 |
set do:[:offset | |
|
773 |
(superSet includes:offset) ifTrue:[ |
|
774 |
removeSet add:offset |
|
775 |
] |
|
776 |
]. |
|
777 |
set removeAll:removeSet |
|
778 |
] |
|
779 |
] |
|
780 |
]. |
|
781 |
||
782 |
" |
|
783 |
remove empty ones |
|
784 |
" |
|
785 |
removeSet := Set new. |
|
786 |
dict keysAndValuesDo:[:cls :set | |
|
787 |
set isEmpty ifTrue:[ |
|
788 |
removeSet add:cls |
|
789 |
] |
|
790 |
]. |
|
791 |
removeSet do:[:cls | |
|
792 |
dict removeKey:cls |
|
793 |
]. |
|
794 |
||
795 |
" |
|
796 |
replace the indices by real names |
|
797 |
" |
|
798 |
newDict := IdentityDictionary new. |
|
799 |
dict keysAndValuesDo:[:cls :set | |
|
800 |
|newSet names| |
|
801 |
||
802 |
names := cls allInstVarNames. |
|
803 |
newSet := set collect:[:index | |
|
804 |
index == 0 ifTrue:['*indexed*'] ifFalse:[names at:index]. |
|
805 |
]. |
|
806 |
newDict at:cls put:newSet |
|
807 |
]. |
|
808 |
||
809 |
newDict inspect |
|
810 |
||
75 | 811 |
|
52 | 812 |
! |
813 |
||
203 | 814 |
filterToSearchRefsTo:varName classVars:classVars modificationsOnly:modsOnly |
815 |
"return a searchblock for variable references" |
|
816 |
||
817 |
|searchBlock| |
|
53 | 818 |
|
203 | 819 |
searchBlock := [:c :m :s | |
820 |
|src result parser vars needMatch| |
|
36 | 821 |
|
203 | 822 |
needMatch := varName includesMatchCharacters. |
36 | 823 |
|
203 | 824 |
src := m source. |
825 |
src isNil ifTrue:[ |
|
826 |
result := false |
|
827 |
] ifFalse:[ |
|
828 |
needMatch ifFalse:[ |
|
829 |
" |
|
830 |
before doing a slow parse, quickly scan the |
|
831 |
methods source for the variables name ... |
|
832 |
" |
|
833 |
result := (src findString:varName) ~~ 0. |
|
834 |
] ifTrue:[ |
|
835 |
result := true. |
|
836 |
]. |
|
837 |
result ifTrue:[ |
|
838 |
result := false. |
|
839 |
parser := Parser parseMethod:src in:c warnings:false. |
|
840 |
parser notNil ifTrue:[ |
|
841 |
classVars ifFalse:[ |
|
842 |
modsOnly ifTrue:[ |
|
843 |
vars := parser modifiedInstVars |
|
844 |
] ifFalse:[ |
|
845 |
vars := parser usedInstVars |
|
846 |
]. |
|
847 |
] ifTrue:[ |
|
848 |
modsOnly ifTrue:[ |
|
849 |
vars := parser modifiedClassVars |
|
850 |
] ifFalse:[ |
|
851 |
vars := parser usedClassVars |
|
852 |
]. |
|
853 |
]. |
|
854 |
vars notNil ifTrue:[ |
|
855 |
needMatch ifTrue:[ |
|
856 |
vars do:[:cv | |
|
857 |
(varName match:cv) ifTrue:[result := true] |
|
858 |
] |
|
859 |
] ifFalse:[ |
|
860 |
result := vars includes:varName |
|
861 |
] |
|
862 |
] |
|
863 |
]. |
|
864 |
]. |
|
865 |
]. |
|
866 |
Processor yield. |
|
867 |
result |
|
36 | 868 |
]. |
203 | 869 |
^ searchBlock |
870 |
! ! |
|
871 |
||
872 |
!SystemBrowser class methodsFor:'startup'! |
|
36 | 873 |
|
203 | 874 |
browseAllSelect:aBlock |
875 |
"launch a browser for all methods where aBlock returns true. |
|
876 |
The block is called with 3 arguments, class, method and seelctor." |
|
877 |
||
878 |
^ self browseMethodsWhere:aBlock title:'selected messages' |
|
36 | 879 |
|
53 | 880 |
" |
203 | 881 |
SystemBrowser browseAllSelect:[:aClass :aMethod :selector | selector numArgs == 3] |
53 | 882 |
" |
203 | 883 |
! |
75 | 884 |
|
203 | 885 |
browseClass:aClass |
886 |
"launch a browser for aClass" |
|
887 |
||
888 |
^ self |
|
889 |
newWithLabel:aClass name |
|
890 |
setupSelector:#setupForClass: |
|
891 |
arg:aClass |
|
892 |
||
893 |
"SystemBrowser browseClass:Object" |
|
894 |
! |
|
895 |
||
896 |
browseClass:aClass methodCategory:aCategory |
|
897 |
"launch a browser for all methods under aCategory in aClass" |
|
898 |
||
899 |
^ self newWithLabel:(aClass name , ' ' , aCategory) |
|
900 |
setupBlock:[:browser | browser setupForClass:aClass methodCategory:aCategory] |
|
901 |
||
902 |
"SystemBrowser browseClass:String methodCategory:'copying'" |
|
903 |
! |
|
904 |
||
905 |
browseClass:aClass selector:selector |
|
906 |
"launch a browser for the method at selector in aClass" |
|
907 |
||
908 |
^ self |
|
909 |
newWithLabel:(aClass name , ' ' , selector , ' ' , selector) |
|
910 |
setupBlock:[:newBrowser | newBrowser setupForClass:aClass selector:selector] |
|
911 |
||
912 |
" |
|
913 |
SystemBrowser browseClass:Object selector:#printString |
|
914 |
" |
|
36 | 915 |
! |
916 |
||
203 | 917 |
browseClassCategory:aClassCategory |
918 |
"launch a browser for all classes under aCategory" |
|
919 |
||
920 |
^ self |
|
921 |
newWithLabel:aClassCategory |
|
922 |
setupSelector:#setupForClassCategory: |
|
923 |
arg:aClassCategory |
|
924 |
||
925 |
"SystemBrowser browseClassCategory:'Kernel-Objects'" |
|
926 |
! |
|
927 |
||
928 |
browseClassHierarchy:aClass |
|
929 |
"launch a browser for aClass and all its superclasses. |
|
930 |
this is different from the fullProtocol browser." |
|
36 | 931 |
|
203 | 932 |
^ self |
933 |
newWithLabel:(aClass name , '-' , 'hierarchy') |
|
934 |
setupSelector:#setupForClassHierarchy: |
|
935 |
arg:aClass |
|
936 |
||
937 |
" |
|
938 |
SystemBrowser browseClassHierarchy:Number |
|
939 |
" |
|
940 |
! |
|
941 |
||
942 |
browseClasses:aList title:title |
|
943 |
"launch a browser for all classes in aList" |
|
944 |
||
945 |
^ self |
|
946 |
newWithLabel:title |
|
947 |
setupSelector:#setupForClassList: |
|
948 |
arg:aList |
|
949 |
||
950 |
" |
|
951 |
SystemBrowser browseClasses:(Array with:Object |
|
952 |
with:Float) |
|
953 |
title:'two classes' |
|
954 |
" |
|
52 | 955 |
! |
956 |
||
203 | 957 |
browseFullClassProtocol:aClass |
958 |
"launch a browser for aClasses full protocol. |
|
959 |
This is different from hierarchy browsing." |
|
960 |
||
961 |
^ self |
|
962 |
newWithLabel:(aClass name , '-' , 'full protocol') |
|
963 |
setupSelector:#setupForFullClassProtocol: |
|
964 |
arg:aClass |
|
965 |
||
966 |
" |
|
967 |
SystemBrowser browseFullClassProtocol:Number |
|
968 |
" |
|
969 |
! |
|
36 | 970 |
|
203 | 971 |
browseFullClasses |
972 |
"launch a browser showing all methods at once" |
|
973 |
||
974 |
^ self |
|
975 |
newWithLabel:'Full Class Browser' |
|
976 |
setupBlock:[:newBrowser | newBrowser setupForFullClass] |
|
36 | 977 |
|
203 | 978 |
"SystemBrowser browseFullClasses" |
979 |
! |
|
980 |
||
981 |
browseInstMethodsFrom:aClass where:aBlock title:title |
|
982 |
"launch a browser for all instance methods in aClass and all subclasses |
|
983 |
where aBlock evaluates to true" |
|
36 | 984 |
|
203 | 985 |
^ self browseMethodsIn:(aClass withAllSubclasses) inst:true class:false where:aBlock title:title |
986 |
! |
|
987 |
||
988 |
browseInstMethodsIn:aCollectionOfClasses where:aBlock title:title |
|
989 |
"launch a browser for all instance methods of all classes in |
|
990 |
aCollectionOfClasses where aBlock evaluates to true" |
|
991 |
||
992 |
^ self browseMethodsIn:aCollectionOfClasses inst:true class:false |
|
993 |
where:aBlock title:title |
|
994 |
! |
|
36 | 995 |
|
203 | 996 |
browseInstMethodsOf:aClass where:aBlock title:title |
997 |
"launch a browser for all instance methods in aClass |
|
998 |
where aBlock evaluates to true" |
|
999 |
||
1000 |
^ self browseMethodsIn:(Array with:aClass) inst:true class:false where:aBlock title:title |
|
1001 |
! |
|
1002 |
||
1003 |
browseMethodCategory:aCategory |
|
1004 |
"launch a browser for all methods where category = aCategory" |
|
1005 |
||
1006 |
|searchBlock| |
|
1007 |
||
1008 |
aCategory includesMatchCharacters ifTrue:[ |
|
1009 |
searchBlock := [:c :m :s | aCategory match:m category]. |
|
53 | 1010 |
] ifFalse:[ |
203 | 1011 |
searchBlock := [:c :m :s | m category = aCategory] |
53 | 1012 |
]. |
1013 |
||
203 | 1014 |
self browseMethodsWhere:searchBlock title:('all methods with category of ' , aCategory) |
1015 |
||
1016 |
" |
|
1017 |
SystemBrowser browseMethodCategory:'printing & storing' |
|
1018 |
SystemBrowser browseMethodCategory:'print*' |
|
1019 |
" |
|
1020 |
! |
|
1021 |
||
1022 |
browseMethods:aList title:aString |
|
1023 |
"launch a browser for an explicit list of class/selectors. |
|
1024 |
Each entry in the list must consist of the classes name and the selector, |
|
1025 |
separated by spaces. For class methods, the string 'class' must be |
|
1026 |
appended to the classname." |
|
1027 |
||
1028 |
(aList size == 0) ifTrue:[ |
|
1029 |
self showNoneFound:aString. |
|
1030 |
^ nil |
|
1031 |
]. |
|
1032 |
aList sort. |
|
1033 |
^ self |
|
1034 |
newWithLabel:aString |
|
1035 |
setupSelector:#setupForList: |
|
1036 |
arg:aList |
|
53 | 1037 |
|
203 | 1038 |
" |
1039 |
SystemBrowser |
|
1040 |
browseMethods:#('Object printOn:' 'Collection add:') |
|
1041 |
title:'some methods' |
|
1042 |
" |
|
1043 |
" |
|
1044 |
SystemBrowser |
|
1045 |
browseMethods:#('Behavior new:' 'Setclass new:') |
|
1046 |
title:'some new: methods' |
|
1047 |
" |
|
1048 |
! |
|
53 | 1049 |
|
203 | 1050 |
browseMethodsFrom:aClass where:aBlock title:title |
1051 |
"launch a browser for all instance- and classmethods in aClass |
|
1052 |
and all its subclasses where aBlock evaluates to true. |
|
1053 |
The block is called with 3 arguments, class, method and seelctor." |
|
1054 |
||
1055 |
^ self browseMethodsIn:(aClass withAllSubclasses) where:aBlock title:title |
|
1056 |
! |
|
1057 |
||
1058 |
browseMethodsIn:aCollectionOfClasses inst:wantInst class:wantClass where:aBlock title:title |
|
1059 |
"launch a browser for all instance- (if wantInst is true) and/or |
|
1060 |
classmethods (if wantClass is true) from classes in aCollectionOfClasses, |
|
1061 |
where aBlock evaluates to true. |
|
1062 |
The block is called with 3 arguments, class, method and seelctor." |
|
1063 |
||
1064 |
|list| |
|
53 | 1065 |
|
1066 |
" |
|
203 | 1067 |
since this may take a long time, lower my priority ... |
53 | 1068 |
" |
203 | 1069 |
Processor activeProcess withLowerPriorityDo:[ |
1070 |
|checkedClasses checkBlock| |
|
75 | 1071 |
|
203 | 1072 |
checkedClasses := IdentitySet new. |
1073 |
list := OrderedCollection new. |
|
1074 |
||
1075 |
checkBlock := [:cls | |
|
1076 |
|methodArray selectorArray| |
|
1077 |
||
1078 |
(checkedClasses includes:cls) ifFalse:[ |
|
1079 |
methodArray := cls methodArray. |
|
1080 |
selectorArray := cls selectorArray. |
|
1081 |
||
1082 |
1 to:methodArray size do:[:index | |
|
1083 |
|method sel| |
|
1084 |
||
1085 |
method := methodArray at:index. |
|
1086 |
sel := selectorArray at:index. |
|
1087 |
(aBlock value:cls value:method value:sel) ifTrue:[ |
|
1088 |
list add:(cls name , ' ' , sel) |
|
1089 |
] |
|
1090 |
]. |
|
1091 |
checkedClasses add:cls. |
|
1092 |
] |
|
1093 |
]. |
|
1094 |
||
1095 |
aCollectionOfClasses do:[:aClass | |
|
1096 |
" |
|
1097 |
output disabled - it slows down things too much (when searching for |
|
1098 |
implementors or senders) |
|
1099 |
" |
|
1100 |
wantInst ifTrue:[ |
|
1101 |
"/ Transcript show:'searching '; show:aClass name; showCr:' ...'; endEntry. |
|
1102 |
checkBlock value:aClass |
|
1103 |
]. |
|
1104 |
wantClass ifTrue:[ |
|
1105 |
"/ Transcript show:'searching '; show:aClass class name; showCr:' ...'; endEntry. |
|
1106 |
checkBlock value:(aClass class) |
|
1107 |
]. |
|
1108 |
Processor yield |
|
1109 |
] |
|
1110 |
]. |
|
1111 |
||
1112 |
^ self browseMethods:list title:title |
|
53 | 1113 |
! |
1114 |
||
203 | 1115 |
browseMethodsIn:aCollectionOfClasses where:aBlock title:title |
1116 |
"launch a browser for all instance- and classmethods from |
|
1117 |
all classes in aCollectionOfClasses where aBlock evaluates to true. |
|
1118 |
The block is called with 3 arguments, class, method and seelctor." |
|
53 | 1119 |
|
203 | 1120 |
^ self browseMethodsIn:aCollectionOfClasses inst:true class:true where:aBlock title:title |
75 | 1121 |
|
36 | 1122 |
! |
1123 |
||
203 | 1124 |
browseMethodsOf:aClass where:aBlock title:title |
1125 |
"launch a browser for all instance- and classmethods in aClass |
|
1126 |
where aBlock evaluates to true. |
|
1127 |
The block is called with 3 arguments, class, method and seelctor." |
|
93 | 1128 |
|
203 | 1129 |
^ self browseMethodsIn:(Array with:aClass) where:aBlock title:title |
93 | 1130 |
! |
1131 |
||
203 | 1132 |
browseMethodsWhere:aBlock title:title |
1133 |
"launch a browser for all methods where aBlock returns true. |
|
1134 |
The block is called with 3 arguments, class, method and seelctor." |
|
1135 |
||
1136 |
^ self browseMethodsIn:(Smalltalk allClasses) where:aBlock title:title |
|
1137 |
! ! |
|
93 | 1138 |
|
203 | 1139 |
!SystemBrowser class methodsFor:'startup with query'! |
1140 |
||
1141 |
askThenBrowseClass |
|
1142 |
self getClassThenPerform:#browseClass: |
|
1143 |
||
1144 |
" |
|
1145 |
SystemBrowser askThenBrowseClass |
|
1146 |
" |
|
93 | 1147 |
! |
1148 |
||
203 | 1149 |
askThenBrowseClassHierarchy |
1150 |
self getClassThenPerform:#browseClassHierarchy: |
|
36 | 1151 |
|
203 | 1152 |
" |
1153 |
SystemBrowser askThenBrowseClassHierarchy |
|
1154 |
" |
|
36 | 1155 |
! |
1156 |
||
203 | 1157 |
askThenBrowseFullClassProtocol |
1158 |
self getClassThenPerform:#browseFullClassProtocol: |
|
36 | 1159 |
|
203 | 1160 |
" |
1161 |
SystemBrowser askThenBrowseFullClassProtocol |
|
1162 |
" |
|
52 | 1163 |
! |
1164 |
||
203 | 1165 |
getClassThenPerform:aSelector |
1166 |
|enterBox| |
|
52 | 1167 |
|
203 | 1168 |
enterBox := EnterBox title:(self classResources at:'Browse which class:') withCRs. |
254 | 1169 |
enterBox okText:(ClassResources at:'browse'). |
203 | 1170 |
enterBox entryCompletionBlock:[:contents | |
1171 |
|s what m| |
|
52 | 1172 |
|
203 | 1173 |
s := contents withoutSpaces. |
1174 |
what := Smalltalk classnameCompletion:s. |
|
1175 |
enterBox contents:what first. |
|
1176 |
]. |
|
1177 |
enterBox action:[:className | |
|
1178 |
|cls| |
|
52 | 1179 |
|
203 | 1180 |
cls := Smalltalk classNamed:className. |
1181 |
cls isNil ifTrue:[ |
|
254 | 1182 |
self warn:(ClassResources at:'no such class'). |
203 | 1183 |
] ifFalse:[ |
1184 |
self perform:aSelector with:cls |
|
1185 |
] |
|
1186 |
]. |
|
1187 |
enterBox showAtPointer |
|
75 | 1188 |
|
203 | 1189 |
" |
1190 |
SystemBrowser getClassThenPerform:#browseClass: |
|
1191 |
" |
|
36 | 1192 |
! ! |
1193 |
||
203 | 1194 |
!SystemBrowser class methodsFor:'documentation'! |
93 | 1195 |
|
203 | 1196 |
version |
256 | 1197 |
^ '$Header: /cvs/stx/stx/libtool/SystemBrowser.st,v 1.47 1995-12-09 17:28:08 cg Exp $' |
36 | 1198 |
! ! |
203 | 1199 |
SystemBrowser initialize! |