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