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