author | Claus Gittinger <cg@exept.de> |
Fri, 10 Sep 2004 12:15:34 +0200 | |
changeset 5998 | 6e40a20b361a |
parent 5885 | 26dee2c80ea9 |
child 6259 | e440c14b02aa |
permissions | -rw-r--r-- |
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:[ |
|
5998 | 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 |
]. |
|
5591 | 290 |
|
5998 | 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 |
]. |
|
5591 | 317 |
|
5998 | 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 |
]. |
|
5591 | 349 |
|
5998 | 350 |
(something == #methodTrap |
351 |
or:[ something == #privacyOfMethod ]) ifTrue:[ |
|
352 |
cls := aParameter at:1. |
|
353 |
sel := aParameter at:2. |
|
354 |
(classes includesIdentical:cls) ifFalse:[ ^ self]. |
|
355 |
newMethod := cls compiledMethodAt:sel. |
|
356 |
newMethod isNil ifTrue:[ |
|
357 |
self invalidateList. |
|
358 |
^ self |
|
359 |
]. |
|
5591 | 360 |
|
5998 | 361 |
(something == #privacyOfMethod) ifTrue:[ |
362 |
self updateListEntryFor:newMethod. |
|
363 |
]. |
|
364 |
||
365 |
(something == #methodTrap) ifTrue:[ |
|
366 |
newMethod isWrapped ifTrue:[ |
|
367 |
oldMethod := newMethod originalMethod |
|
368 |
] ifFalse:[ |
|
369 |
selection size > 0 ifTrue:[ |
|
370 |
oldMethod := selection detect:[:each | each isWrapped and:[each originalMethod == newMethod]] ifNone:nil. |
|
371 |
] |
|
372 |
]. |
|
5591 | 373 |
|
5998 | 374 |
selection size > 0 ifTrue:[ |
375 |
(selection includesIdentical:oldMethod) ifTrue:[ |
|
376 |
needSelectionChange := true. |
|
377 |
] |
|
378 |
]. |
|
379 |
methodList replaceAllIdentical:oldMethod with:newMethod. |
|
380 |
lastSelectedMethods notNil ifTrue:[ |
|
381 |
lastSelectedMethods replaceAllIdentical:oldMethod with:newMethod |
|
382 |
]. |
|
383 |
selection size > 0 ifTrue:[ |
|
384 |
selection := selection asOrderedCollection. |
|
385 |
selection replaceAllIdentical:oldMethod with:newMethod. |
|
386 |
]. |
|
387 |
needSelectionChange == true ifTrue:[ |
|
388 |
selectionHolder changed. |
|
389 |
]. |
|
5591 | 390 |
|
5998 | 391 |
"/ actually, could just change that single item ... |
392 |
"/ ... might be cheaper, if list is huge. |
|
393 |
"/ only update that methods entry |
|
394 |
self updateListEntryFor:newMethod. |
|
395 |
"/ self invalidateList. |
|
396 |
]. |
|
397 |
^ self |
|
398 |
]. |
|
5591 | 399 |
|
5998 | 400 |
something == #projectOrganization ifTrue:[ |
401 |
aParameter notNil ifTrue:[ |
|
402 |
cls := aParameter at:1. |
|
403 |
cls notNil ifTrue:[ |
|
404 |
((classes includesIdentical:cls theNonMetaclass) |
|
405 |
or:[(classes includesIdentical:cls theMetaclass)]) ifTrue:[ |
|
406 |
self invalidateList. |
|
407 |
]. |
|
408 |
]. |
|
409 |
] ifFalse:[ |
|
410 |
self invalidateList. |
|
411 |
]. |
|
412 |
^ self |
|
413 |
]. |
|
414 |
"/ everything else is ignored |
|
415 |
"/ self halt. |
|
416 |
]. |
|
417 |
^ self |
|
5591 | 418 |
]. |
419 |
||
420 |
"/ something == #organization ifTrue:[ |
|
421 |
"/self halt:'no longer'. |
|
422 |
"/^ self. |
|
423 |
"/ "/ a methods cateory has changed |
|
424 |
"/ (classes includesIdentical:changedObject) ifTrue:[ |
|
425 |
"/ aParameter isSymbol ifTrue:[ |
|
426 |
"/ "/ a method with a new category |
|
427 |
"/ (self methodList includesIdentical:(changedObject compiledMethodAt:aParameter)) ifTrue:[ |
|
428 |
"/ self invalidateList. |
|
429 |
"/ ]. |
|
430 |
"/ ^ self. |
|
431 |
"/ ]. |
|
432 |
"/ "/ a new category (no method yet) |
|
433 |
"/ self invalidateList |
|
434 |
"/ ]. |
|
435 |
"/ ^ self |
|
436 |
"/ ]. |
|
437 |
||
438 |
"/ something == #methodDictionary ifTrue:[ |
|
439 |
"/self halt:'no longer'. |
|
440 |
"/^ self. |
|
441 |
"/ "/ a method has been added/removed |
|
442 |
"/ (classes includesIdentical:changedObject) ifTrue:[ |
|
443 |
"/ aParameter isArray ifTrue:[ |
|
444 |
"/ sel := aParameter at:1. |
|
445 |
"/ oldMethod := aParameter at:2. |
|
446 |
"/ newMethod := changedObject compiledMethodAt:sel. |
|
447 |
"/ oldMethod notNil ifTrue:[ |
|
448 |
"/ "a method was changed & acccepted; |
|
449 |
"/ No need for a rescan of the methodDictionary; |
|
450 |
"/ however, ensure that the refs to the old method are updated |
|
451 |
"/ " |
|
452 |
"/ methods := selection. |
|
453 |
"/ methods size > 0 ifTrue:[ |
|
454 |
"/ (methods includesIdentical:oldMethod) ifTrue:[ |
|
455 |
"/ needSelectionChange := true. |
|
456 |
"/ ] |
|
457 |
"/ ]. |
|
458 |
"/ methodList replaceAllIdentical:oldMethod with:newMethod. |
|
459 |
"/ lastSelectedMethods notNil ifTrue:[ |
|
460 |
"/ lastSelectedMethods replaceAllIdentical:oldMethod with:newMethod |
|
461 |
"/ ]. |
|
462 |
"/ methods size > 0 ifTrue:[ |
|
463 |
"/ methods := methods asOrderedCollection. |
|
464 |
"/ methods replaceAllIdentical:oldMethod with:newMethod. |
|
465 |
"/ ]. |
|
466 |
"/ needSelectionChange == true ifTrue:[ |
|
467 |
"/ selectionHolder setValue:methods. |
|
468 |
"/ selectionHolder changed. |
|
469 |
"/ ]. |
|
470 |
"/ ^ self. |
|
471 |
"/ ] |
|
472 |
"/ ]. |
|
473 |
"/ "/ class has changed must update the methodList |
|
474 |
"/ self invalidateList. |
|
475 |
"/ ]. |
|
476 |
"/ ^ self. |
|
477 |
"/ ]. |
|
478 |
||
479 |
"/ something == #projectOrganization ifTrue:[ |
|
480 |
"/ ((classes includesIdentical:changedObject theNonMetaclass) |
|
481 |
"/ or:[(classes includesIdentical:changedObject theMetaclass)]) ifTrue:[ |
|
482 |
"/ self invalidateList. |
|
483 |
"/ ]. |
|
484 |
"/ ^ self |
|
485 |
"/ ]. |
|
486 |
||
487 |
changedObject == sortBy ifTrue:[ |
|
5998 | 488 |
listValid ~~ true ifTrue:[ "/ could be nil |
489 |
inGeneratorHolder value isNil ifTrue:[ |
|
490 |
"/ ok, no need to react on that one |
|
491 |
"/ (will invalidate anyway, once I have more info at hand) |
|
492 |
^ self |
|
493 |
]. |
|
494 |
]. |
|
495 |
self invalidateList. |
|
496 |
^ self |
|
5591 | 497 |
]. |
498 |
||
499 |
(changedObject == variableFilter |
|
500 |
or:[changedObject == filterClassVars |
|
501 |
or:[changedObject == showMethodInheritance]]) ifTrue:[ |
|
5998 | 502 |
self invalidateList. |
503 |
^ self |
|
5591 | 504 |
]. |
505 |
||
506 |
changedObject == selectedMethodNameIndices ifTrue:[ |
|
5998 | 507 |
newSelection := self selectedMethodNameIndices value collect:[:idx | methodList at:idx]. |
508 |
newSelection ~= selection ifTrue:[ |
|
509 |
selectionHolder value:newSelection. |
|
510 |
lastSelectedMethods := newSelection. |
|
511 |
lastSelectedMethods notNil ifTrue:[ |
|
512 |
lastSelectedMethods := lastSelectedMethods asOrderedCollection |
|
513 |
]. |
|
514 |
] ifFalse:[ |
|
515 |
"/ a reselect - force update |
|
5591 | 516 |
"/ selection size == 1 ifTrue:[ |
5998 | 517 |
selectionHolder setValue:newSelection. |
518 |
selectionHolder changed:#value. |
|
5591 | 519 |
"/ ]. |
5998 | 520 |
]. |
521 |
^ self |
|
5591 | 522 |
]. |
523 |
changedObject == selectionHolder ifTrue:[ |
|
5998 | 524 |
self selectedMethodsChanged. |
525 |
lastSelectedMethods := selectionHolder value. |
|
526 |
lastSelectedMethods notNil ifTrue:[ |
|
527 |
lastSelectedMethods := lastSelectedMethods asOrderedCollection |
|
528 |
]. |
|
529 |
^ self |
|
5591 | 530 |
]. |
531 |
"/ something == #methodTrap ifTrue:[ |
|
532 |
"/self halt:'no longer'. |
|
533 |
"/^ self. |
|
534 |
"/ (classes includesIdentical:changedObject) ifTrue:[ |
|
535 |
"/ newMethod := changedObject compiledMethodAt:aParameter. |
|
536 |
"/ newMethod isNil ifTrue:[ |
|
537 |
"/ self invalidateList. |
|
538 |
"/ ^ self |
|
539 |
"/ ]. |
|
540 |
"/ newMethod isWrapped ifTrue:[ |
|
541 |
"/ oldMethod := newMethod originalMethod |
|
542 |
"/ ] ifFalse:[ |
|
543 |
"/ selection size > 0 ifTrue:[ |
|
544 |
"/ oldMethod := selection detect:[:each | each isWrapped and:[each originalMethod == newMethod]] ifNone:nil. |
|
545 |
"/ ] |
|
546 |
"/ ]. |
|
547 |
"/ |
|
548 |
"/ selection size > 0 ifTrue:[ |
|
549 |
"/ (selection includesIdentical:oldMethod) ifTrue:[ |
|
550 |
"/ needSelectionChange := true. |
|
551 |
"/ ] |
|
552 |
"/ ]. |
|
553 |
"/"/ methodList replaceAllIdentical:oldMethod with:newMethod. |
|
554 |
"/ lastSelectedMethods notNil ifTrue:[ |
|
555 |
"/ lastSelectedMethods replaceAllIdentical:oldMethod with:newMethod |
|
556 |
"/ ]. |
|
557 |
"/ selection size > 0 ifTrue:[ |
|
558 |
"/ selection := selection asOrderedCollection. |
|
559 |
"/ selection replaceAllIdentical:oldMethod with:newMethod. |
|
560 |
"/ ]. |
|
561 |
"/ needSelectionChange == true ifTrue:[ |
|
562 |
"/ selectionHolder changed. |
|
563 |
"/ ]. |
|
564 |
"/ self invalidateList. |
|
565 |
"/ ^ self |
|
566 |
"/ ]. |
|
567 |
"/ ^ self |
|
568 |
"/ ]. |
|
569 |
super delayedUpdate:something with:aParameter from:changedObject |
|
570 |
||
571 |
"Created: / 5.2.2000 / 13:42:14 / cg" |
|
572 |
"Modified: / 6.2.2000 / 00:05:26 / cg" |
|
573 |
! |
|
574 |
||
575 |
selectedMethodsChanged |
|
576 |
"the set of selected methods has changed; |
|
577 |
update the selection-index collection (for the selectionInListView)" |
|
578 |
||
579 |
|indices methods reverseMap |
|
580 |
selectedMethodsHolder selectedMethods selectedMethodNameIndicesHolder| |
|
581 |
||
582 |
methods := methodList ? #(). |
|
583 |
methods size == 0 ifTrue:[ |
|
584 |
"/ this may happen during early startup, |
|
585 |
"/ when invoked with a preset methodSelection, |
|
586 |
"/ and the methodGenerator has not yet been setup |
|
587 |
"/ to not clobber the selection, defer the update |
|
588 |
"/ until the methodList arrives ... |
|
589 |
^ self |
|
590 |
]. |
|
591 |
||
592 |
selectedMethodsHolder := self selectedMethods. |
|
593 |
selectedMethods := selectedMethodsHolder value. |
|
594 |
||
595 |
"/ check if all is selected (likely) |
|
596 |
((selectedMethods size == methodList size) |
|
597 |
and:[selectedMethods = methodList]) ifTrue:[ |
|
598 |
indices := (1 to:selectedMethods size) |
|
599 |
] ifFalse:[ |
|
600 |
selectedMethods size > 100 ifTrue:[ |
|
601 |
"/ check if all is selected (likely) |
|
602 |
((selectedMethods size == methodList size) |
|
603 |
and:[selectedMethods = methodList]) ifTrue:[ |
|
604 |
indices := (1 to:selectedMethods size) |
|
605 |
] ifFalse:[ |
|
606 |
"/ for big collections, generate a reverse map |
|
607 |
reverseMap := IdentityDictionary new. |
|
608 |
methods keysAndValuesDo:[:idx :mthd | reverseMap at:mthd put:idx]. |
|
609 |
indices := selectedMethods collect:[:eachSelectedMethod | |
|
610 |
reverseMap at:eachSelectedMethod ifAbsent:0 |
|
611 |
] |
|
612 |
] |
|
613 |
] ifFalse:[ |
|
614 |
indices := (selectedMethods ? #()) collect:[:eachSelectedMethod | |
|
615 |
methods identityIndexOf:eachSelectedMethod. |
|
616 |
] |
|
617 |
]. |
|
618 |
indices := indices select:[:idx | idx ~= 0]. |
|
619 |
]. |
|
620 |
||
621 |
selectedMethodNameIndicesHolder := self selectedMethodNameIndices. |
|
622 |
selectedMethodNameIndicesHolder value ~= indices ifTrue:[ |
|
623 |
selectedMethodNameIndicesHolder value:indices. |
|
624 |
] |
|
625 |
! |
|
626 |
||
627 |
selectionChanged |
|
628 |
|methods| |
|
629 |
||
630 |
methods := ((self selectedMethodNameIndices value) ? #()) collect:[:idx | methodList at:idx]. |
|
631 |
methods notEmpty ifTrue:[ |
|
632 |
lastSelectedMethods := methods asOrderedCollection. |
|
633 |
]. |
|
634 |
"/ to allow reselect, change my valueHolder, even if the same collection |
|
635 |
"/ self selectedMethods value ~= methods ifTrue:[ |
|
636 |
self selectedMethods value:methods |
|
637 |
"/ ] |
|
638 |
||
639 |
"Created: / 5.2.2000 / 13:42:14 / cg" |
|
640 |
"Modified: / 5.2.2000 / 23:32:20 / cg" |
|
641 |
! |
|
642 |
||
643 |
selectionChangedByClick |
|
644 |
"we are not interested in that - get another notification |
|
645 |
via the changed valueHolder" |
|
646 |
||
647 |
! |
|
648 |
||
649 |
update:something with:aParameter from:changedObject |
|
650 |
|cls| |
|
651 |
||
652 |
"/ some can be ignored immediately |
|
653 |
changedObject == Smalltalk ifTrue:[ |
|
654 |
classes isNil ifTrue:[ |
|
655 |
^ self. |
|
656 |
]. |
|
657 |
something isNil ifTrue:[ |
|
658 |
"/ self halt "/ huh - Smalltalk changed - so what ? |
|
659 |
^ self. |
|
660 |
]. |
|
5998 | 661 |
|
5591 | 662 |
something == #classComment ifTrue:[ |
663 |
^ self. |
|
664 |
]. |
|
665 |
something == #classVariables ifTrue:[ |
|
666 |
^ self. |
|
667 |
]. |
|
668 |
something == #organization ifTrue:[ |
|
669 |
^ self. |
|
670 |
]. |
|
671 |
something == #methodCategory ifTrue:[ |
|
672 |
"/ ignore here - methodCategoryList will tell me if required |
|
673 |
^ self |
|
674 |
]. |
|
675 |
something == #classOrganization ifTrue:[ |
|
676 |
"/ ignore here - methodCategoryList will tell me if required |
|
677 |
^ self |
|
678 |
]. |
|
5998 | 679 |
(something == #methodTrap |
680 |
or:[ something == #methodPrivacy ]) ifTrue:[ |
|
681 |
self window shown ifFalse:[ |
|
682 |
changedObject removeDependent:self. "/ ????? |
|
683 |
^ self |
|
684 |
]. |
|
5591 | 685 |
cls := aParameter at:1. |
686 |
(classes includesIdentical:cls) ifFalse:[ |
|
5998 | 687 |
^ self "/ I dont care for that class |
5591 | 688 |
]. |
689 |
]. |
|
690 |
||
691 |
classAndSelectorsRedefinedBySubclassesOfClass := nil. |
|
692 |
||
693 |
something == #classDefinition ifTrue:[ |
|
694 |
cls := aParameter. |
|
695 |
(classes contains:[:aClass | aClass name == cls name]) ifFalse:[ |
|
696 |
^ self "/ I dont care for that class |
|
697 |
]. |
|
698 |
classes := classes collect:[:eachClass | eachClass isMeta ifTrue:[ |
|
699 |
(Smalltalk at:eachClass theNonMetaclass name) class |
|
700 |
] ifFalse:[ |
|
701 |
Smalltalk at:eachClass name |
|
702 |
] |
|
703 |
]. |
|
704 |
self updateList. |
|
705 |
^ self. |
|
706 |
]. |
|
707 |
something == #newClass ifTrue:[ |
|
708 |
^ self. |
|
709 |
]. |
|
710 |
something == #classRemove ifTrue:[ |
|
711 |
^ self. |
|
712 |
]. |
|
713 |
something == #classRename ifTrue:[ |
|
714 |
^ self. |
|
715 |
]. |
|
716 |
]. |
|
717 |
||
718 |
"/ these must lead to immediate update of the selectedMethods collection |
|
719 |
"/ (otherwise, that collection might be updated too late, leading to |
|
720 |
"/ an obsolete methods code being shown by the codeView. |
|
721 |
something == #methodInClass ifTrue:[ |
|
722 |
classAndSelectorsRedefinedBySubclassesOfClass := nil. |
|
723 |
cls := aParameter at:1. |
|
724 |
(classes includesIdentical:cls) ifFalse:[ |
|
725 |
^ self "/ I dont care for that class |
|
726 |
]. |
|
727 |
self enqueueDelayedUpdate:something with:aParameter from:changedObject. |
|
728 |
^ self |
|
729 |
]. |
|
730 |
||
731 |
something == #methodInClassRemoved ifTrue:[ |
|
732 |
cls := aParameter at:1. |
|
733 |
(classes includesIdentical:cls) ifFalse:[ |
|
734 |
^ self "/ I dont care for that class |
|
735 |
]. |
|
736 |
]. |
|
737 |
||
738 |
super update:something with:aParameter from:changedObject |
|
739 |
! ! |
|
740 |
||
741 |
!MethodList methodsFor:'private'! |
|
742 |
||
743 |
listEntryForMethod:aMethod selector:selector class:cls showClass:showClass showCategory:showCategory classFirst:showClassFirst |
|
744 |
"answer a method list entry |
|
745 |
gimmics: |
|
5998 | 746 |
adding a little image to breakPointed methods, |
747 |
inheritance indicators, |
|
748 |
highlight accessors of variable" |
|
5591 | 749 |
|
750 |
|clsName s icn variablesToHighlight classVarsToHighLight |
|
751 |
doHighLight doHighLightRed emp cat l redefIcon| |
|
752 |
||
753 |
aMethod isAssociation ifTrue:[ |
|
5998 | 754 |
self halt:'should not happen'. |
5591 | 755 |
]. |
756 |
||
757 |
s := aMethod printStringForBrowserWithSelector:selector inClass:cls. |
|
758 |
showClassFirst ifTrue:[ |
|
5998 | 759 |
clsName := cls nameInBrowser. |
760 |
s := clsName , ' ' , s allBold |
|
5591 | 761 |
]. |
762 |
||
763 |
"/ |
|
764 |
"/ wrap icons (i.e. break- or trace points) |
|
765 |
"/ have higher prio ... |
|
766 |
"/ |
|
767 |
aMethod isWrapped ifTrue:[ |
|
5998 | 768 |
(s endsWith:' !!') ifTrue:[ |
769 |
s := s copyWithoutLast:2 |
|
770 |
]. |
|
771 |
aMethod isBreakpointed ifTrue:[ |
|
772 |
icn := self stopIcon |
|
773 |
] ifFalse:[ |
|
774 |
aMethod isTimed ifTrue:[ |
|
775 |
icn := self timeIcon |
|
776 |
] ifFalse:[ |
|
777 |
icn := self traceIcon |
|
778 |
] |
|
779 |
]. |
|
5591 | 780 |
]. |
781 |
||
782 |
icn isNil ifTrue:[ |
|
5998 | 783 |
icn := self resourceIconForMethod:aMethod. |
784 |
icn isNil ifTrue:[ |
|
785 |
aMethod isProtected ifTrue:[ |
|
786 |
icn := self protectedMethodIcon |
|
787 |
] ifFalse:[ |
|
788 |
aMethod isPrivate ifTrue:[ |
|
789 |
icn := self privateMethodIcon |
|
790 |
] ifFalse:[ |
|
791 |
(aMethod isIgnored) ifTrue:[ |
|
792 |
icn := self ignoredMethodIcon |
|
793 |
] ifFalse:[ |
|
794 |
(aMethod isJavaMethod and:[aMethod isAbstract]) ifTrue:[ |
|
795 |
icn := self abstractMethodIcon |
|
796 |
] |
|
797 |
] |
|
798 |
] |
|
799 |
]. |
|
800 |
]. |
|
5591 | 801 |
]. |
802 |
icn isNil ifTrue:[ |
|
5998 | 803 |
(selector startsWith:'test') ifTrue:[ |
804 |
((cls isSubclassOf:TestCase) |
|
805 |
and:[cls isAbstract not]) ifTrue:[ |
|
806 |
cls lastTestRunResultOrNil == false ifTrue:[ |
|
807 |
(cls testSelectorFailed:selector) ifTrue:[ |
|
808 |
icn := SystemBrowser testCaseFailedIcon |
|
809 |
] ifFalse:[ |
|
810 |
"/ icn := SystemBrowser testCasePassedIcon |
|
811 |
]. |
|
812 |
] |
|
813 |
]. |
|
814 |
] |
|
5591 | 815 |
]. |
816 |
||
817 |
showClass ifTrue:[ |
|
5998 | 818 |
showClassFirst ifFalse:[ |
819 |
s := s , ' [' , cls name allBold , ']'. |
|
820 |
] |
|
5591 | 821 |
]. |
822 |
showCategory ifTrue:[ |
|
5998 | 823 |
cat := aMethod category. |
824 |
cat notNil ifTrue:[ |
|
825 |
s := s , ' {' , cat "asText allItalic" , '}' |
|
826 |
] |
|
5591 | 827 |
]. |
828 |
||
829 |
variablesToHighlight := variableFilter value. |
|
830 |
variablesToHighlight size > 0 ifTrue:[ |
|
5998 | 831 |
classVarsToHighLight := filterClassVars value. |
832 |
classVarsToHighLight ifTrue:[ |
|
833 |
doHighLight := self method:aMethod includesRefsToClassVariable:variablesToHighlight. |
|
834 |
doHighLight ifTrue:[ |
|
835 |
doHighLightRed := self method:aMethod includesModsOfClassVariable:variablesToHighlight. |
|
836 |
]. |
|
837 |
] ifFalse:[ |
|
838 |
doHighLight := self method:aMethod includesRefsToInstanceVariable:variablesToHighlight. |
|
839 |
doHighLight ifTrue:[ |
|
840 |
doHighLightRed := self method:aMethod includesModsOfInstanceVariable:variablesToHighlight |
|
841 |
] |
|
842 |
]. |
|
843 |
doHighLight ifTrue:[ |
|
844 |
s := s allBold. |
|
845 |
doHighLightRed ifTrue:[ |
|
846 |
emp := (UserPreferences current emphasisForWrittenVariable) |
|
847 |
] ifFalse:[ |
|
848 |
emp := (UserPreferences current emphasisForReadVariable) |
|
849 |
]. |
|
850 |
s := s emphasisAllAdd:emp |
|
851 |
] |
|
5591 | 852 |
]. |
853 |
||
854 |
showMethodInheritance value ~~ false ifTrue:[ |
|
5998 | 855 |
redefIcon := self redefinedOrInheritedIconFor:aMethod. |
5591 | 856 |
]. |
857 |
||
858 |
(icn notNil or:[redefIcon notNil]) ifTrue:[ |
|
5998 | 859 |
l := LabelAndIcon icon:redefIcon string:s. |
860 |
l image:icn. |
|
861 |
l gap:2. |
|
862 |
^ l |
|
5591 | 863 |
]. |
864 |
^ s |
|
865 |
||
866 |
"Created: / 22.10.1996 / 19:51:00 / cg" |
|
867 |
"Modified: / 31.10.2001 / 10:46:50 / cg" |
|
868 |
! |
|
869 |
||
870 |
listOfMethodNames |
|
871 |
|methods entries selectorBag newNameList |
|
872 |
allClasses newClasses allCategories "allSelectors" generator |
|
873 |
doShowClass doShowClassFirst doShowCategory |
|
874 |
enforceClassAndProtocolInList theMethod sortByClass anyMethodToWatch mclass| |
|
875 |
||
876 |
generator := inGeneratorHolder value. |
|
877 |
generator isNil ifTrue:[^ #() ]. |
|
878 |
||
879 |
allClasses := IdentitySet new. |
|
880 |
allCategories := IdentitySet new. "/ not needed - all I need to know is if there is more than 1 category |
|
881 |
"/ allSelectors := Set new. |
|
882 |
newClasses := IdentitySet new. |
|
883 |
selectorBag := Bag new. |
|
884 |
entries := OrderedCollection new. |
|
885 |
enforceClassAndProtocolInList := false. |
|
886 |
anyMethodToWatch := false. |
|
887 |
||
888 |
"/ generator generates nil-selector entries |
|
889 |
"/ to pass multiple-class and multiple-protocol info |
|
890 |
generator do:[:cls :cat :sel :mthd | |
|
891 |
(cls isNil and:[cat isNil and:[sel isNil]]) |
|
892 |
ifTrue:[ |
|
893 |
enforceClassAndProtocolInList := true |
|
894 |
] ifFalse:[ |
|
895 |
cls notNil ifTrue:[ |
|
896 |
allClasses add:cls. |
|
897 |
]. |
|
898 |
cat notNil ifTrue:[ |
|
899 |
allCategories add:cat. |
|
900 |
]. |
|
901 |
sel notNil ifTrue:[ |
|
902 |
entries add:(Array with:cls with:sel with:mthd). |
|
903 |
selectorBag add:sel. |
|
904 |
newClasses add:cls. |
|
905 |
"/ allSelectors add:sel. |
|
906 |
] |
|
907 |
]. |
|
908 |
(mthd notNil and:[mthd isWrapped]) ifTrue:[ |
|
909 |
(mthd isTiming |
|
910 |
or:[mthd isCounting |
|
911 |
or:[mthd isCountingMemoryUsage]]) |
|
912 |
ifTrue:[ |
|
913 |
anyMethodToWatch := true |
|
914 |
] |
|
915 |
]. |
|
916 |
]. |
|
917 |
||
918 |
showMethodInheritance value ~~ false ifTrue:[ |
|
919 |
"/ collect redefinition information once (big speedup for #methodIsRedefinedbelow) |
|
920 |
classAndSelectorsRedefinedBySubclassesOfClass isNil ifTrue:[ |
|
921 |
classAndSelectorsRedefinedBySubclassesOfClass := IdentityDictionary new. |
|
922 |
]. |
|
923 |
allClasses do:[:cls | |d| |
|
924 |
d := classAndSelectorsRedefinedBySubclassesOfClass. |
|
925 |
(d notNil and:[ (d includesKey:cls) not ]) ifTrue:[ |
|
926 |
d at:cls put:(self setOfAllSelectorsImplementedBelow:cls) |
|
927 |
] |
|
928 |
]. |
|
929 |
]. |
|
930 |
||
931 |
"/ multiple classes must: add the className for some |
|
932 |
doShowClass := enforceClassAndProtocolInList or:[allClasses size > 1]. |
|
933 |
"/ multiple categories: must add the categorie for some |
|
934 |
doShowCategory := enforceClassAndProtocolInList or:[allCategories size > 1]. |
|
935 |
||
936 |
doShowClassFirst := doShowClass. "/ (doShowClass and:[allSelectors size == 1]). |
|
937 |
doShowClassFirst := doShowClass and:[ sortBy value == #class ]. |
|
938 |
||
939 |
sortBy value == false ifTrue:[ |
|
940 |
"/ do not sort |
|
941 |
] ifFalse:[ |
|
942 |
(doShowClass not and:[ sortBy value == #class ]) ifTrue:[ |
|
943 |
"/ multiple classes must add the className for some |
|
944 |
"/ check, if doShowClass must be enforced |
|
945 |
entries do:[:entry | |
|
946 |
|cls sel mthd s needClass| |
|
947 |
||
948 |
cls := entry at:1. |
|
949 |
sel := entry at:2. |
|
950 |
mthd := entry at:3. |
|
951 |
doShowClass ifFalse:[ |
|
952 |
doShowClass := (selectorBag occurrencesOf:sel) > 1 |
|
953 |
]. |
|
954 |
]. |
|
955 |
]. |
|
956 |
||
957 |
sortByClass := doShowClass and:[ sortBy value == #class ]. |
|
958 |
||
959 |
sortByClass ifTrue:[ |
|
960 |
entries sort:[:a :b | |nmA nmB clsNmA clsNmB| |
|
961 |
clsNmA := (a at:1) name. |
|
962 |
clsNmB := (b at:1) name. |
|
963 |
clsNmA = clsNmB ifTrue:[ |
|
964 |
nmA := (a at:2). |
|
965 |
nmB := (b at:2). |
|
966 |
nmA < nmB |
|
967 |
] ifFalse:[ |
|
968 |
clsNmA < clsNmB |
|
969 |
] |
|
970 |
]. |
|
971 |
] ifFalse:[ |
|
972 |
entries sort:[:a :b | |nmA nmB clsNmA clsNmB| |
|
973 |
nmA := (a at:2). |
|
974 |
nmB := (b at:2). |
|
975 |
nmA = nmB ifTrue:[ |
|
976 |
clsNmA := (a at:1) name. |
|
977 |
clsNmB := (b at:1) name. |
|
978 |
clsNmA < clsNmB |
|
979 |
] ifFalse:[ |
|
980 |
nmA < nmB |
|
981 |
] |
|
982 |
]. |
|
983 |
]. |
|
984 |
]. |
|
985 |
||
986 |
methods := OrderedCollection new:(entries size). |
|
987 |
||
988 |
"/ first generate the new methodList, and see if it is different ... |
|
989 |
entries do:[:entry | |
|
990 |
|sel mthd| |
|
991 |
||
992 |
mthd := entry at:3. |
|
993 |
methods add:mthd. |
|
994 |
]. |
|
995 |
||
996 |
false "methodList = methods" "does not care for changed icons" ifTrue:[ |
|
997 |
"/ same list |
|
998 |
newNameList := self browserNameList. |
|
999 |
] ifFalse:[ |
|
1000 |
newNameList := OrderedCollection new:(entries size). |
|
1001 |
||
1002 |
"/ multiple classes must add the className for some |
|
1003 |
entries do:[:entry | |
|
1004 |
|cls sel mthd s needClass| |
|
1005 |
||
1006 |
cls := entry at:1. |
|
1007 |
sel := entry at:2. |
|
1008 |
mthd := entry at:3. |
|
1009 |
needClass := doShowClass. |
|
1010 |
"/ needClass ifFalse:[ |
|
1011 |
"/ needClass := (selectorBag occurrencesOf:sel) > 1 |
|
1012 |
"/ ]. |
|
1013 |
s := self |
|
1014 |
listEntryForMethod:mthd |
|
1015 |
selector:sel |
|
1016 |
class:cls |
|
1017 |
showClass:needClass |
|
1018 |
showCategory:doShowCategory |
|
1019 |
classFirst:doShowClassFirst. |
|
1020 |
||
1021 |
"/ s := mthd printStringForBrowserWithSelector:sel inClass:cls. |
|
1022 |
"/ needClass ifTrue:[ |
|
1023 |
"/ s := s , ' [' , cls name , ']'. |
|
1024 |
"/ ]. |
|
1025 |
"/ doShowCategory ifTrue:[ |
|
1026 |
"/ s := s , ' {' , mthd category "asText allItalic" , '}' |
|
1027 |
"/ ]. |
|
1028 |
newNameList add:s. |
|
1029 |
]. |
|
1030 |
]. |
|
1031 |
||
1032 |
self makeIndependent. |
|
1033 |
classes := newClasses. |
|
1034 |
self makeDependent. |
|
1035 |
||
1036 |
methodList := methods. |
|
1037 |
methods size == 1 ifTrue:[ |
|
1038 |
theMethod := methods first. |
|
1039 |
mclass := theMethod mclass. |
|
1040 |
mclass isNil ifTrue:[ |
|
1041 |
theMethod isWrapped ifTrue:[ |
|
1042 |
theMethod := theMethod originalMethod. |
|
1043 |
mclass := theMethod mclass. |
|
1044 |
]. |
|
1045 |
]. |
|
1046 |
mclass isNil ifTrue:[ |
|
1047 |
self methodLabelHolder value:('???' , ' ' , '???'). |
|
1048 |
] ifFalse:[ |
|
1049 |
self methodLabelHolder value:(mclass name , ' ' , theMethod selector). |
|
1050 |
] |
|
1051 |
]. |
|
1052 |
||
1053 |
anyMethodToWatch ifTrue:[ |
|
1054 |
self startWatchProcess. |
|
1055 |
] ifFalse:[ |
|
1056 |
self stopWatchProcess. |
|
1057 |
]. |
|
1058 |
||
1059 |
"/ remember these, in case of an incremental (single method only) |
|
1060 |
"/ update in the future. |
|
1061 |
lastShowClass := doShowClass. |
|
1062 |
lastShowClassFirst := doShowClassFirst. |
|
1063 |
lastShowCategory := doShowCategory. |
|
1064 |
||
1065 |
^ newNameList. |
|
1066 |
||
1067 |
"Created: / 5.2.2000 / 22:43:40 / cg" |
|
1068 |
"Modified: / 1.3.2000 / 21:00:26 / cg" |
|
1069 |
! |
|
1070 |
||
1071 |
makeDependent |
|
1072 |
Smalltalk addDependent:self. |
|
1073 |
! |
|
1074 |
||
1075 |
makeIndependent |
|
1076 |
Smalltalk removeDependent:self. |
|
1077 |
! |
|
1078 |
||
1079 |
method:mthd includesModsOfClassVariable:variablesToHighLight |
|
1080 |
^ self method:mthd includesRefsToVariable:variablesToHighLight askParserWith:#modifiedClassVars |
|
1081 |
! |
|
1082 |
||
1083 |
method:mthd includesModsOfInstanceVariable:variablesToHighLight |
|
1084 |
^ self method:mthd includesRefsToVariable:variablesToHighLight askParserWith:#modifiedInstVars |
|
1085 |
! |
|
1086 |
||
1087 |
method:mthd includesRefsToClassVariable:variablesToHighLight |
|
1088 |
^ self method:mthd includesRefsToVariable:variablesToHighLight askParserWith:#usedClassVars |
|
1089 |
! |
|
1090 |
||
1091 |
method:mthd includesRefsToInstanceVariable:variablesToHighLight |
|
1092 |
^ self method:mthd includesRefsToVariable:variablesToHighLight askParserWith:#usedInstVars |
|
1093 |
! |
|
1094 |
||
1095 |
method:mthd includesRefsToVariable:variablesToHighLight askParserWith:querySelector |
|
1096 |
|cls src parser usedVars anyVarNameAccessable| |
|
1097 |
||
1098 |
cls := mthd mclass. |
|
5885 | 1099 |
cls isNil ifTrue:[^ false]. |
1100 |
||
5591 | 1101 |
anyVarNameAccessable := cls allInstVarNames includesAny:variablesToHighLight. |
1102 |
anyVarNameAccessable ifFalse:[ |
|
5885 | 1103 |
anyVarNameAccessable := cls theNonMetaclass allClassVarNames includesAny:variablesToHighLight. |
5591 | 1104 |
]. |
1105 |
anyVarNameAccessable ifFalse:[ |
|
5885 | 1106 |
"/ no need to parse |
1107 |
^ false |
|
5591 | 1108 |
]. |
1109 |
||
1110 |
src := mthd source. |
|
1111 |
src notNil ifTrue:[ |
|
5885 | 1112 |
" |
1113 |
before doing a slow parse, quickly scan the |
|
1114 |
methods source for the variables name ... |
|
1115 |
" |
|
1116 |
(variablesToHighLight contains:[:varName | (src findString:varName) ~~ 0]) ifTrue:[ |
|
1117 |
parser := Parser |
|
1118 |
parseMethod:src |
|
1119 |
in:cls |
|
1120 |
ignoreErrors:true |
|
1121 |
ignoreWarnings:true. |
|
1122 |
(parser notNil and:[parser ~~ #Error]) ifTrue:[ |
|
1123 |
usedVars := parser perform:querySelector. |
|
1124 |
(usedVars includesAny:variablesToHighLight) |
|
1125 |
ifTrue:[ |
|
1126 |
^ true |
|
1127 |
] |
|
1128 |
] |
|
1129 |
] |
|
5591 | 1130 |
]. |
1131 |
^ false |
|
1132 |
! |
|
1133 |
||
1134 |
methodIsInheritedFromAbove:aMethod |
|
1135 |
|mClass| |
|
1136 |
||
1137 |
mClass := aMethod mclass. |
|
1138 |
(mClass notNil and:[mClass superclass notNil]) ifTrue:[ |
|
1139 |
^ (mClass superclass whichClassImplements:aMethod selector) notNil. |
|
1140 |
]. |
|
1141 |
^ false |
|
1142 |
! |
|
1143 |
||
1144 |
methodIsRedefinedBelow:aMethod |
|
1145 |
|mclass subClasses setOfRedefinedSelectors| |
|
1146 |
||
1147 |
mclass := aMethod mclass. |
|
1148 |
mclass isNil ifTrue:[^ false]. |
|
1149 |
||
1150 |
"/ if possible, make use of info prepared by listOfMethodNames |
|
1151 |
classAndSelectorsRedefinedBySubclassesOfClass notNil |
|
1152 |
ifTrue:[ |
|
1153 |
setOfRedefinedSelectors := classAndSelectorsRedefinedBySubclassesOfClass at:mclass ifAbsent:nil. |
|
1154 |
setOfRedefinedSelectors notNil ifTrue:[ |
|
1155 |
^ setOfRedefinedSelectors includes:aMethod selector |
|
1156 |
] |
|
1157 |
]. |
|
1158 |
||
1159 |
lastMethodClass == mclass ifTrue:[ |
|
1160 |
subClasses := lastMethodClassesSubclasses |
|
1161 |
] ifFalse:[ |
|
1162 |
subClasses := aMethod mclass allSubclasses. |
|
1163 |
lastMethodClassesSubclasses := subClasses. |
|
1164 |
lastMethodClass := mclass. |
|
1165 |
]. |
|
1166 |
^ subClasses contains:[:cls | cls implements:aMethod selector]. |
|
1167 |
! |
|
1168 |
||
1169 |
redefinedOrInheritedIconFor:aMethod |
|
5761
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1170 |
|inherited redefined subclassResponsibility| |
5591 | 1171 |
|
1172 |
inherited := self methodIsInheritedFromAbove:aMethod. |
|
1173 |
redefined := self methodIsRedefinedBelow:aMethod. |
|
1174 |
||
1175 |
inherited ifTrue:[ |
|
5761
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1176 |
redefined ifTrue:[ |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1177 |
^ self methodInheritedFromAboveAndRedefinedBelowIcon. |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1178 |
]. |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1179 |
^ self methodInheritedFromAboveIcon. |
5591 | 1180 |
]. |
5761
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1181 |
|
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1182 |
subclassResponsibility := aMethod sends:#subclassResponsibility. |
5591 | 1183 |
redefined ifTrue:[ |
5761
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1184 |
subclassResponsibility ifTrue:[ |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1185 |
^ self methodIsSubclassResponsibilityAndRedefinedBelowIcon. |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1186 |
]. |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1187 |
^ self methodRedefinedBelowIcon. |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1188 |
]. |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1189 |
subclassResponsibility ifTrue:[ |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1190 |
^ self methodIsSubclassResponsibilityIcon. |
5591 | 1191 |
]. |
1192 |
||
1193 |
^ self methodEmptyInheritedIcon |
|
1194 |
! |
|
1195 |
||
1196 |
release |
|
1197 |
super release. |
|
1198 |
||
1199 |
filterClassVars removeDependent:self. |
|
1200 |
selectedMethodNameIndices removeDependent:self. |
|
1201 |
showMethodInheritance removeDependent:self. |
|
1202 |
variableFilter removeDependent:self. |
|
1203 |
! |
|
1204 |
||
1205 |
resourceIconForMethod:aMethod |
|
1206 |
|resources| |
|
1207 |
||
1208 |
(resources := aMethod resources) notNil ifTrue:[ |
|
5761
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1209 |
(resources includesKey:#obsolete) ifTrue:[ |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1210 |
^ self deprecatedMethodIcon |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1211 |
]. |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1212 |
(resources includesKey:#canvas) ifTrue:[ |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1213 |
^ self canvasIcon |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1214 |
]. |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1215 |
(resources includesKey:#menu) ifTrue:[ |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1216 |
^ self menuIcon |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1217 |
]. |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1218 |
(resources includesKey:#image) ifTrue:[ |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1219 |
^ self imageIcon |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1220 |
]. |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1221 |
(resources includesKey:#fileImage) ifTrue:[ |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1222 |
^ self fileImageIcon |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1223 |
]. |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1224 |
(resources includesKey:#programImage) ifTrue:[ |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1225 |
^ self programImageIcon |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1226 |
]. |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1227 |
(resources includesKey:#help) ifTrue:[ |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1228 |
^ self helpIcon |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1229 |
]. |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1230 |
(resources includesKey:#programMenu) ifTrue:[ |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1231 |
^ self programMenuIcon |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1232 |
]. |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1233 |
(resources includesKey:#tableColumns) ifTrue:[ |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1234 |
^ self tableColumnsIcon |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1235 |
]. |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1236 |
(resources includesKey:#tabList) ifTrue:[ |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1237 |
^ self tabListIcon |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1238 |
]. |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1239 |
(resources includesKey:#hierarchicalList) ifTrue:[ |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1240 |
^ self hierarchicalListIcon |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1241 |
]. |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1242 |
(resources includesKey:#programImage) ifTrue:[ |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1243 |
^ self programImageIcon |
b350e042dc9f
Icons for subclassResponsibility and deprecated methods
Stefan Vogel <sv@exept.de>
parents:
5591
diff
changeset
|
1244 |
] |
5591 | 1245 |
]. |
1246 |
^ nil |
|
1247 |
! |
|
1248 |
||
1249 |
setOfAllSelectorsImplementedBelow:aClass |
|
1250 |
|set| |
|
1251 |
||
1252 |
set := IdentitySet new. |
|
1253 |
aClass allSubclassesDo:[:eachSubclass | |
|
1254 |
set addAll:(eachSubclass methodDictionary keys). |
|
1255 |
]. |
|
1256 |
^ set |
|
1257 |
! |
|
1258 |
||
1259 |
updateList |
|
1260 |
|prevSelection newList newSelection newSelIdx reverseMap sameContents newListSize oldListSize |
|
1261 |
prevClasses methodSet selectedMethodsHolder| |
|
1262 |
||
1263 |
selectedMethodsHolder := self selectedMethods. |
|
1264 |
prevSelection := selectedMethodsHolder value ? #(). |
|
1265 |
||
1266 |
prevClasses := classes ifNil:[ #() ] ifNotNil:[ classes copy ]. |
|
1267 |
||
1268 |
oldListSize := self browserNameList size. |
|
1269 |
||
1270 |
"/ self topApplication withWaitCursorDo:[ |
|
1271 |
newList := self listOfMethodNames. |
|
1272 |
newListSize := newList size. |
|
1273 |
sameContents := self updateListFor:newList. |
|
1274 |
||
1275 |
sameContents ifFalse:[ |
|
1276 |
"/ self browserNameList value:newList. |
|
1277 |
||
1278 |
(prevSelection size == 0 |
|
1279 |
and:[selectedMethodsHolder value size ~~ 0]) ifTrue:[ |
|
1280 |
"/ this happens during early startup time, |
|
1281 |
"/ when the selection is already (pre-)set, |
|
1282 |
"/ and the methodList is generated the first time |
|
1283 |
"/ (i.e. when opened with preset selection |
|
1284 |
||
1285 |
"/ do not clobber the selection in this case. |
|
1286 |
prevSelection := selectedMethodsHolder value. |
|
1287 |
]. |
|
1288 |
||
1289 |
(methodList size == 0 or:[prevSelection size == 0]) ifTrue:[ |
|
1290 |
newSelection := #() |
|
1291 |
] ifFalse:[ |
|
1292 |
methodSet := methodList. |
|
1293 |
||
1294 |
"/ inclusion test is much faster with sets, if the number of items is large |
|
1295 |
methodList size > 30 ifTrue:[ |
|
1296 |
"/ however, only if its worth building the set ... |
|
1297 |
prevSelection size > 5 ifTrue:[ |
|
1298 |
methodSet := methodSet asIdentitySet. |
|
1299 |
] |
|
1300 |
]. |
|
1301 |
newSelection := prevSelection select:[:item | methodSet includesIdentical:item]. |
|
1302 |
]. |
|
1303 |
newSelection size > 0 ifTrue:[ |
|
1304 |
newSelection size > 100 ifTrue:[ |
|
1305 |
"/ need selection indices - might be expensive if done straight forward... |
|
1306 |
reverseMap := IdentityDictionary new. |
|
1307 |
methodList keysAndValuesDo:[:idx :mthd | reverseMap at:mthd put:idx]. |
|
1308 |
newSelIdx := newSelection collect:[:mthd | reverseMap at:mthd]. |
|
1309 |
] ifFalse:[ |
|
1310 |
newSelIdx := newSelection collect:[:mthd | methodList identityIndexOf:mthd] |
|
1311 |
]. |
|
1312 |
"/ self halt. |
|
1313 |
"/ force change (for dependents) |
|
1314 |
selectedMethodNameIndices value:newSelIdx. |
|
1315 |
] ifFalse:[ |
|
1316 |
lastSelectedMethods := selectedMethodsHolder value. |
|
1317 |
lastSelectedMethods notNil ifTrue:[ |
|
1318 |
lastSelectedMethods := lastSelectedMethods asOrderedCollection |
|
1319 |
]. |
|
1320 |
selectedMethodNameIndices value size > 0 ifTrue:[ |
|
1321 |
selectedMethodNameIndices value:#(). |
|
1322 |
] |
|
1323 |
]. |
|
1324 |
||
1325 |
newSelection ~= prevSelection ifTrue:[ |
|
1326 |
self selectionChanged. |
|
1327 |
] |
|
1328 |
] ifTrue:[ |
|
1329 |
"/ same list - but classes might have changed |
|
1330 |
"/ that is the case, if the class selection has been changed, |
|
1331 |
"/ to another class which has the same categories. |
|
1332 |
||
1333 |
(prevClasses size ~= classes size |
|
1334 |
or:[prevClasses asOrderedCollection ~= (classes ? #()) asOrderedCollection ]) ifTrue:[ |
|
1335 |
(newListSize > 0 or:[oldListSize > 0]) ifTrue:[ |
|
1336 |
self selectionChanged. |
|
1337 |
] |
|
1338 |
] |
|
1339 |
] |
|
1340 |
"/ ]. |
|
1341 |
||
1342 |
"Modified: / 18.8.2000 / 19:47:22 / cg" |
|
1343 |
! |
|
1344 |
||
1345 |
updateListEntryFor:aMethod |
|
1346 |
"update my list for a single method. |
|
1347 |
(used when a single methods package, code or whatever changes, and a full udpate |
|
1348 |
would be too slow)" |
|
1349 |
||
1350 |
|s idx| |
|
1351 |
||
1352 |
s := self |
|
1353 |
listEntryForMethod:aMethod |
|
1354 |
selector:aMethod selector |
|
1355 |
class:aMethod mclass |
|
1356 |
showClass:lastShowClass |
|
1357 |
showCategory:lastShowCategory |
|
1358 |
classFirst:lastShowClassFirst. |
|
1359 |
||
1360 |
idx := methodList identityIndexOf:aMethod. |
|
1361 |
idx == 0 ifTrue:[ |
|
1362 |
aMethod isWrapped ifTrue:[ |
|
1363 |
idx := methodList identityIndexOf:aMethod originalMethod. |
|
1364 |
] ifFalse:[ |
|
1365 |
] |
|
1366 |
]. |
|
1367 |
idx == 0 ifTrue:[ |
|
1368 |
self invalidateList |
|
1369 |
] ifFalse:[ |
|
1370 |
self browserNameList at:idx put:s. |
|
1371 |
] |
|
1372 |
! ! |
|
1373 |
||
1374 |
!MethodList methodsFor:'private-watching'! |
|
1375 |
||
1376 |
startWatchProcess |
|
1377 |
updateProcess notNil ifTrue:[ |
|
1378 |
^ self |
|
1379 |
]. |
|
1380 |
updateProcess := [ |
|
1381 |
[true] whileTrue:[ |
|
1382 |
Delay waitForSeconds:1. |
|
1383 |
self enqueueDelayedUpdateList |
|
1384 |
] |
|
1385 |
] fork. |
|
1386 |
! |
|
1387 |
||
1388 |
stopWatchProcess |
|
1389 |
|p| |
|
1390 |
||
1391 |
(p := updateProcess) notNil ifTrue:[ |
|
1392 |
updateProcess := nil. |
|
1393 |
p terminate |
|
1394 |
]. |
|
1395 |
! ! |
|
1396 |
||
1397 |
!MethodList methodsFor:'setup'! |
|
1398 |
||
1399 |
postBuildWith:aBuilder |
|
1400 |
|methodListView| |
|
1401 |
||
1402 |
super postBuildWith:aBuilder. |
|
1403 |
||
1404 |
methodListView := aBuilder componentAt:'List'. |
|
1405 |
methodListView notNil ifTrue:[ |
|
1406 |
methodListView allowDrag:true. |
|
1407 |
methodListView dragObjectConverter:[:obj | |
|
1408 |
|nm method idx| |
|
1409 |
||
1410 |
nm := obj theObject asString. |
|
1411 |
idx := browserNameList value indexOf:nm string. |
|
1412 |
method := methodList value at:idx. |
|
1413 |
DropObject newMethod:method. |
|
1414 |
]. |
|
1415 |
] |
|
1416 |
! ! |
|
1417 |
||
1418 |
!MethodList class methodsFor:'documentation'! |
|
1419 |
||
1420 |
version |
|
5998 | 1421 |
^ '$Header: /cvs/stx/stx/libtool/Tools_MethodList.st,v 1.4 2004-09-10 10:15:34 cg Exp $' |
5591 | 1422 |
! ! |