author | Claus Gittinger <cg@exept.de> |
Fri, 12 Apr 1996 19:09:48 +0200 | |
changeset 475 | b14b3ab39af6 |
parent 436 | c553370b0a05 |
child 504 | 1bb5e6002ebb |
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 ... |
|
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" |
|
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
|
385 |
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
|
386 |
|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
|
387 |
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
|
388 |
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
|
389 |
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
|
390 |
] |
203 | 391 |
] 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
|
392 |
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
|
393 |
|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
|
394 |
|
b14b3ab39af6
dont crash if searching a string in a method which has no accessable source
Claus Gittinger <cg@exept.de>
parents:
436
diff
changeset
|
395 |
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
|
396 |
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
|
397 |
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
|
398 |
] |
203 | 399 |
]. |
400 |
browser := self browseMethodsIn:aCollectionOfClasses where:searchBlock title:title. |
|
401 |
||
402 |
browser notNil ifTrue:[ |
|
256 | 403 |
browser autoSearch:aString |
203 | 404 |
]. |
405 |
^ browser |
|
406 |
||
407 |
" |
|
408 |
SystemBrowser browseForString:'all' in:(Array with:Object) |
|
409 |
SystemBrowser browseForString:'should' in:(Array with:Object) |
|
410 |
SystemBrowser browseForString:'[eE]rror' in:(Array with:Object) |
|
411 |
" |
|
412 |
||
256 | 413 |
"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
|
414 |
"Modified: 12.4.1996 / 19:03:29 / cg" |
203 | 415 |
! |
416 |
||
417 |
browseForSymbol:aSymbol |
|
418 |
"launch a browser for all methods referencing aSymbol" |
|
419 |
||
256 | 420 |
^ self browseForSymbol:aSymbol title:(self classResources string:'users of: %1' with:aSymbol) warnIfNone:true |
421 |
||
422 |
"Created: 9.12.1995 / 18:04:34 / cg" |
|
423 |
"Modified: 9.12.1995 / 18:11:22 / cg" |
|
203 | 424 |
! |
425 |
||
426 |
browseForSymbol:aSymbol title:title warnIfNone:doWarn |
|
427 |
"launch a browser for all methods referencing aSymbol" |
|
428 |
||
429 |
|browser searchBlock sym| |
|
430 |
||
431 |
(aSymbol includesMatchCharacters) ifTrue:[ |
|
375 | 432 |
"a matchString" |
433 |
searchBlock := [:c :m :s | |
|
434 |
|found lits| |
|
203 | 435 |
|
375 | 436 |
lits := m literals. |
437 |
found := false. |
|
438 |
lits notNil ifTrue:[ |
|
439 |
lits do:[:aLiteral | |
|
440 |
found ifFalse:[ |
|
441 |
(aLiteral isMemberOf:Symbol) ifTrue:[ |
|
442 |
found := (aSymbol match:aLiteral) |
|
443 |
] |
|
444 |
] |
|
445 |
] |
|
446 |
]. |
|
447 |
found |
|
448 |
]. |
|
203 | 449 |
] ifFalse:[ |
375 | 450 |
" |
451 |
can do a faster search |
|
452 |
" |
|
453 |
sym := aSymbol asSymbolIfInterned. |
|
454 |
sym isNil ifTrue:[ |
|
455 |
self showNoneFound:title. |
|
456 |
^ nil |
|
457 |
]. |
|
203 | 458 |
|
375 | 459 |
searchBlock := [:c :m :s | |
460 |
|found lits| |
|
203 | 461 |
|
375 | 462 |
lits := m literals. |
463 |
found := false. |
|
464 |
lits notNil ifTrue:[ |
|
465 |
lits do:[:aLiteral | |
|
466 |
found ifFalse:[ |
|
467 |
(aLiteral isMemberOf:Symbol) ifTrue:[ |
|
468 |
found := (sym == aLiteral) |
|
469 |
] |
|
470 |
] |
|
471 |
] |
|
472 |
]. |
|
473 |
found |
|
474 |
]. |
|
203 | 475 |
]. |
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
|
476 |
doWarn ifFalse:[ |
375 | 477 |
WarningSignal ignoreIn:[ |
478 |
browser := self browseMethodsWhere:searchBlock title:title. |
|
479 |
] |
|
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
|
480 |
] ifTrue:[ |
375 | 481 |
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
|
482 |
]. |
203 | 483 |
browser notNil ifTrue:[ |
375 | 484 |
browser autoSearch:aSymbol |
203 | 485 |
]. |
486 |
^ browser |
|
375 | 487 |
|
488 |
"Modified: 20.2.1996 / 20:25:42 / cg" |
|
203 | 489 |
! |
490 |
||
52 | 491 |
browseImplementorsOf:aSelectorString |
492 |
"launch a browser for all implementors of aSelector" |
|
493 |
||
494 |
^ self browseImplementorsOf:aSelectorString |
|
256 | 495 |
in:(Smalltalk allClasses) |
496 |
title:(self classResources string:'implementors of: %1' with:aSelectorString) |
|
52 | 497 |
|
498 |
" |
|
499 |
SystemBrowser browseImplementorsOf:#+ |
|
500 |
" |
|
256 | 501 |
|
502 |
"Created: 9.12.1995 / 18:01:18 / cg" |
|
503 |
"Modified: 9.12.1995 / 18:11:28 / cg" |
|
52 | 504 |
! |
505 |
||
36 | 506 |
browseImplementorsOf:aSelectorString in:aCollectionOfClasses title:title |
507 |
"launch a browser for all implementors of aSelector in |
|
508 |
the classes contained in aCollectionOfClasses and its metaclasses" |
|
509 |
||
510 |
|list sel| |
|
511 |
||
270 | 512 |
list := Set new. |
36 | 513 |
|
514 |
((aSelectorString ~= '*') and:[aSelectorString includesMatchCharacters]) ifTrue:[ |
|
270 | 515 |
"a matchString" |
516 |
||
517 |
aCollectionOfClasses do:[:aClass | |
|
518 |
|nm| |
|
45 | 519 |
|
270 | 520 |
nm := aClass name. |
521 |
aClass selectorArray do:[:aSelector | |
|
522 |
(aSelectorString match:aSelector) ifTrue:[ |
|
523 |
list add:(nm , ' ' , aSelector) |
|
524 |
] |
|
525 |
]. |
|
526 |
aClass isMeta ifFalse:[ |
|
527 |
aClass class selectorArray do:[:aSelector | |
|
528 |
(aSelectorString match:aSelector) ifTrue:[ |
|
529 |
list add:(nm , 'class ' , aSelector) |
|
530 |
] |
|
531 |
] |
|
532 |
] |
|
533 |
] |
|
36 | 534 |
] ifFalse:[ |
270 | 535 |
"can do a faster search" |
45 | 536 |
|
270 | 537 |
sel := aSelectorString asSymbolIfInterned. |
538 |
sel isNil ifTrue:[ |
|
539 |
self showNoneFound:title. |
|
540 |
^ nil |
|
541 |
]. |
|
542 |
||
543 |
aCollectionOfClasses do:[:aClass | |
|
544 |
|nm| |
|
45 | 545 |
|
270 | 546 |
nm := aClass name. |
547 |
(aClass implements:sel) ifTrue:[ |
|
548 |
list add:(nm , ' ' , aSelectorString) |
|
549 |
]. |
|
550 |
aClass isMeta ifFalse:[ |
|
551 |
(aClass class implements:sel) ifTrue:[ |
|
552 |
list add:(nm , 'class ' , aSelectorString) |
|
553 |
] |
|
554 |
] |
|
555 |
] |
|
36 | 556 |
]. |
270 | 557 |
^ self browseMethods:list asOrderedCollection title:title |
36 | 558 |
|
559 |
" |
|
560 |
SystemBrowser browseImplementorsOf:#+ |
|
270 | 561 |
in:(Array with:Number |
562 |
with:Float |
|
563 |
with:SmallInteger) |
|
564 |
title:'some implementors of +' |
|
36 | 565 |
" |
132 | 566 |
|
567 |
"Modified: 4.9.1995 / 17:33:39 / claus" |
|
270 | 568 |
"Modified: 10.12.1995 / 16:59:03 / cg" |
36 | 569 |
! |
570 |
||
52 | 571 |
browseImplementorsOf:aSelectorString under:aClass |
572 |
"launch a browser for all implementors of aSelector in aClass |
|
573 |
and its subclasses" |
|
574 |
||
575 |
^ self browseImplementorsOf:aSelectorString |
|
256 | 576 |
in:(aClass withAllSubclasses) |
577 |
title:(self classResources string:'implementors of: %1 (in and below %2)' |
|
578 |
with:aSelectorString |
|
579 |
with:aClass name) |
|
52 | 580 |
|
581 |
" |
|
582 |
SystemBrowser browseImplementorsOf:#+ under:Integer |
|
583 |
" |
|
256 | 584 |
|
585 |
"Created: 9.12.1995 / 18:06:09 / cg" |
|
586 |
"Modified: 9.12.1995 / 18:11:38 / cg" |
|
52 | 587 |
! |
588 |
||
203 | 589 |
browseInstRefsTo:aString in:aCollectionOfClasses modificationsOnly:modsOnly |
590 |
"launch a browser for all methods in aClass where the instVar named |
|
591 |
aString is referenced; if modsOnly is true, browse only methods where the |
|
592 |
instvar is modified" |
|
45 | 593 |
|
203 | 594 |
^ self browseRefsTo:aString classVars:false in:aCollectionOfClasses modificationsOnly:modsOnly |
36 | 595 |
! |
596 |
||
203 | 597 |
browseInstRefsTo:varName in:aCollectionOfClasses modificationsOnly:modsOnly title:title |
598 |
"launch a browser for all methods in aClass where the instVar named |
|
599 |
varName is referenced; if modsOnly is true, browse only methods where the |
|
600 |
instvar is modified" |
|
52 | 601 |
|
203 | 602 |
^ self browseRefsTo:varName classVars:false in:aCollectionOfClasses modificationsOnly:modsOnly title:title |
52 | 603 |
! |
604 |
||
203 | 605 |
browseInstRefsTo:aString under:aClass modificationsOnly:modsOnly |
606 |
"launch a browser for all methods in aClass and subclasses |
|
607 |
where the instVar named aString is referenced; |
|
608 |
if modsOnly is true, browse only methods where the instvar is modified" |
|
36 | 609 |
|
203 | 610 |
^ self browseInstRefsTo:aString in:(aClass withAllSubclasses) modificationsOnly:modsOnly |
36 | 611 |
! |
612 |
||
613 |
browseReferendsOf:aGlobalName |
|
614 |
"launch a browser for all methods referencing a global |
|
615 |
named aGlobalName. |
|
616 |
" |
|
617 |
||
618 |
^ self browseReferendsOf:aGlobalName warnIfNone:true |
|
619 |
||
620 |
" |
|
621 |
Browser browseReferendsOf:#Transcript |
|
622 |
" |
|
75 | 623 |
|
36 | 624 |
! |
625 |
||
203 | 626 |
browseReferendsOf:aGlobalName warnIfNone:doWarn |
627 |
"launch a browser for all methods referencing a global |
|
628 |
named aGlobalName. |
|
629 |
" |
|
630 |
||
256 | 631 |
^ self browseForSymbol:aGlobalName title:(self classResources string:'users of: %1' with:aGlobalName) warnIfNone:doWarn |
203 | 632 |
|
256 | 633 |
"Created: 9.12.1995 / 18:06:34 / cg" |
634 |
"Modified: 9.12.1995 / 18:11:45 / cg" |
|
203 | 635 |
! |
636 |
||
637 |
browseRefsTo:aString classVars:classVars in:aCollectionOfClasses modificationsOnly:modsOnly |
|
638 |
"launch a browser for all methods in aClass where the instVar/classVar named |
|
639 |
aString is referenced; if modsOnly is true, browse only methods where the |
|
640 |
instvar is modified" |
|
641 |
||
642 |
|title| |
|
643 |
||
644 |
modsOnly ifTrue:[ |
|
256 | 645 |
title := 'modifications of: %1' |
203 | 646 |
] ifFalse:[ |
256 | 647 |
title := 'references to: %1 ' |
203 | 648 |
]. |
649 |
^ self |
|
256 | 650 |
browseRefsTo:aString |
651 |
classVars:classVars |
|
652 |
in:aCollectionOfClasses |
|
653 |
modificationsOnly:modsOnly |
|
654 |
title:(self classResources string:title with:aString) |
|
655 |
||
656 |
"Created: 9.12.1995 / 18:07:05 / cg" |
|
657 |
"Modified: 9.12.1995 / 18:11:49 / cg" |
|
203 | 658 |
! |
659 |
||
660 |
browseRefsTo:varName classVars:classVars in:aCollectionOfClasses modificationsOnly:modsOnly title:title |
|
661 |
"launch a browser for all methods in aClass where the instVar/classVar named |
|
662 |
varName is referenced; if modsOnly is true, browse only methods where the |
|
663 |
instvar is modified" |
|
664 |
||
665 |
|filter browser pattern| |
|
666 |
||
667 |
filter := self filterToSearchRefsTo:varName classVars:classVars modificationsOnly:modsOnly. |
|
668 |
browser := self browseMethodsIn:aCollectionOfClasses |
|
669 |
inst:true class:classVars where:filter title:title. |
|
670 |
||
671 |
browser notNil ifTrue:[ |
|
672 |
modsOnly ifTrue:[ |
|
673 |
pattern := varName , ' :=' |
|
674 |
] ifFalse:[ |
|
675 |
pattern := varName |
|
676 |
]. |
|
677 |
browser autoSearch:pattern |
|
678 |
]. |
|
679 |
^ browser |
|
680 |
! |
|
681 |
||
256 | 682 |
browseSuperCallsIn:aCollectionOfClasses title:title |
683 |
"launch a browser for all super sends in aCollectionOfClasses" |
|
684 |
||
685 |
|sel browser searchBlock| |
|
686 |
||
687 |
searchBlock := [:class :method :s | |
|
688 |
|parser| |
|
689 |
||
690 |
parser := Parser parseMethod:method source in:class warnings:false. |
|
691 |
parser notNil and:[parser usesSuper] |
|
692 |
]. |
|
693 |
||
694 |
browser := self browseMethodsIn:aCollectionOfClasses |
|
695 |
where:searchBlock |
|
696 |
title:title. |
|
697 |
||
698 |
browser notNil ifTrue:[ |
|
699 |
browser autoSearch:'super' |
|
700 |
]. |
|
701 |
^ browser |
|
702 |
||
703 |
"Created: 23.11.1995 / 14:08:55 / cg" |
|
704 |
! |
|
705 |
||
706 |
browseSuperCallsUnder:aClass |
|
707 |
"launch a browser for all supersends in aClass and subclasses" |
|
708 |
||
709 |
^ self browseSuperCallsIn:(aClass withAllSubclasses) |
|
710 |
title:(self classResources string:'supersends (in and below %1)' with:aClass name) |
|
711 |
||
712 |
" |
|
713 |
SystemBrowser browseSuperCallsUnder:Number |
|
714 |
" |
|
715 |
||
716 |
"Created: 23.11.1995 / 12:06:06 / cg" |
|
717 |
"Modified: 9.12.1995 / 18:11:59 / cg" |
|
718 |
! |
|
719 |
||
52 | 720 |
browseUsesOf:aClass |
721 |
|dict owners offsets |
|
722 |
sz "{ Class: SmallInteger }" |
|
723 |
n "{ Class: SmallInteger }" |
|
724 |
removeSet newDict| |
|
725 |
||
726 |
owners := ObjectMemory whoReferencesInstancesOf:aClass. |
|
727 |
||
728 |
" |
|
729 |
collect set of offsets in dict; key is class |
|
730 |
" |
|
731 |
dict := IdentityDictionary new. |
|
732 |
owners do:[:someObject | |
|
733 |
|cls create| |
|
734 |
||
735 |
someObject isContext ifFalse:[ |
|
736 |
" |
|
737 |
someObject refers to an instance of aClass; |
|
738 |
find out, which instVar(s) |
|
739 |
" |
|
740 |
cls := someObject class. |
|
741 |
cls ~~ Array ifTrue:[ |
|
742 |
n := cls instSize. |
|
743 |
create := [|s| s := Set new. dict at:cls put:s. s]. |
|
744 |
||
745 |
1 to:n do:[:i | |
|
746 |
|ref| |
|
747 |
||
748 |
ref := someObject instVarAt:i. |
|
749 |
(ref isMemberOf:aClass) ifTrue:[ |
|
750 |
offsets := dict at:cls ifAbsent:create. |
|
751 |
offsets add:i. |
|
752 |
] |
|
753 |
]. |
|
754 |
cls isVariable ifTrue:[ |
|
755 |
cls isPointers ifTrue:[ |
|
756 |
| idx "{ Class: SmallInteger }" | |
|
757 |
||
758 |
sz := someObject basicSize. |
|
759 |
idx := 1. |
|
760 |
[idx <= sz] whileTrue:[ |
|
761 |
|ref| |
|
762 |
||
763 |
ref := someObject basicAt:idx. |
|
764 |
(ref isMemberOf:aClass) ifTrue:[ |
|
765 |
offsets := dict at:cls ifAbsent:create. |
|
766 |
offsets add:0. |
|
767 |
idx := sz |
|
768 |
]. |
|
769 |
idx := idx + 1 |
|
770 |
] |
|
771 |
] |
|
772 |
] |
|
773 |
] |
|
774 |
] |
|
775 |
]. |
|
776 |
||
777 |
" |
|
778 |
merge with superclass refs |
|
779 |
" |
|
780 |
dict keysAndValuesDo:[:cls :set | |
|
781 |
cls allSuperclasses do:[:aSuperclass | |
|
782 |
|superSet| |
|
783 |
||
784 |
superSet := dict at:aSuperclass ifAbsent:[]. |
|
785 |
superSet notNil ifTrue:[ |
|
786 |
|removeSet| |
|
787 |
||
788 |
superSet := dict at:aSuperclass. |
|
789 |
removeSet := Set new. |
|
790 |
set do:[:offset | |
|
791 |
(superSet includes:offset) ifTrue:[ |
|
792 |
removeSet add:offset |
|
793 |
] |
|
794 |
]. |
|
795 |
set removeAll:removeSet |
|
796 |
] |
|
797 |
] |
|
798 |
]. |
|
799 |
||
800 |
" |
|
801 |
remove empty ones |
|
802 |
" |
|
803 |
removeSet := Set new. |
|
804 |
dict keysAndValuesDo:[:cls :set | |
|
805 |
set isEmpty ifTrue:[ |
|
806 |
removeSet add:cls |
|
807 |
] |
|
808 |
]. |
|
809 |
removeSet do:[:cls | |
|
810 |
dict removeKey:cls |
|
811 |
]. |
|
812 |
||
813 |
" |
|
814 |
replace the indices by real names |
|
815 |
" |
|
816 |
newDict := IdentityDictionary new. |
|
817 |
dict keysAndValuesDo:[:cls :set | |
|
818 |
|newSet names| |
|
819 |
||
820 |
names := cls allInstVarNames. |
|
821 |
newSet := set collect:[:index | |
|
822 |
index == 0 ifTrue:['*indexed*'] ifFalse:[names at:index]. |
|
823 |
]. |
|
824 |
newDict at:cls put:newSet |
|
825 |
]. |
|
826 |
||
827 |
newDict inspect |
|
828 |
||
75 | 829 |
|
52 | 830 |
! |
831 |
||
203 | 832 |
filterToSearchRefsTo:varName classVars:classVars modificationsOnly:modsOnly |
833 |
"return a searchblock for variable references" |
|
834 |
||
835 |
|searchBlock| |
|
53 | 836 |
|
203 | 837 |
searchBlock := [:c :m :s | |
838 |
|src result parser vars needMatch| |
|
36 | 839 |
|
203 | 840 |
needMatch := varName includesMatchCharacters. |
36 | 841 |
|
203 | 842 |
src := m source. |
843 |
src isNil ifTrue:[ |
|
844 |
result := false |
|
845 |
] ifFalse:[ |
|
846 |
needMatch ifFalse:[ |
|
847 |
" |
|
848 |
before doing a slow parse, quickly scan the |
|
849 |
methods source for the variables name ... |
|
850 |
" |
|
851 |
result := (src findString:varName) ~~ 0. |
|
852 |
] ifTrue:[ |
|
853 |
result := true. |
|
854 |
]. |
|
855 |
result ifTrue:[ |
|
856 |
result := false. |
|
857 |
parser := Parser parseMethod:src in:c warnings:false. |
|
858 |
parser notNil ifTrue:[ |
|
859 |
classVars ifFalse:[ |
|
860 |
modsOnly ifTrue:[ |
|
861 |
vars := parser modifiedInstVars |
|
862 |
] ifFalse:[ |
|
863 |
vars := parser usedInstVars |
|
864 |
]. |
|
865 |
] ifTrue:[ |
|
866 |
modsOnly ifTrue:[ |
|
867 |
vars := parser modifiedClassVars |
|
868 |
] ifFalse:[ |
|
869 |
vars := parser usedClassVars |
|
870 |
]. |
|
871 |
]. |
|
872 |
vars notNil ifTrue:[ |
|
873 |
needMatch ifTrue:[ |
|
874 |
vars do:[:cv | |
|
875 |
(varName match:cv) ifTrue:[result := true] |
|
876 |
] |
|
877 |
] ifFalse:[ |
|
878 |
result := vars includes:varName |
|
879 |
] |
|
880 |
] |
|
881 |
]. |
|
882 |
]. |
|
883 |
]. |
|
884 |
Processor yield. |
|
885 |
result |
|
36 | 886 |
]. |
203 | 887 |
^ searchBlock |
888 |
! ! |
|
889 |
||
890 |
!SystemBrowser class methodsFor:'startup'! |
|
36 | 891 |
|
203 | 892 |
browseAllSelect:aBlock |
893 |
"launch a browser for all methods where aBlock returns true. |
|
894 |
The block is called with 3 arguments, class, method and seelctor." |
|
895 |
||
896 |
^ self browseMethodsWhere:aBlock title:'selected messages' |
|
36 | 897 |
|
53 | 898 |
" |
203 | 899 |
SystemBrowser browseAllSelect:[:aClass :aMethod :selector | selector numArgs == 3] |
53 | 900 |
" |
203 | 901 |
! |
75 | 902 |
|
203 | 903 |
browseClass:aClass |
904 |
"launch a browser for aClass" |
|
905 |
||
906 |
^ self |
|
907 |
newWithLabel:aClass name |
|
908 |
setupSelector:#setupForClass: |
|
909 |
arg:aClass |
|
910 |
||
911 |
"SystemBrowser browseClass:Object" |
|
912 |
! |
|
913 |
||
914 |
browseClass:aClass methodCategory:aCategory |
|
915 |
"launch a browser for all methods under aCategory in aClass" |
|
916 |
||
917 |
^ self newWithLabel:(aClass name , ' ' , aCategory) |
|
918 |
setupBlock:[:browser | browser setupForClass:aClass methodCategory:aCategory] |
|
919 |
||
920 |
"SystemBrowser browseClass:String methodCategory:'copying'" |
|
921 |
! |
|
922 |
||
923 |
browseClass:aClass selector:selector |
|
924 |
"launch a browser for the method at selector in aClass" |
|
925 |
||
926 |
^ self |
|
927 |
newWithLabel:(aClass name , ' ' , selector , ' ' , selector) |
|
928 |
setupBlock:[:newBrowser | newBrowser setupForClass:aClass selector:selector] |
|
929 |
||
930 |
" |
|
931 |
SystemBrowser browseClass:Object selector:#printString |
|
932 |
" |
|
36 | 933 |
! |
934 |
||
203 | 935 |
browseClassCategory:aClassCategory |
936 |
"launch a browser for all classes under aCategory" |
|
937 |
||
938 |
^ self |
|
939 |
newWithLabel:aClassCategory |
|
940 |
setupSelector:#setupForClassCategory: |
|
941 |
arg:aClassCategory |
|
942 |
||
943 |
"SystemBrowser browseClassCategory:'Kernel-Objects'" |
|
944 |
! |
|
945 |
||
946 |
browseClassHierarchy:aClass |
|
947 |
"launch a browser for aClass and all its superclasses. |
|
948 |
this is different from the fullProtocol browser." |
|
36 | 949 |
|
203 | 950 |
^ self |
951 |
newWithLabel:(aClass name , '-' , 'hierarchy') |
|
952 |
setupSelector:#setupForClassHierarchy: |
|
953 |
arg:aClass |
|
954 |
||
955 |
" |
|
956 |
SystemBrowser browseClassHierarchy:Number |
|
957 |
" |
|
958 |
! |
|
959 |
||
960 |
browseClasses:aList title:title |
|
961 |
"launch a browser for all classes in aList" |
|
962 |
||
963 |
^ self |
|
964 |
newWithLabel:title |
|
965 |
setupSelector:#setupForClassList: |
|
966 |
arg:aList |
|
967 |
||
968 |
" |
|
969 |
SystemBrowser browseClasses:(Array with:Object |
|
970 |
with:Float) |
|
971 |
title:'two classes' |
|
972 |
" |
|
52 | 973 |
! |
974 |
||
203 | 975 |
browseFullClassProtocol:aClass |
976 |
"launch a browser for aClasses full protocol. |
|
977 |
This is different from hierarchy browsing." |
|
978 |
||
979 |
^ self |
|
980 |
newWithLabel:(aClass name , '-' , 'full protocol') |
|
981 |
setupSelector:#setupForFullClassProtocol: |
|
982 |
arg:aClass |
|
983 |
||
984 |
" |
|
985 |
SystemBrowser browseFullClassProtocol:Number |
|
986 |
" |
|
987 |
! |
|
36 | 988 |
|
203 | 989 |
browseFullClasses |
990 |
"launch a browser showing all methods at once" |
|
991 |
||
992 |
^ self |
|
993 |
newWithLabel:'Full Class Browser' |
|
994 |
setupBlock:[:newBrowser | newBrowser setupForFullClass] |
|
36 | 995 |
|
203 | 996 |
"SystemBrowser browseFullClasses" |
997 |
! |
|
998 |
||
999 |
browseInstMethodsFrom:aClass where:aBlock title:title |
|
1000 |
"launch a browser for all instance methods in aClass and all subclasses |
|
1001 |
where aBlock evaluates to true" |
|
36 | 1002 |
|
203 | 1003 |
^ self browseMethodsIn:(aClass withAllSubclasses) inst:true class:false where:aBlock title:title |
1004 |
! |
|
1005 |
||
1006 |
browseInstMethodsIn:aCollectionOfClasses where:aBlock title:title |
|
1007 |
"launch a browser for all instance methods of all classes in |
|
1008 |
aCollectionOfClasses where aBlock evaluates to true" |
|
1009 |
||
1010 |
^ self browseMethodsIn:aCollectionOfClasses inst:true class:false |
|
1011 |
where:aBlock title:title |
|
1012 |
! |
|
36 | 1013 |
|
203 | 1014 |
browseInstMethodsOf:aClass where:aBlock title:title |
1015 |
"launch a browser for all instance methods in aClass |
|
1016 |
where aBlock evaluates to true" |
|
1017 |
||
1018 |
^ self browseMethodsIn:(Array with:aClass) inst:true class:false where:aBlock title:title |
|
1019 |
! |
|
1020 |
||
1021 |
browseMethodCategory:aCategory |
|
1022 |
"launch a browser for all methods where category = aCategory" |
|
1023 |
||
1024 |
|searchBlock| |
|
1025 |
||
1026 |
aCategory includesMatchCharacters ifTrue:[ |
|
1027 |
searchBlock := [:c :m :s | aCategory match:m category]. |
|
53 | 1028 |
] ifFalse:[ |
203 | 1029 |
searchBlock := [:c :m :s | m category = aCategory] |
53 | 1030 |
]. |
1031 |
||
203 | 1032 |
self browseMethodsWhere:searchBlock title:('all methods with category of ' , aCategory) |
1033 |
||
1034 |
" |
|
1035 |
SystemBrowser browseMethodCategory:'printing & storing' |
|
1036 |
SystemBrowser browseMethodCategory:'print*' |
|
1037 |
" |
|
1038 |
! |
|
1039 |
||
1040 |
browseMethods:aList title:aString |
|
1041 |
"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
|
1042 |
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
|
1043 |
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
|
1044 |
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
|
1045 |
|
062022b53f22
allow browseMethods to be passed a collection of methodObjects (in addition to strings)
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
1046 |
|l| |
203 | 1047 |
|
1048 |
(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
|
1049 |
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
|
1050 |
^ nil |
203 | 1051 |
]. |
279
062022b53f22
allow browseMethods to be passed a collection of methodObjects (in addition to strings)
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
1052 |
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
|
1053 |
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
|
1054 |
|who| |
062022b53f22
allow browseMethods to be passed a collection of methodObjects (in addition to strings)
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
1055 |
|
062022b53f22
allow browseMethods to be passed a collection of methodObjects (in addition to strings)
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
1056 |
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
|
1057 |
entry |
062022b53f22
allow browseMethods to be passed a collection of methodObjects (in addition to strings)
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
1058 |
] ifFalse:[ |
062022b53f22
allow browseMethods to be passed a collection of methodObjects (in addition to strings)
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
1059 |
|who| |
062022b53f22
allow browseMethods to be passed a collection of methodObjects (in addition to strings)
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
1060 |
|
062022b53f22
allow browseMethods to be passed a collection of methodObjects (in addition to strings)
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
1061 |
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
|
1062 |
(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
|
1063 |
] |
062022b53f22
allow browseMethods to be passed a collection of methodObjects (in addition to strings)
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
1064 |
]. |
062022b53f22
allow browseMethods to be passed a collection of methodObjects (in addition to strings)
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
1065 |
|
062022b53f22
allow browseMethods to be passed a collection of methodObjects (in addition to strings)
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
1066 |
l sort. |
203 | 1067 |
^ 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
|
1068 |
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
|
1069 |
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
|
1070 |
arg:l |
53 | 1071 |
|
203 | 1072 |
" |
1073 |
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
|
1074 |
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
|
1075 |
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
|
1076 |
|
062022b53f22
allow browseMethods to be passed a collection of methodObjects (in addition to strings)
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
1077 |
SystemBrowser |
062022b53f22
allow browseMethods to be passed a collection of methodObjects (in addition to strings)
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
1078 |
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
|
1079 |
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
|
1080 |
|
062022b53f22
allow browseMethods to be passed a collection of methodObjects (in addition to strings)
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
1081 |
SystemBrowser |
062022b53f22
allow browseMethods to be passed a collection of methodObjects (in addition to strings)
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
1082 |
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
|
1083 |
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
|
1084 |
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
|
1085 |
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
|
1086 |
|
203 | 1087 |
" |
279
062022b53f22
allow browseMethods to be passed a collection of methodObjects (in addition to strings)
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
1088 |
|
062022b53f22
allow browseMethods to be passed a collection of methodObjects (in addition to strings)
Claus Gittinger <cg@exept.de>
parents:
270
diff
changeset
|
1089 |
"Modified: 12.12.1995 / 16:34:27 / cg" |
203 | 1090 |
! |
53 | 1091 |
|
203 | 1092 |
browseMethodsFrom:aClass where:aBlock title:title |
1093 |
"launch a browser for all instance- and classmethods in aClass |
|
1094 |
and all its subclasses where aBlock evaluates to true. |
|
1095 |
The block is called with 3 arguments, class, method and seelctor." |
|
1096 |
||
1097 |
^ self browseMethodsIn:(aClass withAllSubclasses) where:aBlock title:title |
|
1098 |
! |
|
1099 |
||
1100 |
browseMethodsIn:aCollectionOfClasses inst:wantInst class:wantClass where:aBlock title:title |
|
1101 |
"launch a browser for all instance- (if wantInst is true) and/or |
|
1102 |
classmethods (if wantClass is true) from classes in aCollectionOfClasses, |
|
1103 |
where aBlock evaluates to true. |
|
270 | 1104 |
The block is called with 3 arguments, class, method and selector." |
203 | 1105 |
|
1106 |
|list| |
|
53 | 1107 |
|
1108 |
" |
|
203 | 1109 |
since this may take a long time, lower my priority ... |
53 | 1110 |
" |
203 | 1111 |
Processor activeProcess withLowerPriorityDo:[ |
270 | 1112 |
|checkedClasses checkBlock| |
75 | 1113 |
|
270 | 1114 |
checkedClasses := IdentitySet new. |
1115 |
list := OrderedCollection new. |
|
203 | 1116 |
|
270 | 1117 |
checkBlock := [:cls | |
1118 |
|methodArray selectorArray| |
|
203 | 1119 |
|
270 | 1120 |
(checkedClasses includes:cls) ifFalse:[ |
435 | 1121 |
cls isObsolete ifTrue:[ |
1122 |
Transcript showCr:'skipping obsolete class: ' , cls displayString |
|
1123 |
] ifFalse:[ |
|
1124 |
methodArray := cls methodArray. |
|
1125 |
selectorArray := cls selectorArray. |
|
203 | 1126 |
|
435 | 1127 |
1 to:methodArray size do:[:index | |
1128 |
|method sel| |
|
203 | 1129 |
|
435 | 1130 |
method := methodArray at:index. |
1131 |
sel := selectorArray at:index. |
|
436 | 1132 |
(aBlock value:cls value:method value:sel) ifTrue:[ |
435 | 1133 |
list add:(cls name , ' ' , sel) |
1134 |
] |
|
1135 |
]. |
|
1136 |
checkedClasses add:cls. |
|
1137 |
] |
|
270 | 1138 |
] |
1139 |
]. |
|
203 | 1140 |
|
270 | 1141 |
aCollectionOfClasses do:[:aClass | |
1142 |
" |
|
1143 |
output disabled - it slows down things too much (when searching for |
|
1144 |
implementors or senders) |
|
1145 |
" |
|
1146 |
wantInst ifTrue:[ |
|
203 | 1147 |
"/ Transcript show:'searching '; show:aClass name; showCr:' ...'; endEntry. |
270 | 1148 |
checkBlock value:aClass |
1149 |
]. |
|
1150 |
wantClass ifTrue:[ |
|
203 | 1151 |
"/ Transcript show:'searching '; show:aClass class name; showCr:' ...'; endEntry. |
270 | 1152 |
checkBlock value:(aClass class) |
1153 |
]. |
|
1154 |
Processor yield |
|
1155 |
] |
|
203 | 1156 |
]. |
1157 |
^ self browseMethods:list title:title |
|
270 | 1158 |
|
1159 |
"Created: 10.12.1995 / 15:34:57 / cg" |
|
53 | 1160 |
! |
1161 |
||
203 | 1162 |
browseMethodsIn:aCollectionOfClasses where:aBlock title:title |
1163 |
"launch a browser for all instance- and classmethods from |
|
1164 |
all classes in aCollectionOfClasses where aBlock evaluates to true. |
|
1165 |
The block is called with 3 arguments, class, method and seelctor." |
|
53 | 1166 |
|
203 | 1167 |
^ self browseMethodsIn:aCollectionOfClasses inst:true class:true where:aBlock title:title |
75 | 1168 |
|
36 | 1169 |
! |
1170 |
||
203 | 1171 |
browseMethodsOf:aClass where:aBlock title:title |
1172 |
"launch a browser for all instance- and classmethods in aClass |
|
1173 |
where aBlock evaluates to true. |
|
1174 |
The block is called with 3 arguments, class, method and seelctor." |
|
93 | 1175 |
|
203 | 1176 |
^ self browseMethodsIn:(Array with:aClass) where:aBlock title:title |
93 | 1177 |
! |
1178 |
||
203 | 1179 |
browseMethodsWhere:aBlock title:title |
1180 |
"launch a browser for all methods where aBlock returns true. |
|
1181 |
The block is called with 3 arguments, class, method and seelctor." |
|
1182 |
||
1183 |
^ self browseMethodsIn:(Smalltalk allClasses) where:aBlock title:title |
|
1184 |
! ! |
|
93 | 1185 |
|
203 | 1186 |
!SystemBrowser class methodsFor:'startup with query'! |
1187 |
||
1188 |
askThenBrowseClass |
|
1189 |
self getClassThenPerform:#browseClass: |
|
1190 |
||
1191 |
" |
|
1192 |
SystemBrowser askThenBrowseClass |
|
1193 |
" |
|
93 | 1194 |
! |
1195 |
||
203 | 1196 |
askThenBrowseClassHierarchy |
1197 |
self getClassThenPerform:#browseClassHierarchy: |
|
36 | 1198 |
|
203 | 1199 |
" |
1200 |
SystemBrowser askThenBrowseClassHierarchy |
|
1201 |
" |
|
36 | 1202 |
! |
1203 |
||
203 | 1204 |
askThenBrowseFullClassProtocol |
1205 |
self getClassThenPerform:#browseFullClassProtocol: |
|
36 | 1206 |
|
203 | 1207 |
" |
1208 |
SystemBrowser askThenBrowseFullClassProtocol |
|
1209 |
" |
|
52 | 1210 |
! |
1211 |
||
203 | 1212 |
getClassThenPerform:aSelector |
1213 |
|enterBox| |
|
52 | 1214 |
|
203 | 1215 |
enterBox := EnterBox title:(self classResources at:'Browse which class:') withCRs. |
254 | 1216 |
enterBox okText:(ClassResources at:'browse'). |
203 | 1217 |
enterBox entryCompletionBlock:[:contents | |
1218 |
|s what m| |
|
52 | 1219 |
|
203 | 1220 |
s := contents withoutSpaces. |
1221 |
what := Smalltalk classnameCompletion:s. |
|
1222 |
enterBox contents:what first. |
|
1223 |
]. |
|
1224 |
enterBox action:[:className | |
|
1225 |
|cls| |
|
52 | 1226 |
|
203 | 1227 |
cls := Smalltalk classNamed:className. |
1228 |
cls isNil ifTrue:[ |
|
254 | 1229 |
self warn:(ClassResources at:'no such class'). |
203 | 1230 |
] ifFalse:[ |
1231 |
self perform:aSelector with:cls |
|
1232 |
] |
|
1233 |
]. |
|
1234 |
enterBox showAtPointer |
|
75 | 1235 |
|
203 | 1236 |
" |
1237 |
SystemBrowser getClassThenPerform:#browseClass: |
|
1238 |
" |
|
36 | 1239 |
! ! |
1240 |
||
203 | 1241 |
!SystemBrowser class methodsFor:'documentation'! |
93 | 1242 |
|
203 | 1243 |
version |
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
|
1244 |
^ '$Header: /cvs/stx/stx/libtool/Attic/SBrowser.st,v 1.53 1996-04-12 17:09:48 cg Exp $' |
36 | 1245 |
! ! |
203 | 1246 |
SystemBrowser initialize! |