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