5591
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2000 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
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 |
|
|
13 |
"{ Package: 'stx:libtool' }"
|
|
14 |
|
|
15 |
"{ NameSpace: Tools }"
|
|
16 |
|
|
17 |
BrowserList subclass:#MethodList
|
|
18 |
instanceVariableNames:'classes selectedMethodNameIndices methodList lastSelectedMethods
|
|
19 |
browserNameList variableFilter filterClassVars updateProcess
|
|
20 |
lastShowClass lastShowCategory lastShowClassFirst
|
|
21 |
showMethodInheritance lastMethodClass lastMethodClassesSubclasses
|
|
22 |
classAndSelectorsRedefinedBySubclassesOfClass showClass'
|
|
23 |
classVariableNames:''
|
|
24 |
poolDictionaries:''
|
|
25 |
category:'Interface-Browsers-New'
|
|
26 |
!
|
|
27 |
|
|
28 |
!MethodList class methodsFor:'documentation'!
|
|
29 |
|
|
30 |
copyright
|
|
31 |
"
|
|
32 |
COPYRIGHT (c) 2000 by eXept Software AG
|
|
33 |
All Rights Reserved
|
|
34 |
|
|
35 |
This software is furnished under a license and may be used
|
|
36 |
only in accordance with the terms of that license and with the
|
|
37 |
inclusion of the above copyright notice. This software may not
|
|
38 |
be provided or otherwise made available to, or used by, any
|
|
39 |
other person. No title to or ownership of the software is
|
|
40 |
hereby transferred.
|
|
41 |
"
|
|
42 |
! !
|
|
43 |
|
|
44 |
!MethodList class methodsFor:'interface specs'!
|
|
45 |
|
|
46 |
singleMethodWindowSpec
|
|
47 |
"This resource specification was automatically generated
|
|
48 |
by the UIPainter of ST/X."
|
|
49 |
|
|
50 |
"Do not manually edit this!! If it is corrupted,
|
|
51 |
the UIPainter may not be able to read the specification."
|
|
52 |
|
|
53 |
"
|
|
54 |
UIPainter new openOnClass:MethodList andSelector:#singleMethodWindowSpec
|
|
55 |
MethodList new openInterface:#singleMethodWindowSpec
|
|
56 |
"
|
|
57 |
|
|
58 |
<resource: #canvas>
|
|
59 |
|
|
60 |
^
|
|
61 |
#(#FullSpec
|
|
62 |
#name: #singleMethodWindowSpec
|
|
63 |
#window:
|
|
64 |
#(#WindowSpec
|
|
65 |
#label: 'SingleSelectorList'
|
|
66 |
#name: 'SingleSelectorList'
|
|
67 |
#min: #(#Point 0 0)
|
|
68 |
#max: #(#Point 1024 721)
|
|
69 |
#bounds: #(#Rectangle 12 22 312 322)
|
|
70 |
)
|
|
71 |
#component:
|
|
72 |
#(#SpecCollection
|
|
73 |
#collection: #(
|
|
74 |
#(#LabelSpec
|
|
75 |
#label: 'MethodName'
|
|
76 |
#name: 'MethodLabel'
|
|
77 |
#layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 25 0)
|
|
78 |
#translateLabel: true
|
|
79 |
#labelChannel: #methodLabelHolder
|
|
80 |
#menu: #menuHolder
|
|
81 |
)
|
|
82 |
)
|
|
83 |
|
|
84 |
)
|
|
85 |
)
|
|
86 |
|
|
87 |
"Modified: / 1.3.2000 / 20:50:15 / cg"
|
|
88 |
!
|
|
89 |
|
|
90 |
windowSpec
|
|
91 |
"This resource specification was automatically generated
|
|
92 |
by the UIPainter of ST/X."
|
|
93 |
|
|
94 |
"Do not manually edit this!! If it is corrupted,
|
|
95 |
the UIPainter may not be able to read the specification."
|
|
96 |
|
|
97 |
"
|
|
98 |
UIPainter new openOnClass:MethodList andSelector:#windowSpec
|
|
99 |
MethodList new openInterface:#windowSpec
|
|
100 |
MethodList open
|
|
101 |
"
|
|
102 |
|
|
103 |
<resource: #canvas>
|
|
104 |
|
|
105 |
^
|
|
106 |
#(#FullSpec
|
|
107 |
#name: #windowSpec
|
|
108 |
#window:
|
|
109 |
#(#WindowSpec
|
|
110 |
#label: 'SelectorList'
|
|
111 |
#name: 'SelectorList'
|
|
112 |
#min: #(#Point 0 0)
|
|
113 |
#max: #(#Point 1024 721)
|
|
114 |
#bounds: #(#Rectangle 12 22 312 322)
|
|
115 |
)
|
|
116 |
#component:
|
|
117 |
#(#SpecCollection
|
|
118 |
#collection: #(
|
|
119 |
#(#SequenceViewSpec
|
|
120 |
#name: 'List'
|
|
121 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
|
|
122 |
#tabable: true
|
|
123 |
#model: #selectedMethodNameIndices
|
|
124 |
#menu: #menuHolder
|
|
125 |
#hasHorizontalScrollBar: true
|
|
126 |
#hasVerticalScrollBar: true
|
|
127 |
#miniScrollerHorizontal: true
|
|
128 |
#isMultiSelect: true
|
|
129 |
#valueChangeSelector: #selectionChangedByClick
|
|
130 |
#useIndex: true
|
|
131 |
#sequenceList: #browserNameList
|
|
132 |
#doubleClickChannel: #doubleClickChannel
|
|
133 |
)
|
|
134 |
)
|
|
135 |
|
|
136 |
)
|
|
137 |
)
|
|
138 |
! !
|
|
139 |
|
|
140 |
!MethodList class methodsFor:'plugIn spec'!
|
|
141 |
|
|
142 |
aspectSelectors
|
|
143 |
"This resource specification was automatically generated
|
|
144 |
by the UIPainter of ST/X."
|
|
145 |
|
|
146 |
"Do not manually edit this. If it is corrupted,
|
|
147 |
the UIPainter may not be able to read the specification."
|
|
148 |
|
|
149 |
"Return a description of exported aspects;
|
|
150 |
these can be connected to aspects of an embedding application
|
|
151 |
(if this app is embedded in a subCanvas)."
|
|
152 |
|
|
153 |
^ #(
|
|
154 |
#classHolder
|
|
155 |
#(#doubleClickChannel #action )
|
|
156 |
#forceGeneratorTrigger
|
|
157 |
#immediateUpdate
|
|
158 |
#inGeneratorHolder
|
|
159 |
#menuHolder
|
|
160 |
#methodCategoryHolder
|
|
161 |
#packageFilter
|
|
162 |
#selectedMethods
|
|
163 |
#selectionChangeCondition
|
|
164 |
#updateTrigger
|
|
165 |
#variableFilter
|
|
166 |
#filterClassVars
|
|
167 |
#showMethodInheritance
|
|
168 |
#sortBy
|
|
169 |
).
|
|
170 |
! !
|
|
171 |
|
|
172 |
!MethodList methodsFor:'aspects'!
|
|
173 |
|
|
174 |
browserNameList
|
|
175 |
browserNameList isNil ifTrue:[
|
|
176 |
browserNameList := List new.
|
|
177 |
].
|
|
178 |
^ browserNameList.
|
|
179 |
|
|
180 |
"Modified: / 31.1.2000 / 00:42:44 / cg"
|
|
181 |
"Created: / 5.2.2000 / 22:38:32 / cg"
|
|
182 |
!
|
|
183 |
|
|
184 |
defaultSlaveModeValue
|
|
185 |
^ false.
|
|
186 |
!
|
|
187 |
|
|
188 |
filterClassVars
|
|
189 |
filterClassVars isNil ifTrue:[
|
|
190 |
filterClassVars := false asValue.
|
|
191 |
filterClassVars addDependent:self
|
|
192 |
].
|
|
193 |
^ filterClassVars
|
|
194 |
!
|
|
195 |
|
|
196 |
filterClassVars:aValueHolder
|
|
197 |
filterClassVars notNil ifTrue:[
|
|
198 |
filterClassVars removeDependent:self
|
|
199 |
].
|
|
200 |
filterClassVars := aValueHolder.
|
|
201 |
filterClassVars notNil ifTrue:[
|
|
202 |
filterClassVars addDependent:self
|
|
203 |
].
|
|
204 |
!
|
|
205 |
|
|
206 |
methodLabelHolder
|
|
207 |
^ self pseudoListLabelHolder
|
|
208 |
|
|
209 |
"Created: / 1.3.2000 / 20:50:07 / cg"
|
|
210 |
!
|
|
211 |
|
|
212 |
methodList
|
|
213 |
^ methodList
|
|
214 |
!
|
|
215 |
|
|
216 |
selectedMethodNameIndices
|
|
217 |
selectedMethodNameIndices isNil ifTrue:[
|
|
218 |
selectedMethodNameIndices := ValueHolder new.
|
|
219 |
selectedMethodNameIndices addDependent:self
|
|
220 |
].
|
|
221 |
^ selectedMethodNameIndices.
|
|
222 |
|
|
223 |
"Modified: / 5.2.2000 / 00:31:48 / cg"
|
|
224 |
"Created: / 5.2.2000 / 22:59:31 / cg"
|
|
225 |
!
|
|
226 |
|
|
227 |
selectedMethods
|
|
228 |
^ self selectionHolder
|
|
229 |
!
|
|
230 |
|
|
231 |
selectedMethods:aValueHolder
|
|
232 |
^ self selectionHolder:aValueHolder
|
|
233 |
!
|
|
234 |
|
|
235 |
showMethodInheritance
|
|
236 |
showMethodInheritance isNil ifTrue:[
|
|
237 |
showMethodInheritance := false asValue.
|
|
238 |
showMethodInheritance addDependent:self
|
|
239 |
].
|
|
240 |
^ showMethodInheritance
|
|
241 |
!
|
|
242 |
|
|
243 |
showMethodInheritance:aValueHolder
|
|
244 |
showMethodInheritance notNil ifTrue:[
|
|
245 |
showMethodInheritance removeDependent:self
|
|
246 |
].
|
|
247 |
showMethodInheritance := aValueHolder.
|
|
248 |
showMethodInheritance notNil ifTrue:[
|
|
249 |
showMethodInheritance addDependent:self
|
|
250 |
].
|
|
251 |
!
|
|
252 |
|
|
253 |
variableFilter
|
|
254 |
variableFilter isNil ifTrue:[
|
|
255 |
variableFilter := nil asValue.
|
|
256 |
variableFilter addDependent:self
|
|
257 |
].
|
|
258 |
^ variableFilter
|
|
259 |
!
|
|
260 |
|
|
261 |
variableFilter:aValueHolder
|
|
262 |
variableFilter notNil ifTrue:[
|
|
263 |
variableFilter removeDependent:self
|
|
264 |
].
|
|
265 |
variableFilter := aValueHolder.
|
|
266 |
variableFilter notNil ifTrue:[
|
|
267 |
variableFilter addDependent:self
|
|
268 |
].
|
|
269 |
! !
|
|
270 |
|
|
271 |
!MethodList methodsFor:'change & update'!
|
|
272 |
|
|
273 |
delayedUpdate:something with:aParameter from:changedObject
|
|
274 |
|cls sel oldMethod newMethod methods newSelection
|
|
275 |
selectionHolder selection needSelectionChange|
|
|
276 |
|
|
277 |
selectionHolder := self selectedMethods.
|
|
278 |
selection := selectionHolder value.
|
|
279 |
|
|
280 |
changedObject == Smalltalk ifTrue:[
|
|
281 |
classes notNil ifTrue:[
|
|
282 |
something == #methodCategory ifTrue:[
|
|
283 |
"/ ignore here - methodCategoryList will tell me if required
|
|
284 |
^ self
|
|
285 |
].
|
|
286 |
something == #classOrganization ifTrue:[
|
|
287 |
"/ ignore here - methodCategoryList will tell me if required
|
|
288 |
^ self
|
|
289 |
].
|
|
290 |
|
|
291 |
something == #methodInClass ifTrue:[
|
|
292 |
"/ a method has been added/changed
|
|
293 |
cls := aParameter at:1.
|
|
294 |
(classes includesIdentical:cls) ifTrue:[
|
|
295 |
sel := aParameter at:2.
|
|
296 |
oldMethod := aParameter at:3.
|
|
297 |
newMethod := cls compiledMethodAt:sel.
|
|
298 |
(oldMethod notNil and:[newMethod notNil]) ifTrue:[
|
|
299 |
"a method was changed & acccepted;
|
|
300 |
No need for a rescan of the methodDictionary;
|
|
301 |
however, ensure that the refs to the old method are updated
|
|
302 |
"
|
|
303 |
methods := selection.
|
|
304 |
methods size > 0 ifTrue:[
|
|
305 |
(methods includesIdentical:oldMethod) ifTrue:[
|
|
306 |
needSelectionChange := true.
|
|
307 |
]
|
|
308 |
].
|
|
309 |
methodList replaceAllIdentical:oldMethod with:newMethod.
|
|
310 |
lastSelectedMethods notNil ifTrue:[
|
|
311 |
lastSelectedMethods replaceAllIdentical:oldMethod with:newMethod
|
|
312 |
].
|
|
313 |
methods size > 0 ifTrue:[
|
|
314 |
methods := methods asOrderedCollection.
|
|
315 |
methods replaceAllIdentical:oldMethod with:newMethod.
|
|
316 |
].
|
|
317 |
|
|
318 |
needSelectionChange == true ifTrue:[
|
|
319 |
selectionHolder setValue:methods.
|
|
320 |
selectionHolder changed.
|
|
321 |
].
|
|
322 |
(variableFilter value size > 0
|
|
323 |
or:[oldMethod package ~= newMethod package
|
|
324 |
or:[oldMethod resources ~= newMethod resources]]) ifTrue:[
|
|
325 |
"/ only update that methods entry
|
|
326 |
self updateListEntryFor:newMethod.
|
|
327 |
"/ sigh - must invalidate
|
|
328 |
"/ self invalidateList.
|
|
329 |
].
|
|
330 |
^ self.
|
|
331 |
].
|
|
332 |
"/ method was added - update the methodList
|
|
333 |
"/ Q: is this needed (methodCategoryList should send me a new inGenerator)
|
|
334 |
self invalidateList.
|
|
335 |
].
|
|
336 |
^ self.
|
|
337 |
].
|
|
338 |
|
|
339 |
something == #methodInClassRemoved ifTrue:[
|
|
340 |
cls := aParameter at:1.
|
|
341 |
(classes includesIdentical:cls) ifTrue:[
|
|
342 |
sel := aParameter at:2.
|
|
343 |
"/ method was removed - update the methodList
|
|
344 |
"/ Q: is this needed (methodCategoryList should send me a new inGenerator)
|
|
345 |
self invalidateList.
|
|
346 |
].
|
|
347 |
^ self.
|
|
348 |
].
|
|
349 |
|
|
350 |
something == #methodTrap ifTrue:[
|
|
351 |
cls := aParameter at:1.
|
|
352 |
sel := aParameter at:2.
|
|
353 |
(classes includesIdentical:cls) ifTrue:[
|
|
354 |
newMethod := cls compiledMethodAt:sel.
|
|
355 |
newMethod isNil ifTrue:[
|
|
356 |
self invalidateList.
|
|
357 |
^ self
|
|
358 |
].
|
|
359 |
newMethod isWrapped ifTrue:[
|
|
360 |
oldMethod := newMethod originalMethod
|
|
361 |
] ifFalse:[
|
|
362 |
selection size > 0 ifTrue:[
|
|
363 |
oldMethod := selection detect:[:each | each isWrapped and:[each originalMethod == newMethod]] ifNone:nil.
|
|
364 |
]
|
|
365 |
].
|
|
366 |
|
|
367 |
selection size > 0 ifTrue:[
|
|
368 |
(selection includesIdentical:oldMethod) ifTrue:[
|
|
369 |
needSelectionChange := true.
|
|
370 |
]
|
|
371 |
].
|
|
372 |
methodList replaceAllIdentical:oldMethod with:newMethod.
|
|
373 |
lastSelectedMethods notNil ifTrue:[
|
|
374 |
lastSelectedMethods replaceAllIdentical:oldMethod with:newMethod
|
|
375 |
].
|
|
376 |
selection size > 0 ifTrue:[
|
|
377 |
selection := selection asOrderedCollection.
|
|
378 |
selection replaceAllIdentical:oldMethod with:newMethod.
|
|
379 |
].
|
|
380 |
needSelectionChange == true ifTrue:[
|
|
381 |
selectionHolder changed.
|
|
382 |
].
|
|
383 |
|
|
384 |
"/ actually, could just change that single item ...
|
|
385 |
"/ ... might be cheaper, if list is huge.
|
|
386 |
"/ only update that methods entry
|
|
387 |
self updateListEntryFor:newMethod.
|
|
388 |
"/ self invalidateList.
|
|
389 |
].
|
|
390 |
^ self
|
|
391 |
].
|
|
392 |
|
|
393 |
something == #projectOrganization ifTrue:[
|
|
394 |
aParameter notNil ifTrue:[
|
|
395 |
cls := aParameter at:1.
|
|
396 |
cls notNil ifTrue:[
|
|
397 |
((classes includesIdentical:cls theNonMetaclass)
|
|
398 |
or:[(classes includesIdentical:cls theMetaclass)]) ifTrue:[
|
|
399 |
self invalidateList.
|
|
400 |
].
|
|
401 |
].
|
|
402 |
] ifFalse:[
|
|
403 |
self invalidateList.
|
|
404 |
].
|
|
405 |
^ self
|
|
406 |
].
|
|
407 |
"/ everything else is ignored
|
|
408 |
"/ self halt.
|
|
409 |
].
|
|
410 |
^ self
|
|
411 |
].
|
|
412 |
|
|
413 |
"/ something == #organization ifTrue:[
|
|
414 |
"/self halt:'no longer'.
|
|
415 |
"/^ self.
|
|
416 |
"/ "/ a methods cateory has changed
|
|
417 |
"/ (classes includesIdentical:changedObject) ifTrue:[
|
|
418 |
"/ aParameter isSymbol ifTrue:[
|
|
419 |
"/ "/ a method with a new category
|
|
420 |
"/ (self methodList includesIdentical:(changedObject compiledMethodAt:aParameter)) ifTrue:[
|
|
421 |
"/ self invalidateList.
|
|
422 |
"/ ].
|
|
423 |
"/ ^ self.
|
|
424 |
"/ ].
|
|
425 |
"/ "/ a new category (no method yet)
|
|
426 |
"/ self invalidateList
|
|
427 |
"/ ].
|
|
428 |
"/ ^ self
|
|
429 |
"/ ].
|
|
430 |
|
|
431 |
"/ something == #methodDictionary ifTrue:[
|
|
432 |
"/self halt:'no longer'.
|
|
433 |
"/^ self.
|
|
434 |
"/ "/ a method has been added/removed
|
|
435 |
"/ (classes includesIdentical:changedObject) ifTrue:[
|
|
436 |
"/ aParameter isArray ifTrue:[
|
|
437 |
"/ sel := aParameter at:1.
|
|
438 |
"/ oldMethod := aParameter at:2.
|
|
439 |
"/ newMethod := changedObject compiledMethodAt:sel.
|
|
440 |
"/ oldMethod notNil ifTrue:[
|
|
441 |
"/ "a method was changed & acccepted;
|
|
442 |
"/ No need for a rescan of the methodDictionary;
|
|
443 |
"/ however, ensure that the refs to the old method are updated
|
|
444 |
"/ "
|
|
445 |
"/ methods := selection.
|
|
446 |
"/ methods size > 0 ifTrue:[
|
|
447 |
"/ (methods includesIdentical:oldMethod) ifTrue:[
|
|
448 |
"/ needSelectionChange := true.
|
|
449 |
"/ ]
|
|
450 |
"/ ].
|
|
451 |
"/ methodList replaceAllIdentical:oldMethod with:newMethod.
|
|
452 |
"/ lastSelectedMethods notNil ifTrue:[
|
|
453 |
"/ lastSelectedMethods replaceAllIdentical:oldMethod with:newMethod
|
|
454 |
"/ ].
|
|
455 |
"/ methods size > 0 ifTrue:[
|
|
456 |
"/ methods := methods asOrderedCollection.
|
|
457 |
"/ methods replaceAllIdentical:oldMethod with:newMethod.
|
|
458 |
"/ ].
|
|
459 |
"/ needSelectionChange == true ifTrue:[
|
|
460 |
"/ selectionHolder setValue:methods.
|
|
461 |
"/ selectionHolder changed.
|
|
462 |
"/ ].
|
|
463 |
"/ ^ self.
|
|
464 |
"/ ]
|
|
465 |
"/ ].
|
|
466 |
"/ "/ class has changed must update the methodList
|
|
467 |
"/ self invalidateList.
|
|
468 |
"/ ].
|
|
469 |
"/ ^ self.
|
|
470 |
"/ ].
|
|
471 |
|
|
472 |
"/ something == #projectOrganization ifTrue:[
|
|
473 |
"/ ((classes includesIdentical:changedObject theNonMetaclass)
|
|
474 |
"/ or:[(classes includesIdentical:changedObject theMetaclass)]) ifTrue:[
|
|
475 |
"/ self invalidateList.
|
|
476 |
"/ ].
|
|
477 |
"/ ^ self
|
|
478 |
"/ ].
|
|
479 |
|
|
480 |
changedObject == sortBy ifTrue:[
|
|
481 |
listValid ~~ true ifTrue:[ "/ could be nil
|
|
482 |
inGeneratorHolder value isNil ifTrue:[
|
|
483 |
"/ ok, no need to react on that one
|
|
484 |
"/ (will invalidate anyway, once I have more info at hand)
|
|
485 |
^ self
|
|
486 |
].
|
|
487 |
].
|
|
488 |
self invalidateList.
|
|
489 |
^ self
|
|
490 |
].
|
|
491 |
|
|
492 |
(changedObject == variableFilter
|
|
493 |
or:[changedObject == filterClassVars
|
|
494 |
or:[changedObject == showMethodInheritance]]) ifTrue:[
|
|
495 |
self invalidateList.
|
|
496 |
^ self
|
|
497 |
].
|
|
498 |
|
|
499 |
changedObject == selectedMethodNameIndices ifTrue:[
|
|
500 |
newSelection := self selectedMethodNameIndices value collect:[:idx | methodList at:idx].
|
|
501 |
newSelection ~= selection ifTrue:[
|
|
502 |
selectionHolder value:newSelection.
|
|
503 |
lastSelectedMethods := newSelection.
|
|
504 |
lastSelectedMethods notNil ifTrue:[
|
|
505 |
lastSelectedMethods := lastSelectedMethods asOrderedCollection
|
|
506 |
].
|
|
507 |
] ifFalse:[
|
|
508 |
"/ a reselect - force update
|
|
509 |
"/ selection size == 1 ifTrue:[
|
|
510 |
selectionHolder setValue:newSelection.
|
|
511 |
selectionHolder changed:#value.
|
|
512 |
"/ ].
|
|
513 |
].
|
|
514 |
^ self
|
|
515 |
].
|
|
516 |
changedObject == selectionHolder ifTrue:[
|
|
517 |
self selectedMethodsChanged.
|
|
518 |
lastSelectedMethods := selectionHolder value.
|
|
519 |
lastSelectedMethods notNil ifTrue:[
|
|
520 |
lastSelectedMethods := lastSelectedMethods asOrderedCollection
|
|
521 |
].
|
|
522 |
^ self
|
|
523 |
].
|
|
524 |
"/ something == #methodTrap ifTrue:[
|
|
525 |
"/self halt:'no longer'.
|
|
526 |
"/^ self.
|
|
527 |
"/ (classes includesIdentical:changedObject) ifTrue:[
|
|
528 |
"/ newMethod := changedObject compiledMethodAt:aParameter.
|
|
529 |
"/ newMethod isNil ifTrue:[
|
|
530 |
"/ self invalidateList.
|
|
531 |
"/ ^ self
|
|
532 |
"/ ].
|
|
533 |
"/ newMethod isWrapped ifTrue:[
|
|
534 |
"/ oldMethod := newMethod originalMethod
|
|
535 |
"/ ] ifFalse:[
|
|
536 |
"/ selection size > 0 ifTrue:[
|
|
537 |
"/ oldMethod := selection detect:[:each | each isWrapped and:[each originalMethod == newMethod]] ifNone:nil.
|
|
538 |
"/ ]
|
|
539 |
"/ ].
|
|
540 |
"/
|
|
541 |
"/ selection size > 0 ifTrue:[
|
|
542 |
"/ (selection includesIdentical:oldMethod) ifTrue:[
|
|
543 |
"/ needSelectionChange := true.
|
|
544 |
"/ ]
|
|
545 |
"/ ].
|
|
546 |
"/"/ methodList replaceAllIdentical:oldMethod with:newMethod.
|
|
547 |
"/ lastSelectedMethods notNil ifTrue:[
|
|
548 |
"/ lastSelectedMethods replaceAllIdentical:oldMethod with:newMethod
|
|
549 |
"/ ].
|
|
550 |
"/ selection size > 0 ifTrue:[
|
|
551 |
"/ selection := selection asOrderedCollection.
|
|
552 |
"/ selection replaceAllIdentical:oldMethod with:newMethod.
|
|
553 |
"/ ].
|
|
554 |
"/ needSelectionChange == true ifTrue:[
|
|
555 |
"/ selectionHolder changed.
|
|
556 |
"/ ].
|
|
557 |
"/ self invalidateList.
|
|
558 |
"/ ^ self
|
|
559 |
"/ ].
|
|
560 |
"/ ^ self
|
|
561 |
"/ ].
|
|
562 |
super delayedUpdate:something with:aParameter from:changedObject
|
|
563 |
|
|
564 |
"Created: / 5.2.2000 / 13:42:14 / cg"
|
|
565 |
"Modified: / 6.2.2000 / 00:05:26 / cg"
|
|
566 |
!
|
|
567 |
|
|
568 |
selectedMethodsChanged
|
|
569 |
"the set of selected methods has changed;
|
|
570 |
update the selection-index collection (for the selectionInListView)"
|
|
571 |
|
|
572 |
|indices methods reverseMap
|
|
573 |
selectedMethodsHolder selectedMethods selectedMethodNameIndicesHolder|
|
|
574 |
|
|
575 |
methods := methodList ? #().
|
|
576 |
methods size == 0 ifTrue:[
|
|
577 |
"/ this may happen during early startup,
|
|
578 |
"/ when invoked with a preset methodSelection,
|
|
579 |
"/ and the methodGenerator has not yet been setup
|
|
580 |
"/ to not clobber the selection, defer the update
|
|
581 |
"/ until the methodList arrives ...
|
|
582 |
^ self
|
|
583 |
].
|
|
584 |
|
|
585 |
selectedMethodsHolder := self selectedMethods.
|
|
586 |
selectedMethods := selectedMethodsHolder value.
|
|
587 |
|
|
588 |
"/ check if all is selected (likely)
|
|
589 |
((selectedMethods size == methodList size)
|
|
590 |
and:[selectedMethods = methodList]) ifTrue:[
|
|
591 |
indices := (1 to:selectedMethods size)
|
|
592 |
] ifFalse:[
|
|
593 |
selectedMethods size > 100 ifTrue:[
|
|
594 |
"/ check if all is selected (likely)
|
|
595 |
((selectedMethods size == methodList size)
|
|
596 |
and:[selectedMethods = methodList]) ifTrue:[
|
|
597 |
indices := (1 to:selectedMethods size)
|
|
598 |
] ifFalse:[
|
|
599 |
"/ for big collections, generate a reverse map
|
|
600 |
reverseMap := IdentityDictionary new.
|
|
601 |
methods keysAndValuesDo:[:idx :mthd | reverseMap at:mthd put:idx].
|
|
602 |
indices := selectedMethods collect:[:eachSelectedMethod |
|
|
603 |
reverseMap at:eachSelectedMethod ifAbsent:0
|
|
604 |
]
|
|
605 |
]
|
|
606 |
] ifFalse:[
|
|
607 |
indices := (selectedMethods ? #()) collect:[:eachSelectedMethod |
|
|
608 |
methods identityIndexOf:eachSelectedMethod.
|
|
609 |
]
|
|
610 |
].
|
|
611 |
indices := indices select:[:idx | idx ~= 0].
|
|
612 |
].
|
|
613 |
|
|
614 |
selectedMethodNameIndicesHolder := self selectedMethodNameIndices.
|
|
615 |
selectedMethodNameIndicesHolder value ~= indices ifTrue:[
|
|
616 |
selectedMethodNameIndicesHolder value:indices.
|
|
617 |
]
|
|
618 |
!
|
|
619 |
|
|
620 |
selectionChanged
|
|
621 |
|methods|
|
|
622 |
|
|
623 |
methods := ((self selectedMethodNameIndices value) ? #()) collect:[:idx | methodList at:idx].
|
|
624 |
methods notEmpty ifTrue:[
|
|
625 |
lastSelectedMethods := methods asOrderedCollection.
|
|
626 |
].
|
|
627 |
"/ to allow reselect, change my valueHolder, even if the same collection
|
|
628 |
"/ self selectedMethods value ~= methods ifTrue:[
|
|
629 |
self selectedMethods value:methods
|
|
630 |
"/ ]
|
|
631 |
|
|
632 |
"Created: / 5.2.2000 / 13:42:14 / cg"
|
|
633 |
"Modified: / 5.2.2000 / 23:32:20 / cg"
|
|
634 |
!
|
|
635 |
|
|
636 |
selectionChangedByClick
|
|
637 |
"we are not interested in that - get another notification
|
|
638 |
via the changed valueHolder"
|
|
639 |
|
|
640 |
!
|
|
641 |
|
|
642 |
update:something with:aParameter from:changedObject
|
|
643 |
|cls|
|
|
644 |
|
|
645 |
"/ some can be ignored immediately
|
|
646 |
changedObject == Smalltalk ifTrue:[
|
|
647 |
classes isNil ifTrue:[
|
|
648 |
^ self.
|
|
649 |
].
|
|
650 |
something isNil ifTrue:[
|
|
651 |
"/ self halt "/ huh - Smalltalk changed - so what ?
|
|
652 |
^ self.
|
|
653 |
].
|
|
654 |
something == #classComment ifTrue:[
|
|
655 |
^ self.
|
|
656 |
].
|
|
657 |
something == #classVariables ifTrue:[
|
|
658 |
^ self.
|
|
659 |
].
|
|
660 |
something == #organization ifTrue:[
|
|
661 |
^ self.
|
|
662 |
].
|
|
663 |
something == #methodCategory ifTrue:[
|
|
664 |
"/ ignore here - methodCategoryList will tell me if required
|
|
665 |
^ self
|
|
666 |
].
|
|
667 |
something == #classOrganization ifTrue:[
|
|
668 |
"/ ignore here - methodCategoryList will tell me if required
|
|
669 |
^ self
|
|
670 |
].
|
|
671 |
something == #methodTrap ifTrue:[
|
|
672 |
cls := aParameter at:1.
|
|
673 |
(classes includesIdentical:cls) ifFalse:[
|
|
674 |
^ self
|
|
675 |
].
|
|
676 |
].
|
|
677 |
|
|
678 |
classAndSelectorsRedefinedBySubclassesOfClass := nil.
|
|
679 |
|
|
680 |
something == #classDefinition ifTrue:[
|
|
681 |
cls := aParameter.
|
|
682 |
(classes contains:[:aClass | aClass name == cls name]) ifFalse:[
|
|
683 |
^ self "/ I dont care for that class
|
|
684 |
].
|
|
685 |
classes := classes collect:[:eachClass | eachClass isMeta ifTrue:[
|
|
686 |
(Smalltalk at:eachClass theNonMetaclass name) class
|
|
687 |
] ifFalse:[
|
|
688 |
Smalltalk at:eachClass name
|
|
689 |
]
|
|
690 |
].
|
|
691 |
self updateList.
|
|
692 |
^ self.
|
|
693 |
].
|
|
694 |
something == #newClass ifTrue:[
|
|
695 |
^ self.
|
|
696 |
].
|
|
697 |
something == #classRemove ifTrue:[
|
|
698 |
^ self.
|
|
699 |
].
|
|
700 |
something == #classRename ifTrue:[
|
|
701 |
^ self.
|
|
702 |
].
|
|
703 |
].
|
|
704 |
|
|
705 |
"/ these must lead to immediate update of the selectedMethods collection
|
|
706 |
"/ (otherwise, that collection might be updated too late, leading to
|
|
707 |
"/ an obsolete methods code being shown by the codeView.
|
|
708 |
something == #methodInClass ifTrue:[
|
|
709 |
classAndSelectorsRedefinedBySubclassesOfClass := nil.
|
|
710 |
cls := aParameter at:1.
|
|
711 |
(classes includesIdentical:cls) ifFalse:[
|
|
712 |
^ self "/ I dont care for that class
|
|
713 |
].
|
|
714 |
self enqueueDelayedUpdate:something with:aParameter from:changedObject.
|
|
715 |
^ self
|
|
716 |
].
|
|
717 |
|
|
718 |
something == #methodInClassRemoved ifTrue:[
|
|
719 |
cls := aParameter at:1.
|
|
720 |
(classes includesIdentical:cls) ifFalse:[
|
|
721 |
^ self "/ I dont care for that class
|
|
722 |
].
|
|
723 |
].
|
|
724 |
|
|
725 |
something == #methodTrap ifTrue:[
|
|
726 |
self window shown ifFalse:[
|
|
727 |
changedObject removeDependent:self. "/ ?????
|
|
728 |
^ self
|
|
729 |
].
|
|
730 |
cls := aParameter at:1.
|
|
731 |
(classes includesIdentical:cls) ifFalse:[
|
|
732 |
^ self "/ I dont care for that class
|
|
733 |
].
|
|
734 |
].
|
|
735 |
|
|
736 |
super update:something with:aParameter from:changedObject
|
|
737 |
! !
|
|
738 |
|
|
739 |
!MethodList methodsFor:'private'!
|
|
740 |
|
|
741 |
listEntryForMethod:aMethod selector:selector class:cls showClass:showClass showCategory:showCategory classFirst:showClassFirst
|
|
742 |
"answer a method list entry
|
|
743 |
gimmics:
|
|
744 |
adding a little image to breakPointed methods,
|
|
745 |
inheritance indicators,
|
|
746 |
highlight accessors of variable"
|
|
747 |
|
|
748 |
|clsName s icn variablesToHighlight classVarsToHighLight
|
|
749 |
doHighLight doHighLightRed emp cat l redefIcon|
|
|
750 |
|
|
751 |
aMethod isAssociation ifTrue:[
|
|
752 |
self halt:'should not happen'.
|
|
753 |
].
|
|
754 |
|
|
755 |
s := aMethod printStringForBrowserWithSelector:selector inClass:cls.
|
|
756 |
showClassFirst ifTrue:[
|
|
757 |
clsName := cls nameInBrowser.
|
|
758 |
s := clsName , ' ' , s allBold
|
|
759 |
].
|
|
760 |
|
|
761 |
"/
|
|
762 |
"/ wrap icons (i.e. break- or trace points)
|
|
763 |
"/ have higher prio ...
|
|
764 |
"/
|
|
765 |
aMethod isWrapped ifTrue:[
|
|
766 |
(s endsWith:' !!') ifTrue:[
|
|
767 |
s := s copyWithoutLast:2
|
|
768 |
].
|
|
769 |
aMethod isBreakpointed ifTrue:[
|
|
770 |
icn := self stopIcon
|
|
771 |
] ifFalse:[
|
|
772 |
aMethod isTimed ifTrue:[
|
|
773 |
icn := self timeIcon
|
|
774 |
] ifFalse:[
|
|
775 |
icn := self traceIcon
|
|
776 |
]
|
|
777 |
].
|
|
778 |
].
|
|
779 |
|
|
780 |
icn isNil ifTrue:[
|
|
781 |
icn := self resourceIconForMethod:aMethod.
|
|
782 |
icn isNil ifTrue:[
|
|
783 |
aMethod isProtected ifTrue:[
|
|
784 |
icn := self protectedMethodIcon
|
|
785 |
] ifFalse:[
|
|
786 |
aMethod isPrivate ifTrue:[
|
|
787 |
icn := self privateMethodIcon
|
|
788 |
] ifFalse:[
|
|
789 |
(aMethod isJavaMethod and:[aMethod isAbstract]) ifTrue:[
|
|
790 |
icn := self abstractMethodIcon
|
|
791 |
]
|
|
792 |
]
|
|
793 |
].
|
|
794 |
].
|
|
795 |
].
|
|
796 |
icn isNil ifTrue:[
|
|
797 |
(selector startsWith:'test') ifTrue:[
|
|
798 |
((cls isSubclassOf:TestCase)
|
|
799 |
and:[cls isAbstract not]) ifTrue:[
|
|
800 |
cls lastTestRunResultOrNil == false ifTrue:[
|
|
801 |
(cls testSelectorFailed:selector) ifTrue:[
|
|
802 |
icn := SystemBrowser testCaseFailedIcon
|
|
803 |
] ifFalse:[
|
|
804 |
"/ icn := SystemBrowser testCasePassedIcon
|
|
805 |
].
|
|
806 |
]
|
|
807 |
].
|
|
808 |
]
|
|
809 |
].
|
|
810 |
|
|
811 |
showClass ifTrue:[
|
|
812 |
showClassFirst ifFalse:[
|
|
813 |
s := s , ' [' , cls name allBold , ']'.
|
|
814 |
]
|
|
815 |
].
|
|
816 |
showCategory ifTrue:[
|
|
817 |
cat := aMethod category.
|
|
818 |
cat notNil ifTrue:[
|
|
819 |
s := s , ' {' , cat "asText allItalic" , '}'
|
|
820 |
]
|
|
821 |
].
|
|
822 |
|
|
823 |
variablesToHighlight := variableFilter value.
|
|
824 |
variablesToHighlight size > 0 ifTrue:[
|
|
825 |
classVarsToHighLight := filterClassVars value.
|
|
826 |
classVarsToHighLight ifTrue:[
|
|
827 |
doHighLight := self method:aMethod includesRefsToClassVariable:variablesToHighlight.
|
|
828 |
doHighLight ifTrue:[
|
|
829 |
doHighLightRed := self method:aMethod includesModsOfClassVariable:variablesToHighlight.
|
|
830 |
].
|
|
831 |
] ifFalse:[
|
|
832 |
doHighLight := self method:aMethod includesRefsToInstanceVariable:variablesToHighlight.
|
|
833 |
doHighLight ifTrue:[
|
|
834 |
doHighLightRed := self method:aMethod includesModsOfInstanceVariable:variablesToHighlight
|
|
835 |
]
|
|
836 |
].
|
|
837 |
doHighLight ifTrue:[
|
|
838 |
s := s allBold.
|
|
839 |
doHighLightRed ifTrue:[
|
|
840 |
emp := (UserPreferences current emphasisForWrittenVariable)
|
|
841 |
] ifFalse:[
|
|
842 |
emp := (UserPreferences current emphasisForReadVariable)
|
|
843 |
].
|
|
844 |
s := s emphasisAllAdd:emp
|
|
845 |
]
|
|
846 |
].
|
|
847 |
|
|
848 |
showMethodInheritance value ~~ false ifTrue:[
|
|
849 |
redefIcon := self redefinedOrInheritedIconFor:aMethod.
|
|
850 |
].
|
|
851 |
|
|
852 |
(icn notNil or:[redefIcon notNil]) ifTrue:[
|
|
853 |
l := LabelAndIcon icon:redefIcon string:s.
|
|
854 |
l image:icn.
|
|
855 |
l gap:2.
|
|
856 |
^ l
|
|
857 |
].
|
|
858 |
^ s
|
|
859 |
|
|
860 |
"Created: / 22.10.1996 / 19:51:00 / cg"
|
|
861 |
"Modified: / 31.10.2001 / 10:46:50 / cg"
|
|
862 |
!
|
|
863 |
|
|
864 |
listOfMethodNames
|
|
865 |
|methods entries selectorBag newNameList
|
|
866 |
allClasses newClasses allCategories "allSelectors" generator
|
|
867 |
doShowClass doShowClassFirst doShowCategory
|
|
868 |
enforceClassAndProtocolInList theMethod sortByClass anyMethodToWatch mclass|
|
|
869 |
|
|
870 |
generator := inGeneratorHolder value.
|
|
871 |
generator isNil ifTrue:[^ #() ].
|
|
872 |
|
|
873 |
allClasses := IdentitySet new.
|
|
874 |
allCategories := IdentitySet new. "/ not needed - all I need to know is if there is more than 1 category
|
|
875 |
"/ allSelectors := Set new.
|
|
876 |
newClasses := IdentitySet new.
|
|
877 |
selectorBag := Bag new.
|
|
878 |
entries := OrderedCollection new.
|
|
879 |
enforceClassAndProtocolInList := false.
|
|
880 |
anyMethodToWatch := false.
|
|
881 |
|
|
882 |
"/ generator generates nil-selector entries
|
|
883 |
"/ to pass multiple-class and multiple-protocol info
|
|
884 |
generator do:[:cls :cat :sel :mthd |
|
|
885 |
(cls isNil and:[cat isNil and:[sel isNil]])
|
|
886 |
ifTrue:[
|
|
887 |
enforceClassAndProtocolInList := true
|
|
888 |
] ifFalse:[
|
|
889 |
cls notNil ifTrue:[
|
|
890 |
allClasses add:cls.
|
|
891 |
].
|
|
892 |
cat notNil ifTrue:[
|
|
893 |
allCategories add:cat.
|
|
894 |
].
|
|
895 |
sel notNil ifTrue:[
|
|
896 |
entries add:(Array with:cls with:sel with:mthd).
|
|
897 |
selectorBag add:sel.
|
|
898 |
newClasses add:cls.
|
|
899 |
"/ allSelectors add:sel.
|
|
900 |
]
|
|
901 |
].
|
|
902 |
(mthd notNil and:[mthd isWrapped]) ifTrue:[
|
|
903 |
(mthd isTiming
|
|
904 |
or:[mthd isCounting
|
|
905 |
or:[mthd isCountingMemoryUsage]])
|
|
906 |
ifTrue:[
|
|
907 |
anyMethodToWatch := true
|
|
908 |
]
|
|
909 |
].
|
|
910 |
].
|
|
911 |
|
|
912 |
showMethodInheritance value ~~ false ifTrue:[
|
|
913 |
"/ collect redefinition information once (big speedup for #methodIsRedefinedbelow)
|
|
914 |
classAndSelectorsRedefinedBySubclassesOfClass isNil ifTrue:[
|
|
915 |
classAndSelectorsRedefinedBySubclassesOfClass := IdentityDictionary new.
|
|
916 |
].
|
|
917 |
allClasses do:[:cls | |d|
|
|
918 |
d := classAndSelectorsRedefinedBySubclassesOfClass.
|
|
919 |
(d notNil and:[ (d includesKey:cls) not ]) ifTrue:[
|
|
920 |
d at:cls put:(self setOfAllSelectorsImplementedBelow:cls)
|
|
921 |
]
|
|
922 |
].
|
|
923 |
].
|
|
924 |
|
|
925 |
"/ multiple classes must: add the className for some
|
|
926 |
doShowClass := enforceClassAndProtocolInList or:[allClasses size > 1].
|
|
927 |
"/ multiple categories: must add the categorie for some
|
|
928 |
doShowCategory := enforceClassAndProtocolInList or:[allCategories size > 1].
|
|
929 |
|
|
930 |
doShowClassFirst := doShowClass. "/ (doShowClass and:[allSelectors size == 1]).
|
|
931 |
doShowClassFirst := doShowClass and:[ sortBy value == #class ].
|
|
932 |
|
|
933 |
sortBy value == false ifTrue:[
|
|
934 |
"/ do not sort
|
|
935 |
] ifFalse:[
|
|
936 |
(doShowClass not and:[ sortBy value == #class ]) ifTrue:[
|
|
937 |
"/ multiple classes must add the className for some
|
|
938 |
"/ check, if doShowClass must be enforced
|
|
939 |
entries do:[:entry |
|
|
940 |
|cls sel mthd s needClass|
|
|
941 |
|
|
942 |
cls := entry at:1.
|
|
943 |
sel := entry at:2.
|
|
944 |
mthd := entry at:3.
|
|
945 |
doShowClass ifFalse:[
|
|
946 |
doShowClass := (selectorBag occurrencesOf:sel) > 1
|
|
947 |
].
|
|
948 |
].
|
|
949 |
].
|
|
950 |
|
|
951 |
sortByClass := doShowClass and:[ sortBy value == #class ].
|
|
952 |
|
|
953 |
sortByClass ifTrue:[
|
|
954 |
entries sort:[:a :b | |nmA nmB clsNmA clsNmB|
|
|
955 |
clsNmA := (a at:1) name.
|
|
956 |
clsNmB := (b at:1) name.
|
|
957 |
clsNmA = clsNmB ifTrue:[
|
|
958 |
nmA := (a at:2).
|
|
959 |
nmB := (b at:2).
|
|
960 |
nmA < nmB
|
|
961 |
] ifFalse:[
|
|
962 |
clsNmA < clsNmB
|
|
963 |
]
|
|
964 |
].
|
|
965 |
] ifFalse:[
|
|
966 |
entries sort:[:a :b | |nmA nmB clsNmA clsNmB|
|
|
967 |
nmA := (a at:2).
|
|
968 |
nmB := (b at:2).
|
|
969 |
nmA = nmB ifTrue:[
|
|
970 |
clsNmA := (a at:1) name.
|
|
971 |
clsNmB := (b at:1) name.
|
|
972 |
clsNmA < clsNmB
|
|
973 |
] ifFalse:[
|
|
974 |
nmA < nmB
|
|
975 |
]
|
|
976 |
].
|
|
977 |
].
|
|
978 |
].
|
|
979 |
|
|
980 |
methods := OrderedCollection new:(entries size).
|
|
981 |
|
|
982 |
"/ first generate the new methodList, and see if it is different ...
|
|
983 |
entries do:[:entry |
|
|
984 |
|sel mthd|
|
|
985 |
|
|
986 |
mthd := entry at:3.
|
|
987 |
methods add:mthd.
|
|
988 |
].
|
|
989 |
|
|
990 |
false "methodList = methods" "does not care for changed icons" ifTrue:[
|
|
991 |
"/ same list
|
|
992 |
newNameList := self browserNameList.
|
|
993 |
] ifFalse:[
|
|
994 |
newNameList := OrderedCollection new:(entries size).
|
|
995 |
|
|
996 |
"/ multiple classes must add the className for some
|
|
997 |
entries do:[:entry |
|
|
998 |
|cls sel mthd s needClass|
|
|
999 |
|
|
1000 |
cls := entry at:1.
|
|
1001 |
sel := entry at:2.
|
|
1002 |
mthd := entry at:3.
|
|
1003 |
needClass := doShowClass.
|
|
1004 |
"/ needClass ifFalse:[
|
|
1005 |
"/ needClass := (selectorBag occurrencesOf:sel) > 1
|
|
1006 |
"/ ].
|
|
1007 |
s := self
|
|
1008 |
listEntryForMethod:mthd
|
|
1009 |
selector:sel
|
|
1010 |
class:cls
|
|
1011 |
showClass:needClass
|
|
1012 |
showCategory:doShowCategory
|
|
1013 |
classFirst:doShowClassFirst.
|
|
1014 |
|
|
1015 |
"/ s := mthd printStringForBrowserWithSelector:sel inClass:cls.
|
|
1016 |
"/ needClass ifTrue:[
|
|
1017 |
"/ s := s , ' [' , cls name , ']'.
|
|
1018 |
"/ ].
|
|
1019 |
"/ doShowCategory ifTrue:[
|
|
1020 |
"/ s := s , ' {' , mthd category "asText allItalic" , '}'
|
|
1021 |
"/ ].
|
|
1022 |
newNameList add:s.
|
|
1023 |
].
|
|
1024 |
].
|
|
1025 |
|
|
1026 |
self makeIndependent.
|
|
1027 |
classes := newClasses.
|
|
1028 |
self makeDependent.
|
|
1029 |
|
|
1030 |
methodList := methods.
|
|
1031 |
methods size == 1 ifTrue:[
|
|
1032 |
theMethod := methods first.
|
|
1033 |
mclass := theMethod mclass.
|
|
1034 |
mclass isNil ifTrue:[
|
|
1035 |
theMethod isWrapped ifTrue:[
|
|
1036 |
theMethod := theMethod originalMethod.
|
|
1037 |
mclass := theMethod mclass.
|
|
1038 |
].
|
|
1039 |
].
|
|
1040 |
mclass isNil ifTrue:[
|
|
1041 |
self methodLabelHolder value:('???' , ' ' , '???').
|
|
1042 |
] ifFalse:[
|
|
1043 |
self methodLabelHolder value:(mclass name , ' ' , theMethod selector).
|
|
1044 |
]
|
|
1045 |
].
|
|
1046 |
|
|
1047 |
anyMethodToWatch ifTrue:[
|
|
1048 |
self startWatchProcess.
|
|
1049 |
] ifFalse:[
|
|
1050 |
self stopWatchProcess.
|
|
1051 |
].
|
|
1052 |
|
|
1053 |
"/ remember these, in case of an incremental (single method only)
|
|
1054 |
"/ update in the future.
|
|
1055 |
lastShowClass := doShowClass.
|
|
1056 |
lastShowClassFirst := doShowClassFirst.
|
|
1057 |
lastShowCategory := doShowCategory.
|
|
1058 |
|
|
1059 |
^ newNameList.
|
|
1060 |
|
|
1061 |
"Created: / 5.2.2000 / 22:43:40 / cg"
|
|
1062 |
"Modified: / 1.3.2000 / 21:00:26 / cg"
|
|
1063 |
!
|
|
1064 |
|
|
1065 |
makeDependent
|
|
1066 |
Smalltalk addDependent:self.
|
|
1067 |
!
|
|
1068 |
|
|
1069 |
makeIndependent
|
|
1070 |
Smalltalk removeDependent:self.
|
|
1071 |
!
|
|
1072 |
|
|
1073 |
method:mthd includesModsOfClassVariable:variablesToHighLight
|
|
1074 |
^ self method:mthd includesRefsToVariable:variablesToHighLight askParserWith:#modifiedClassVars
|
|
1075 |
!
|
|
1076 |
|
|
1077 |
method:mthd includesModsOfInstanceVariable:variablesToHighLight
|
|
1078 |
^ self method:mthd includesRefsToVariable:variablesToHighLight askParserWith:#modifiedInstVars
|
|
1079 |
!
|
|
1080 |
|
|
1081 |
method:mthd includesRefsToClassVariable:variablesToHighLight
|
|
1082 |
^ self method:mthd includesRefsToVariable:variablesToHighLight askParserWith:#usedClassVars
|
|
1083 |
!
|
|
1084 |
|
|
1085 |
method:mthd includesRefsToInstanceVariable:variablesToHighLight
|
|
1086 |
^ self method:mthd includesRefsToVariable:variablesToHighLight askParserWith:#usedInstVars
|
|
1087 |
!
|
|
1088 |
|
|
1089 |
method:mthd includesRefsToVariable:variablesToHighLight askParserWith:querySelector
|
|
1090 |
|cls src parser usedVars anyVarNameAccessable|
|
|
1091 |
|
|
1092 |
cls := mthd mclass.
|
|
1093 |
anyVarNameAccessable := cls allInstVarNames includesAny:variablesToHighLight.
|
|
1094 |
anyVarNameAccessable ifFalse:[
|
|
1095 |
anyVarNameAccessable := cls theNonMetaclass allClassVarNames includesAny:variablesToHighLight.
|
|
1096 |
].
|
|
1097 |
anyVarNameAccessable ifFalse:[
|
|
1098 |
"/ no need to parse
|
|
1099 |
^ false
|
|
1100 |
].
|
|
1101 |
|
|
1102 |
src := mthd source.
|
|
1103 |
src notNil ifTrue:[
|
|
1104 |
"
|
|
1105 |
before doing a slow parse, quickly scan the
|
|
1106 |
methods source for the variables name ...
|
|
1107 |
"
|
|
1108 |
(variablesToHighLight contains:[:varName | (src findString:varName) ~~ 0]) ifTrue:[
|
|
1109 |
parser := Parser
|
|
1110 |
parseMethod:src
|
|
1111 |
in:cls
|
|
1112 |
ignoreErrors:true
|
|
1113 |
ignoreWarnings:true.
|
|
1114 |
(parser notNil and:[parser ~~ #Error]) ifTrue:[
|
|
1115 |
usedVars := parser perform:querySelector.
|
|
1116 |
(usedVars includesAny:variablesToHighLight)
|
|
1117 |
ifTrue:[
|
|
1118 |
^ true
|
|
1119 |
]
|
|
1120 |
]
|
|
1121 |
]
|
|
1122 |
].
|
|
1123 |
^ false
|
|
1124 |
!
|
|
1125 |
|
|
1126 |
methodIsInheritedFromAbove:aMethod
|
|
1127 |
|mClass|
|
|
1128 |
|
|
1129 |
mClass := aMethod mclass.
|
|
1130 |
(mClass notNil and:[mClass superclass notNil]) ifTrue:[
|
|
1131 |
^ (mClass superclass whichClassImplements:aMethod selector) notNil.
|
|
1132 |
].
|
|
1133 |
^ false
|
|
1134 |
!
|
|
1135 |
|
|
1136 |
methodIsRedefinedBelow:aMethod
|
|
1137 |
|mclass subClasses setOfRedefinedSelectors|
|
|
1138 |
|
|
1139 |
mclass := aMethod mclass.
|
|
1140 |
mclass isNil ifTrue:[^ false].
|
|
1141 |
|
|
1142 |
"/ if possible, make use of info prepared by listOfMethodNames
|
|
1143 |
classAndSelectorsRedefinedBySubclassesOfClass notNil
|
|
1144 |
ifTrue:[
|
|
1145 |
setOfRedefinedSelectors := classAndSelectorsRedefinedBySubclassesOfClass at:mclass ifAbsent:nil.
|
|
1146 |
setOfRedefinedSelectors notNil ifTrue:[
|
|
1147 |
^ setOfRedefinedSelectors includes:aMethod selector
|
|
1148 |
]
|
|
1149 |
].
|
|
1150 |
|
|
1151 |
lastMethodClass == mclass ifTrue:[
|
|
1152 |
subClasses := lastMethodClassesSubclasses
|
|
1153 |
] ifFalse:[
|
|
1154 |
subClasses := aMethod mclass allSubclasses.
|
|
1155 |
lastMethodClassesSubclasses := subClasses.
|
|
1156 |
lastMethodClass := mclass.
|
|
1157 |
].
|
|
1158 |
^ subClasses contains:[:cls | cls implements:aMethod selector].
|
|
1159 |
!
|
|
1160 |
|
|
1161 |
redefinedOrInheritedIconFor:aMethod
|
|
1162 |
|inherited redefined|
|
|
1163 |
|
|
1164 |
inherited := self methodIsInheritedFromAbove:aMethod.
|
|
1165 |
redefined := self methodIsRedefinedBelow:aMethod.
|
|
1166 |
|
|
1167 |
inherited ifTrue:[
|
|
1168 |
redefined ifTrue:[
|
|
1169 |
^ self methodInheritedFromAboveAndRedefinedBelowIcon.
|
|
1170 |
].
|
|
1171 |
^ self methodInheritedFromAboveIcon.
|
|
1172 |
].
|
|
1173 |
redefined ifTrue:[
|
|
1174 |
^ self methodRedefinedBelowIcon.
|
|
1175 |
].
|
|
1176 |
|
|
1177 |
^ self methodEmptyInheritedIcon
|
|
1178 |
!
|
|
1179 |
|
|
1180 |
release
|
|
1181 |
super release.
|
|
1182 |
|
|
1183 |
filterClassVars removeDependent:self.
|
|
1184 |
selectedMethodNameIndices removeDependent:self.
|
|
1185 |
showMethodInheritance removeDependent:self.
|
|
1186 |
variableFilter removeDependent:self.
|
|
1187 |
!
|
|
1188 |
|
|
1189 |
resourceIconForMethod:aMethod
|
|
1190 |
|resources|
|
|
1191 |
|
|
1192 |
(resources := aMethod resources) notNil ifTrue:[
|
|
1193 |
(resources includesKey:#canvas) ifTrue:[
|
|
1194 |
^ self canvasIcon
|
|
1195 |
].
|
|
1196 |
(resources includesKey:#menu) ifTrue:[
|
|
1197 |
^ self menuIcon
|
|
1198 |
].
|
|
1199 |
(resources includesKey:#image) ifTrue:[
|
|
1200 |
^ self imageIcon
|
|
1201 |
].
|
|
1202 |
(resources includesKey:#fileImage) ifTrue:[
|
|
1203 |
^ self fileImageIcon
|
|
1204 |
].
|
|
1205 |
(resources includesKey:#programImage) ifTrue:[
|
|
1206 |
^ self programImageIcon
|
|
1207 |
].
|
|
1208 |
(resources includesKey:#help) ifTrue:[
|
|
1209 |
^ self helpIcon
|
|
1210 |
].
|
|
1211 |
(resources includesKey:#programMenu) ifTrue:[
|
|
1212 |
^ self programMenuIcon
|
|
1213 |
].
|
|
1214 |
(resources includesKey:#tableColumns) ifTrue:[
|
|
1215 |
^ self tableColumnsIcon
|
|
1216 |
].
|
|
1217 |
(resources includesKey:#tabList) ifTrue:[
|
|
1218 |
^ self tabListIcon
|
|
1219 |
].
|
|
1220 |
(resources includesKey:#hierarchicalList) ifTrue:[
|
|
1221 |
^ self hierarchicalListIcon
|
|
1222 |
].
|
|
1223 |
(resources includesKey:#programImage) ifTrue:[
|
|
1224 |
^ self programImageIcon
|
|
1225 |
]
|
|
1226 |
].
|
|
1227 |
^ nil
|
|
1228 |
!
|
|
1229 |
|
|
1230 |
setOfAllSelectorsImplementedBelow:aClass
|
|
1231 |
|set|
|
|
1232 |
|
|
1233 |
set := IdentitySet new.
|
|
1234 |
aClass allSubclassesDo:[:eachSubclass |
|
|
1235 |
set addAll:(eachSubclass methodDictionary keys).
|
|
1236 |
].
|
|
1237 |
^ set
|
|
1238 |
!
|
|
1239 |
|
|
1240 |
updateList
|
|
1241 |
|prevSelection newList newSelection newSelIdx reverseMap sameContents newListSize oldListSize
|
|
1242 |
prevClasses methodSet selectedMethodsHolder|
|
|
1243 |
|
|
1244 |
selectedMethodsHolder := self selectedMethods.
|
|
1245 |
prevSelection := selectedMethodsHolder value ? #().
|
|
1246 |
|
|
1247 |
prevClasses := classes ifNil:[ #() ] ifNotNil:[ classes copy ].
|
|
1248 |
|
|
1249 |
oldListSize := self browserNameList size.
|
|
1250 |
|
|
1251 |
"/ self topApplication withWaitCursorDo:[
|
|
1252 |
newList := self listOfMethodNames.
|
|
1253 |
newListSize := newList size.
|
|
1254 |
sameContents := self updateListFor:newList.
|
|
1255 |
|
|
1256 |
sameContents ifFalse:[
|
|
1257 |
"/ self browserNameList value:newList.
|
|
1258 |
|
|
1259 |
(prevSelection size == 0
|
|
1260 |
and:[selectedMethodsHolder value size ~~ 0]) ifTrue:[
|
|
1261 |
"/ this happens during early startup time,
|
|
1262 |
"/ when the selection is already (pre-)set,
|
|
1263 |
"/ and the methodList is generated the first time
|
|
1264 |
"/ (i.e. when opened with preset selection
|
|
1265 |
|
|
1266 |
"/ do not clobber the selection in this case.
|
|
1267 |
prevSelection := selectedMethodsHolder value.
|
|
1268 |
].
|
|
1269 |
|
|
1270 |
(methodList size == 0 or:[prevSelection size == 0]) ifTrue:[
|
|
1271 |
newSelection := #()
|
|
1272 |
] ifFalse:[
|
|
1273 |
methodSet := methodList.
|
|
1274 |
|
|
1275 |
"/ inclusion test is much faster with sets, if the number of items is large
|
|
1276 |
methodList size > 30 ifTrue:[
|
|
1277 |
"/ however, only if its worth building the set ...
|
|
1278 |
prevSelection size > 5 ifTrue:[
|
|
1279 |
methodSet := methodSet asIdentitySet.
|
|
1280 |
]
|
|
1281 |
].
|
|
1282 |
newSelection := prevSelection select:[:item | methodSet includesIdentical:item].
|
|
1283 |
].
|
|
1284 |
newSelection size > 0 ifTrue:[
|
|
1285 |
newSelection size > 100 ifTrue:[
|
|
1286 |
"/ need selection indices - might be expensive if done straight forward...
|
|
1287 |
reverseMap := IdentityDictionary new.
|
|
1288 |
methodList keysAndValuesDo:[:idx :mthd | reverseMap at:mthd put:idx].
|
|
1289 |
newSelIdx := newSelection collect:[:mthd | reverseMap at:mthd].
|
|
1290 |
] ifFalse:[
|
|
1291 |
newSelIdx := newSelection collect:[:mthd | methodList identityIndexOf:mthd]
|
|
1292 |
].
|
|
1293 |
"/ self halt.
|
|
1294 |
"/ force change (for dependents)
|
|
1295 |
selectedMethodNameIndices value:newSelIdx.
|
|
1296 |
] ifFalse:[
|
|
1297 |
lastSelectedMethods := selectedMethodsHolder value.
|
|
1298 |
lastSelectedMethods notNil ifTrue:[
|
|
1299 |
lastSelectedMethods := lastSelectedMethods asOrderedCollection
|
|
1300 |
].
|
|
1301 |
selectedMethodNameIndices value size > 0 ifTrue:[
|
|
1302 |
selectedMethodNameIndices value:#().
|
|
1303 |
]
|
|
1304 |
].
|
|
1305 |
|
|
1306 |
newSelection ~= prevSelection ifTrue:[
|
|
1307 |
self selectionChanged.
|
|
1308 |
]
|
|
1309 |
] ifTrue:[
|
|
1310 |
"/ same list - but classes might have changed
|
|
1311 |
"/ that is the case, if the class selection has been changed,
|
|
1312 |
"/ to another class which has the same categories.
|
|
1313 |
|
|
1314 |
(prevClasses size ~= classes size
|
|
1315 |
or:[prevClasses asOrderedCollection ~= (classes ? #()) asOrderedCollection ]) ifTrue:[
|
|
1316 |
(newListSize > 0 or:[oldListSize > 0]) ifTrue:[
|
|
1317 |
self selectionChanged.
|
|
1318 |
]
|
|
1319 |
]
|
|
1320 |
]
|
|
1321 |
"/ ].
|
|
1322 |
|
|
1323 |
"Modified: / 18.8.2000 / 19:47:22 / cg"
|
|
1324 |
!
|
|
1325 |
|
|
1326 |
updateListEntryFor:aMethod
|
|
1327 |
"update my list for a single method.
|
|
1328 |
(used when a single methods package, code or whatever changes, and a full udpate
|
|
1329 |
would be too slow)"
|
|
1330 |
|
|
1331 |
|s idx|
|
|
1332 |
|
|
1333 |
s := self
|
|
1334 |
listEntryForMethod:aMethod
|
|
1335 |
selector:aMethod selector
|
|
1336 |
class:aMethod mclass
|
|
1337 |
showClass:lastShowClass
|
|
1338 |
showCategory:lastShowCategory
|
|
1339 |
classFirst:lastShowClassFirst.
|
|
1340 |
|
|
1341 |
idx := methodList identityIndexOf:aMethod.
|
|
1342 |
idx == 0 ifTrue:[
|
|
1343 |
aMethod isWrapped ifTrue:[
|
|
1344 |
idx := methodList identityIndexOf:aMethod originalMethod.
|
|
1345 |
] ifFalse:[
|
|
1346 |
]
|
|
1347 |
].
|
|
1348 |
idx == 0 ifTrue:[
|
|
1349 |
self invalidateList
|
|
1350 |
] ifFalse:[
|
|
1351 |
self browserNameList at:idx put:s.
|
|
1352 |
]
|
|
1353 |
! !
|
|
1354 |
|
|
1355 |
!MethodList methodsFor:'private-watching'!
|
|
1356 |
|
|
1357 |
startWatchProcess
|
|
1358 |
updateProcess notNil ifTrue:[
|
|
1359 |
^ self
|
|
1360 |
].
|
|
1361 |
updateProcess := [
|
|
1362 |
[true] whileTrue:[
|
|
1363 |
Delay waitForSeconds:1.
|
|
1364 |
self enqueueDelayedUpdateList
|
|
1365 |
]
|
|
1366 |
] fork.
|
|
1367 |
!
|
|
1368 |
|
|
1369 |
stopWatchProcess
|
|
1370 |
|p|
|
|
1371 |
|
|
1372 |
(p := updateProcess) notNil ifTrue:[
|
|
1373 |
updateProcess := nil.
|
|
1374 |
p terminate
|
|
1375 |
].
|
|
1376 |
! !
|
|
1377 |
|
|
1378 |
!MethodList methodsFor:'setup'!
|
|
1379 |
|
|
1380 |
postBuildWith:aBuilder
|
|
1381 |
|methodListView|
|
|
1382 |
|
|
1383 |
super postBuildWith:aBuilder.
|
|
1384 |
|
|
1385 |
methodListView := aBuilder componentAt:'List'.
|
|
1386 |
methodListView notNil ifTrue:[
|
|
1387 |
methodListView allowDrag:true.
|
|
1388 |
methodListView dragObjectConverter:[:obj |
|
|
1389 |
|nm method idx|
|
|
1390 |
|
|
1391 |
nm := obj theObject asString.
|
|
1392 |
idx := browserNameList value indexOf:nm string.
|
|
1393 |
method := methodList value at:idx.
|
|
1394 |
DropObject newMethod:method.
|
|
1395 |
].
|
|
1396 |
]
|
|
1397 |
! !
|
|
1398 |
|
|
1399 |
!MethodList class methodsFor:'documentation'!
|
|
1400 |
|
|
1401 |
version
|
|
1402 |
^ '$Header: /cvs/stx/stx/libtool/Tools_MethodList.st,v 1.1 2004-02-26 18:55:13 cg Exp $'
|
|
1403 |
! !
|