74
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
|
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 |
'From Smalltalk/X, Version:2.10.4 on 24-feb-1995 at 7:10:38 am'!
|
|
14 |
|
|
15 |
StandardSystemView subclass:#BrowserView
|
|
16 |
instanceVariableNames:'classCategoryListView classListView methodCategoryListView
|
|
17 |
methodListView classMethodListView codeView classToggle
|
|
18 |
instanceToggle currentClassCategory currentClassHierarchy
|
|
19 |
currentClass currentMethodCategory currentMethod currentSelector
|
|
20 |
showInstance actualClass fullClass lastMethodCategory aspect
|
|
21 |
variableListView fullProtocol lockUpdates autoSearch myLabel
|
|
22 |
acceptClass'
|
|
23 |
classVariableNames:'CheckForInstancesWhenRemovingClasses DefaultIcon'
|
|
24 |
poolDictionaries:''
|
|
25 |
category:'Interface-Browsers'
|
|
26 |
!
|
|
27 |
|
|
28 |
BrowserView comment:'
|
|
29 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
|
30 |
All Rights Reserved
|
|
31 |
|
120
|
32 |
$Header: /cvs/stx/stx/libtool/BrowserView.st,v 1.19 1995-08-27 00:36:40 claus Exp $
|
74
|
33 |
'!
|
|
34 |
|
|
35 |
!BrowserView class methodsFor:'documentation'!
|
|
36 |
|
|
37 |
copyright
|
|
38 |
"
|
|
39 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
|
40 |
All Rights Reserved
|
|
41 |
|
|
42 |
This software is furnished under a license and may be used
|
|
43 |
only in accordance with the terms of that license and with the
|
|
44 |
inclusion of the above copyright notice. This software may not
|
|
45 |
be provided or otherwise made available to, or used by, any
|
|
46 |
other person. No title to or ownership of the software is
|
|
47 |
hereby transferred.
|
|
48 |
"
|
|
49 |
!
|
|
50 |
|
|
51 |
version
|
|
52 |
"
|
120
|
53 |
$Header: /cvs/stx/stx/libtool/BrowserView.st,v 1.19 1995-08-27 00:36:40 claus Exp $
|
74
|
54 |
"
|
|
55 |
!
|
|
56 |
|
|
57 |
documentation
|
|
58 |
"
|
|
59 |
this class implements all kinds of class browsers.
|
|
60 |
Typically, it is started with 'SystemBrowser open', but there are many other
|
|
61 |
startup messages, to launch special browsers.
|
|
62 |
See the categories 'startup' and 'special search startup' in the classes
|
|
63 |
protocol.
|
|
64 |
|
|
65 |
Alse, see the extra document 'doc/misc/sbrowser.doc' or the HTML online doc
|
|
66 |
for how to use the browser.
|
|
67 |
|
|
68 |
written winter 89 by claus
|
106
|
69 |
|
|
70 |
Notice: SystemBrowser is currently being rewritten to be an instance
|
|
71 |
of ApplicationModel - this transition is not yet complete and you see
|
|
72 |
here intermediate versions of BrowserView/SystemBrowser.
|
|
73 |
All action is (currently) still done here in BrowserView, although the
|
|
74 |
SystemBrowsers class methods are used to startup a browser.
|
|
75 |
This will certainly change ...
|
74
|
76 |
"
|
|
77 |
! !
|
|
78 |
|
|
79 |
!BrowserView class methodsFor:'defaults'!
|
|
80 |
|
|
81 |
defaultIcon
|
|
82 |
DefaultIcon isNil ifTrue:[
|
|
83 |
DefaultIcon := Form fromFile:'SBrowser.xbm' resolution:100
|
|
84 |
].
|
|
85 |
^ DefaultIcon
|
|
86 |
! !
|
|
87 |
|
|
88 |
!BrowserView class methodsFor:'initialization'!
|
|
89 |
|
|
90 |
initialize
|
|
91 |
"Browser configuration;
|
|
92 |
(values can be changed from your private startup file)"
|
|
93 |
|
|
94 |
"
|
|
95 |
setting this to false, the removeClass function will remove
|
|
96 |
classes WITHOUT checking for instances. Otherwise,
|
|
97 |
it will check and let you confirm in case there are instances.
|
|
98 |
Checking for instances may be a bit time consuming, though.
|
|
99 |
The default is true - therefore, it will check
|
|
100 |
"
|
|
101 |
CheckForInstancesWhenRemovingClasses := true
|
|
102 |
|
|
103 |
"
|
|
104 |
CheckForInstancesWhenRemovingClasses := true
|
|
105 |
CheckForInstancesWhenRemovingClasses := false
|
|
106 |
"
|
|
107 |
! !
|
|
108 |
|
|
109 |
!BrowserView methodsFor:'misc'!
|
|
110 |
|
85
|
111 |
processName
|
|
112 |
"the name of my process - for the processMonitor only"
|
|
113 |
|
|
114 |
^ 'System Browser'.
|
|
115 |
!
|
|
116 |
|
74
|
117 |
updateCodeView
|
|
118 |
|code|
|
|
119 |
|
|
120 |
fullClass ifTrue:[
|
|
121 |
currentClass notNil ifTrue:[
|
|
122 |
code := currentClass source.
|
|
123 |
]
|
|
124 |
] ifFalse:[
|
|
125 |
currentMethod notNil ifTrue:[
|
|
126 |
(codeView acceptAction isNil
|
|
127 |
and:[actualClass notNil
|
|
128 |
and:[currentMethodCategory notNil]]) ifTrue:[
|
|
129 |
self setAcceptAndExplainActionsForMethod.
|
|
130 |
].
|
|
131 |
|
|
132 |
code := currentMethod source.
|
|
133 |
|
|
134 |
]
|
|
135 |
].
|
|
136 |
codeView contents:code.
|
|
137 |
codeView modified:false.
|
|
138 |
|
|
139 |
self normalLabel.
|
|
140 |
!
|
|
141 |
|
|
142 |
instanceProtocol:aBoolean
|
|
143 |
"switch between instance and class protocol"
|
|
144 |
|
93
|
145 |
|onToggle offToggle|
|
|
146 |
|
74
|
147 |
showInstance ~~ aBoolean ifTrue:[
|
|
148 |
self checkSelectionChangeAllowed ifTrue:[
|
120
|
149 |
instanceToggle notNil ifTrue:[
|
|
150 |
aBoolean ifTrue:[
|
|
151 |
offToggle := classToggle.
|
|
152 |
onToggle := instanceToggle.
|
|
153 |
] ifFalse:[
|
|
154 |
onToggle := classToggle.
|
|
155 |
offToggle := instanceToggle.
|
|
156 |
].
|
|
157 |
onToggle turnOn.
|
|
158 |
offToggle turnOff.
|
74
|
159 |
].
|
|
160 |
showInstance := aBoolean.
|
|
161 |
|
|
162 |
(variableListView notNil
|
|
163 |
and:[variableListView hasSelection]) ifTrue:[
|
|
164 |
self unhilightMethodCategories.
|
|
165 |
self unhilightMethods.
|
|
166 |
variableListView deselect
|
|
167 |
].
|
|
168 |
|
|
169 |
fullProtocol ifTrue:[
|
|
170 |
showInstance ifTrue:[
|
93
|
171 |
actualClass := currentClassHierarchy.
|
74
|
172 |
] ifFalse:[
|
93
|
173 |
actualClass := currentClassHierarchy class.
|
74
|
174 |
].
|
93
|
175 |
acceptClass := actualClass.
|
74
|
176 |
|
|
177 |
self updateClassList.
|
|
178 |
self updateMethodCategoryListWithScroll:false.
|
|
179 |
self updateMethodListWithScroll:false.
|
|
180 |
self updateVariableList.
|
|
181 |
^ self
|
|
182 |
].
|
|
183 |
currentClass notNil ifTrue:[
|
|
184 |
self classSelectionChanged
|
|
185 |
].
|
|
186 |
codeView modified:false.
|
|
187 |
] ifFalse:[
|
|
188 |
aBoolean ifTrue:[
|
93
|
189 |
onToggle := classToggle.
|
|
190 |
offToggle := instanceToggle
|
74
|
191 |
] ifFalse:[
|
93
|
192 |
offToggle := classToggle.
|
|
193 |
onToggle := instanceToggle.
|
74
|
194 |
].
|
93
|
195 |
onToggle turnOn.
|
|
196 |
offToggle turnOff.
|
74
|
197 |
]
|
|
198 |
]
|
|
199 |
! !
|
|
200 |
|
|
201 |
!BrowserView methodsFor:'method stuff'!
|
|
202 |
|
|
203 |
methodSelectionChanged
|
|
204 |
"method selection has changed - update dependent views"
|
|
205 |
|
|
206 |
self withWaitCursorDo:[
|
|
207 |
|index cls|
|
|
208 |
|
|
209 |
self updateCodeView.
|
|
210 |
self setAcceptAndExplainActionsForMethod.
|
|
211 |
|
|
212 |
"
|
|
213 |
if there is any autoSearch string, do the search
|
|
214 |
"
|
|
215 |
autoSearch notNil ifTrue:[
|
|
216 |
codeView searchFwd:autoSearch startingAtLine:1 col:0 ifAbsent:[]
|
|
217 |
].
|
|
218 |
|
|
219 |
fullProtocol ifTrue:[
|
|
220 |
"
|
|
221 |
remove any bold attribute from classList
|
|
222 |
"
|
|
223 |
1 to:classListView list size do:[:i |
|
|
224 |
classListView attributeAt:i remove:#bold.
|
|
225 |
].
|
|
226 |
"
|
|
227 |
boldify the class where this method is implemented
|
|
228 |
"
|
|
229 |
currentMethod notNil ifTrue:[
|
|
230 |
cls := currentMethod who at:1.
|
|
231 |
index := classListView list indexOf:(cls name).
|
|
232 |
(index == 0
|
|
233 |
and:[cls isMeta
|
|
234 |
and:[cls name endsWith:'class']]) ifTrue:[
|
|
235 |
index := classListView list indexOf:(cls name copyWithoutLast:5).
|
|
236 |
].
|
|
237 |
index ~~ 0 ifTrue:[
|
|
238 |
classListView attributeAt:index add:#bold.
|
|
239 |
].
|
|
240 |
currentClass := acceptClass := cls.
|
|
241 |
]
|
|
242 |
].
|
|
243 |
]
|
|
244 |
!
|
|
245 |
|
|
246 |
updateMethodListWithScroll:scroll
|
107
|
247 |
self updateMethodListWithScroll:scroll keepSelection:false
|
|
248 |
!
|
|
249 |
|
|
250 |
updateMethodListWithScroll:scroll keepSelection:keep
|
|
251 |
|selectors scr first last selection|
|
|
252 |
|
74
|
253 |
|
|
254 |
methodListView notNil ifTrue:[
|
107
|
255 |
selection := methodListView selection.
|
|
256 |
|
74
|
257 |
currentMethodCategory notNil ifTrue:[
|
|
258 |
fullProtocol ifTrue:[
|
|
259 |
selectors := self listOfAllSelectorsInCategory:currentMethodCategory
|
|
260 |
inFullProtocolHierarchyOfClass:actualClass
|
|
261 |
] ifFalse:[
|
|
262 |
selectors := self listOfAllSelectorsInCategory:currentMethodCategory
|
|
263 |
ofClass:actualClass
|
|
264 |
]
|
|
265 |
].
|
|
266 |
scr := scroll.
|
|
267 |
first := methodListView firstLineShown.
|
|
268 |
first ~~ 1 ifTrue:[
|
|
269 |
last := methodListView lastLineShown.
|
|
270 |
selectors size <= (last - first + 1) ifTrue:[
|
|
271 |
scr := true
|
|
272 |
]
|
|
273 |
].
|
|
274 |
methodListView list = selectors ifFalse:[
|
|
275 |
scr ifTrue:[
|
|
276 |
methodListView contents:selectors
|
|
277 |
] ifFalse:[
|
|
278 |
methodListView setContents:selectors
|
|
279 |
]
|
|
280 |
].
|
107
|
281 |
keep ifTrue:[
|
|
282 |
methodListView selection:selection.
|
|
283 |
]
|
74
|
284 |
]
|
|
285 |
!
|
|
286 |
|
|
287 |
listOfAllSelectorsInCategory:aCategory ofClass:aClass
|
|
288 |
"answer a list of all selectors in a given method category
|
|
289 |
of the argument, aClass"
|
|
290 |
|
114
|
291 |
|newList searchCategory all|
|
|
292 |
|
|
293 |
all := (aCategory = '* all *').
|
|
294 |
(aCategory = '* no category *') ifTrue:[
|
|
295 |
searchCategory := nil
|
74
|
296 |
] ifFalse:[
|
114
|
297 |
searchCategory := aCategory
|
|
298 |
].
|
|
299 |
newList := OrderedCollection new.
|
|
300 |
aClass methodArray with:aClass selectorArray do:[:aMethod :selector |
|
|
301 |
|sel|
|
|
302 |
|
|
303 |
(all or:[aMethod category = searchCategory]) ifTrue:[
|
|
304 |
sel := selector.
|
|
305 |
aMethod isPrivate ifTrue:[
|
|
306 |
sel := sel , ' (* private *)'.
|
|
307 |
] ifFalse:[
|
107
|
308 |
aMethod isProtected ifTrue:[
|
|
309 |
sel := sel , ' (* protected *)'.
|
|
310 |
].
|
114
|
311 |
].
|
|
312 |
aMethod isWrapped ifTrue:[
|
|
313 |
sel := sel , ' !!'
|
|
314 |
].
|
|
315 |
aMethod isInvalid ifTrue:[
|
|
316 |
sel := sel , ' (not executable)'
|
|
317 |
].
|
|
318 |
newList add:sel
|
74
|
319 |
]
|
|
320 |
].
|
|
321 |
(newList size == 0) ifTrue:[^ nil].
|
|
322 |
^ newList sort
|
|
323 |
!
|
|
324 |
|
|
325 |
methodSelection:lineNr
|
|
326 |
"user clicked on a method line - show code"
|
|
327 |
|
|
328 |
|selectorString selectorSymbol|
|
|
329 |
|
|
330 |
(fullProtocol not and:[currentClass isNil]) ifTrue:[^ self].
|
|
331 |
|
|
332 |
selectorString := methodListView selectionValue.
|
|
333 |
"
|
107
|
334 |
kludge: extract real selector
|
74
|
335 |
"
|
107
|
336 |
selectorString := selectorString withoutSpaces upTo:(Character space).
|
74
|
337 |
selectorSymbol := selectorString asSymbol.
|
|
338 |
fullProtocol ifTrue:[
|
|
339 |
currentMethod := currentSelector := nil.
|
|
340 |
"
|
|
341 |
search which class implements the selector
|
|
342 |
"
|
|
343 |
self classesInFullProtocolHierarchy:actualClass do:[:c |
|
|
344 |
(currentMethod isNil
|
|
345 |
and:[c implements:selectorSymbol]) ifTrue:[
|
|
346 |
currentSelector := selectorSymbol.
|
|
347 |
currentMethod := c compiledMethodAt:selectorSymbol.
|
|
348 |
acceptClass := c
|
|
349 |
]
|
|
350 |
]
|
|
351 |
] ifFalse:[
|
|
352 |
currentSelector := selectorSymbol.
|
|
353 |
currentMethod := actualClass compiledMethodAt:selectorSymbol.
|
|
354 |
].
|
|
355 |
|
|
356 |
methodCategoryListView notNil ifTrue:[
|
|
357 |
currentMethod notNil ifTrue:[
|
|
358 |
(currentMethodCategory = currentMethod category) ifFalse:[
|
|
359 |
currentMethodCategory := currentMethod category.
|
|
360 |
methodCategoryListView selectElement:currentMethodCategory
|
|
361 |
]
|
|
362 |
]
|
|
363 |
].
|
|
364 |
|
|
365 |
self methodSelectionChanged
|
|
366 |
!
|
|
367 |
|
|
368 |
updateMethodList
|
107
|
369 |
self updateMethodListWithScroll:true keepSelection:false
|
74
|
370 |
!
|
|
371 |
|
|
372 |
checkMethodSelected
|
|
373 |
currentMethod isNil ifTrue:[
|
|
374 |
self warn:'select a method first'.
|
|
375 |
^ false
|
|
376 |
].
|
|
377 |
^ true
|
|
378 |
!
|
|
379 |
|
|
380 |
template
|
|
381 |
"return a method definition template"
|
|
382 |
|
|
383 |
^
|
|
384 |
'message selector and argument names
|
|
385 |
"comment stating purpose of message"
|
|
386 |
|
|
387 |
|
|
388 |
|temporaries|
|
|
389 |
statements
|
|
390 |
|
|
391 |
|
|
392 |
"
|
|
393 |
change above template into real code.
|
|
394 |
Then ''accept'' either via the menu
|
|
395 |
or via the keyboard (usually CMD-A).
|
|
396 |
|
|
397 |
You do not need this template; you can also
|
|
398 |
select any existing methods code, change it,
|
|
399 |
and finally ''accept''.
|
|
400 |
"
|
|
401 |
'
|
|
402 |
!
|
|
403 |
|
|
404 |
switchToMethodNamed:matchString
|
|
405 |
|aSelector method cat index classToSearch selectors|
|
|
406 |
|
|
407 |
currentClass notNil ifTrue:[
|
|
408 |
showInstance ifTrue:[
|
|
409 |
classToSearch := currentClass
|
|
410 |
] ifFalse:[
|
|
411 |
classToSearch := currentClass class
|
|
412 |
].
|
|
413 |
selectors := classToSearch selectorArray.
|
|
414 |
|
|
415 |
((matchString ~= '*') and:[matchString includesMatchCharacters]) ifTrue:[
|
|
416 |
index := selectors findFirst:[:element | matchString match:element]
|
|
417 |
] ifFalse:[
|
|
418 |
index := selectors indexOf:matchString
|
|
419 |
].
|
|
420 |
|
|
421 |
(index ~~ 0) ifTrue:[
|
|
422 |
aSelector := selectors at:index.
|
|
423 |
method := classToSearch methodArray at:index.
|
|
424 |
cat := method category.
|
|
425 |
cat isNil ifTrue:[cat := '* all *'].
|
|
426 |
methodCategoryListView selectElement:cat.
|
|
427 |
currentMethodCategory := cat.
|
|
428 |
self methodCategorySelectionChanged.
|
|
429 |
|
|
430 |
currentMethod := classToSearch compiledMethodAt:aSelector.
|
|
431 |
currentMethod notNil ifTrue:[
|
|
432 |
currentSelector := aSelector.
|
|
433 |
methodListView selectElement:aSelector.
|
|
434 |
].
|
|
435 |
self methodSelectionChanged
|
|
436 |
]
|
|
437 |
]
|
|
438 |
!
|
|
439 |
|
|
440 |
listOfAllSelectorsInCategory:aCategory inFullProtocolHierarchyOfClass:aClass
|
|
441 |
"answer a list of all selectors in a given method category
|
|
442 |
of the argument, aClass and its superclasses.
|
|
443 |
Used with fullProtocol browsing."
|
|
444 |
|
|
445 |
|newList|
|
|
446 |
|
|
447 |
newList := Set new.
|
|
448 |
self classesInFullProtocolHierarchy:aClass do:[:c |
|
|
449 |
|searchCategory|
|
|
450 |
|
|
451 |
(aCategory = '* all *') ifTrue:[
|
|
452 |
newList addAll:(c selectorArray)
|
|
453 |
] ifFalse:[
|
|
454 |
(aCategory = '* no category *') ifTrue:[
|
|
455 |
searchCategory := nil
|
|
456 |
] ifFalse:[
|
|
457 |
searchCategory := aCategory
|
|
458 |
].
|
|
459 |
c methodArray with:c selectorArray do:[:aMethod :selector |
|
|
460 |
(aMethod category = searchCategory) ifTrue:[
|
|
461 |
newList add:selector
|
|
462 |
]
|
|
463 |
]
|
|
464 |
].
|
|
465 |
].
|
|
466 |
(newList size == 0) ifTrue:[^ nil].
|
|
467 |
^ newList asOrderedCollection sort
|
|
468 |
!
|
|
469 |
|
|
470 |
switchToAnyMethodNamed:aString
|
|
471 |
|aSelector classToStartSearch aClass nm|
|
|
472 |
|
|
473 |
aSelector := aString asSymbol.
|
|
474 |
currentClass isNil ifTrue:[
|
|
475 |
currentClassHierarchy notNil ifTrue:[
|
|
476 |
classToStartSearch := currentClassHierarchy
|
|
477 |
]
|
|
478 |
] ifFalse:[
|
|
479 |
classToStartSearch := currentClass
|
|
480 |
].
|
|
481 |
classToStartSearch notNil ifTrue:[
|
|
482 |
showInstance ifFalse:[
|
|
483 |
classToStartSearch := classToStartSearch class
|
|
484 |
].
|
93
|
485 |
aClass := classToStartSearch whichClassIncludesSelector:aSelector.
|
74
|
486 |
aClass notNil ifTrue:[
|
|
487 |
nm := aClass name.
|
|
488 |
showInstance ifFalse:[
|
|
489 |
((nm ~= 'Metaclass') and:[nm endsWith:'class']) ifTrue:[
|
106
|
490 |
nm := nm copyWithoutLast:5 "copyTo:(nm size - 5)"
|
74
|
491 |
]
|
|
492 |
].
|
|
493 |
self switchToClassNamed:nm.
|
|
494 |
self switchToMethodNamed:aString
|
|
495 |
]
|
|
496 |
]
|
|
497 |
! !
|
|
498 |
|
|
499 |
!BrowserView methodsFor:'private'!
|
|
500 |
|
|
501 |
checkSelectionChangeAllowed
|
|
502 |
"return true, if selection change is ok;
|
|
503 |
its not ok, if code has been changed.
|
|
504 |
in this case, return the result of a user query"
|
|
505 |
|
107
|
506 |
|action|
|
74
|
507 |
|
|
508 |
codeView modified ifFalse:[
|
|
509 |
^ true
|
|
510 |
].
|
|
511 |
action := OptionBox
|
|
512 |
request:(resources at:'text has not been accepted.\\Your modifications will be lost when continuing.') withCRs
|
|
513 |
label:(resources string:'Attention')
|
|
514 |
form:(WarningBox iconBitmap)
|
|
515 |
buttonLabels:(resources array:#('abort' 'accept' 'continue'))
|
108
|
516 |
values:#(false #accept true)
|
|
517 |
default:true.
|
74
|
518 |
action ~~ #accept ifTrue:[
|
|
519 |
^ action
|
|
520 |
].
|
|
521 |
codeView accept. ^ true
|
|
522 |
!
|
|
523 |
|
|
524 |
normalLabel
|
|
525 |
"set the normal (inactive) window- and icon labels"
|
|
526 |
|
|
527 |
|l il|
|
|
528 |
|
|
529 |
myLabel notNil ifTrue:[
|
110
|
530 |
"if I have been given an explicit label,
|
|
531 |
and its not the default, take that one"
|
|
532 |
|
|
533 |
myLabel ~= 'System Browser' ifTrue:[
|
|
534 |
l := il := myLabel
|
|
535 |
]
|
|
536 |
].
|
|
537 |
l isNil ifTrue:[
|
74
|
538 |
l := resources string:'System Browser'.
|
|
539 |
|
|
540 |
currentClass notNil ifTrue:[
|
|
541 |
l := l, ': ', currentClass name.
|
|
542 |
classListView isNil ifTrue:[
|
|
543 |
currentSelector notNil ifTrue:[
|
|
544 |
l := l , ' ' , currentSelector
|
|
545 |
]
|
|
546 |
].
|
|
547 |
il := currentClass name
|
|
548 |
] ifFalse:[
|
|
549 |
il := l.
|
|
550 |
]
|
|
551 |
].
|
|
552 |
self label:l.
|
|
553 |
self iconLabel:il.
|
|
554 |
!
|
|
555 |
|
|
556 |
setDoitActionForClass
|
|
557 |
"tell the codeView what to do on doIt"
|
|
558 |
|
|
559 |
"set self for doits. This allows accessing the current class
|
|
560 |
as self, and access to the class variables by name.
|
|
561 |
"
|
|
562 |
codeView doItAction:[:theCode |
|
|
563 |
|compiler|
|
|
564 |
|
|
565 |
currentClass isNil ifTrue:[
|
|
566 |
compiler := Compiler
|
|
567 |
] ifFalse:[
|
108
|
568 |
compiler := currentClass evaluatorClass
|
74
|
569 |
].
|
|
570 |
compiler
|
|
571 |
evaluate:theCode
|
|
572 |
in:nil
|
|
573 |
receiver:currentClass
|
|
574 |
notifying:codeView
|
|
575 |
logged:false
|
|
576 |
ifFail:nil
|
|
577 |
].
|
|
578 |
!
|
|
579 |
|
|
580 |
setAcceptAndExplainActionsForMethod
|
|
581 |
"tell the codeView what to do on accept and explain"
|
|
582 |
|
|
583 |
codeView acceptAction:[:theCode |
|
|
584 |
|cat cls|
|
|
585 |
|
|
586 |
codeView cursor:Cursor execute.
|
|
587 |
|
|
588 |
(cat := currentMethodCategory) = '* all *' ifTrue:[
|
|
589 |
"must check from which category this code came from ...
|
|
590 |
... thanks to Arno for pointing this out"
|
|
591 |
|
|
592 |
cat := self askForMethodCategory.
|
|
593 |
].
|
|
594 |
(cat notNil and:[cat notEmpty]) ifTrue:[
|
|
595 |
fullProtocol ifTrue:[
|
93
|
596 |
cls := acceptClass "/actualClass whichClassIncludesSelector:currentSelector.
|
74
|
597 |
].
|
|
598 |
cls isNil ifTrue:[
|
|
599 |
cls := actualClass
|
|
600 |
].
|
|
601 |
|
|
602 |
Object abortSignal catch:[
|
|
603 |
lockUpdates := true.
|
|
604 |
|
|
605 |
actualClass compilerClass
|
|
606 |
compile:theCode asString
|
|
607 |
forClass:cls
|
|
608 |
inCategory:cat
|
|
609 |
notifying:codeView.
|
|
610 |
|
|
611 |
codeView modified:false.
|
|
612 |
self updateMethodListWithScroll:false.
|
|
613 |
].
|
|
614 |
lockUpdates := false.
|
|
615 |
].
|
|
616 |
codeView cursor:Cursor normal.
|
|
617 |
].
|
|
618 |
|
|
619 |
codeView explainAction:[:theCode :theSelection |
|
|
620 |
self showExplanation:(Explainer
|
|
621 |
explain:theSelection
|
|
622 |
in:theCode
|
|
623 |
forClass:actualClass)
|
|
624 |
].
|
|
625 |
!
|
|
626 |
|
|
627 |
enterBoxTitle:title okText:okText
|
|
628 |
"convenient method: setup enterBox"
|
|
629 |
|
|
630 |
|box|
|
|
631 |
|
|
632 |
box := EnterBox new.
|
|
633 |
box title:(resources string:title) okText:(resources string:okText).
|
|
634 |
^ box
|
|
635 |
!
|
|
636 |
|
|
637 |
selectorToSearchFor
|
|
638 |
"look in codeView and methodListView for a search-string when searching for selectors"
|
|
639 |
|
|
640 |
|sel t|
|
|
641 |
|
|
642 |
sel := codeView selection.
|
|
643 |
sel notNil ifTrue:[
|
|
644 |
sel := sel asString.
|
|
645 |
t := Parser selectorInExpression:sel.
|
|
646 |
t notNil ifTrue:[
|
|
647 |
sel := t
|
|
648 |
].
|
|
649 |
sel := sel withoutSpaces.
|
|
650 |
sel == #>> ifTrue:[
|
|
651 |
"oops - thats probably not what we want here ..."
|
|
652 |
self extractClassAndSelectorFromSelectionInto:[:c :s :m |
|
|
653 |
sel := s
|
|
654 |
]
|
|
655 |
]
|
|
656 |
] ifFalse:[
|
|
657 |
methodListView notNil ifTrue:[
|
|
658 |
sel := methodListView selectionValue
|
|
659 |
] ifFalse:[
|
|
660 |
classMethodListView notNil ifTrue:[
|
|
661 |
sel := classMethodListView selectionValue.
|
|
662 |
sel notNil ifTrue:[
|
|
663 |
sel := self selectorFromClassMethodString:sel
|
|
664 |
]
|
|
665 |
]
|
|
666 |
].
|
|
667 |
sel notNil ifTrue:[
|
107
|
668 |
sel := sel withoutSpaces upTo:(Character space)
|
74
|
669 |
] ifFalse:[
|
|
670 |
sel := ''
|
|
671 |
]
|
|
672 |
].
|
|
673 |
^ sel
|
|
674 |
!
|
|
675 |
|
|
676 |
setSearchPattern:aString
|
|
677 |
codeView setSearchPattern:aString
|
|
678 |
!
|
|
679 |
|
|
680 |
listBoxTitle:title okText:okText list:aList
|
|
681 |
"convenient method: setup a listBox & return it"
|
|
682 |
|
|
683 |
|box|
|
|
684 |
|
|
685 |
box := ListSelectionBox new.
|
|
686 |
box okText:(resources string:okText).
|
|
687 |
box title:(resources string:title).
|
|
688 |
box list:aList.
|
|
689 |
^ box
|
|
690 |
!
|
|
691 |
|
|
692 |
showExplanation:someText
|
|
693 |
"show explanation from Parser"
|
|
694 |
|
108
|
695 |
self information:someText
|
74
|
696 |
!
|
|
697 |
|
|
698 |
stringToSearchFor
|
|
699 |
"look in codeView and methodListView for a search-string when searching for classes/names"
|
|
700 |
|
|
701 |
|sel|
|
|
702 |
|
|
703 |
sel := codeView selection.
|
|
704 |
sel notNil ifTrue:[
|
|
705 |
sel := sel asString withoutSpaces
|
|
706 |
] ifFalse:[
|
|
707 |
sel isNil ifTrue:[
|
|
708 |
currentClass notNil ifTrue:[
|
|
709 |
sel := currentClass name
|
|
710 |
]
|
|
711 |
].
|
|
712 |
sel notNil ifTrue:[
|
|
713 |
sel := sel withoutSpaces
|
|
714 |
] ifFalse:[
|
|
715 |
sel := ''
|
|
716 |
]
|
|
717 |
].
|
|
718 |
^ sel
|
|
719 |
!
|
|
720 |
|
|
721 |
findClassOfVariable:aVariableName accessWith:aSelector
|
|
722 |
"this method returns the class, in which a variable
|
|
723 |
is defined;
|
|
724 |
needs either #instVarNames or #classVarNames as aSelector."
|
|
725 |
|
|
726 |
|cls homeClass|
|
|
727 |
|
|
728 |
"
|
|
729 |
first, find the class, where the variable is declared
|
|
730 |
"
|
|
731 |
cls := currentClass.
|
|
732 |
[cls notNil] whileTrue:[
|
|
733 |
((cls perform:aSelector) includes:aVariableName) ifTrue:[
|
|
734 |
homeClass := cls.
|
|
735 |
cls := nil.
|
|
736 |
] ifFalse:[
|
|
737 |
cls := cls superclass
|
|
738 |
]
|
|
739 |
].
|
|
740 |
homeClass isNil ifTrue:[
|
|
741 |
"nope, must be one below ... (could optimize a bit, by searching down
|
|
742 |
for the declaring class ...
|
|
743 |
"
|
|
744 |
homeClass := currentClass
|
|
745 |
] ifFalse:[
|
|
746 |
"/ Transcript showCr:'starting search in ' , homeClass name.
|
|
747 |
].
|
|
748 |
^ homeClass
|
|
749 |
!
|
|
750 |
|
|
751 |
enterBoxForSearchSelectorTitle:title
|
|
752 |
"convenient method: setup enterBox with text from codeView or selected
|
|
753 |
method for browsing based on a selector"
|
|
754 |
|
|
755 |
|box|
|
|
756 |
|
|
757 |
box := self enterBoxTitle:title okText:'search'.
|
|
758 |
box initialText:(self selectorToSearchFor).
|
|
759 |
^ box
|
|
760 |
!
|
|
761 |
|
|
762 |
enterBoxForCodeSelectionTitle:title okText:okText
|
|
763 |
"convenient method: setup enterBox with text from codeview"
|
|
764 |
|
|
765 |
|sel box|
|
|
766 |
|
|
767 |
box := self enterBoxTitle:(resources string:title) okText:(resources string:okText).
|
|
768 |
sel := codeView selection.
|
|
769 |
sel notNil ifTrue:[
|
|
770 |
box initialText:(sel asString withoutSeparators)
|
|
771 |
].
|
|
772 |
^ box
|
|
773 |
!
|
|
774 |
|
|
775 |
classesInFullProtocolHierarchy:aClass do:aBlock
|
|
776 |
"evaluate aBlock for all non-striked out classes in
|
|
777 |
the hierarchy"
|
|
778 |
|
|
779 |
|index|
|
|
780 |
|
|
781 |
index := (classListView list size).
|
|
782 |
aClass withAllSuperclasses do:[:c |
|
|
783 |
(classListView isInSelection:index) ifFalse:[
|
|
784 |
aBlock value:c
|
|
785 |
].
|
|
786 |
index := index - 1
|
|
787 |
]
|
|
788 |
|
|
789 |
!
|
|
790 |
|
|
791 |
enterBoxForBrowseTitle:title action:aBlock
|
|
792 |
"convenient method: setup enterBox with text from codeView or selected
|
|
793 |
method for method browsing based on className/variable"
|
|
794 |
|
|
795 |
|box|
|
|
796 |
|
|
797 |
box := self enterBoxTitle:title okText:'browse'.
|
|
798 |
box initialText:(self stringToSearchFor).
|
93
|
799 |
box action:[:aString |
|
|
800 |
aString notEmpty ifTrue:[
|
|
801 |
self withWaitCursorDo:[aBlock value:aString]
|
|
802 |
].
|
|
803 |
].
|
74
|
804 |
box showAtPointer
|
|
805 |
!
|
|
806 |
|
|
807 |
askAndBrowseMethodCategory:title action:aBlock
|
|
808 |
"convenient method: setup enterBox with initial being current method category"
|
|
809 |
|
|
810 |
|sel box|
|
|
811 |
|
|
812 |
box := self enterBoxTitle:title okText:'browse'.
|
|
813 |
sel := codeView selection.
|
|
814 |
sel isNil ifTrue:[
|
|
815 |
currentMethodCategory notNil ifTrue:[
|
|
816 |
sel := currentMethodCategory
|
|
817 |
]
|
|
818 |
].
|
|
819 |
sel notNil ifTrue:[
|
|
820 |
box initialText:(sel asString withoutSpaces)
|
|
821 |
].
|
|
822 |
box action:[:aString | self withWaitCursorDo:[aBlock value:aString]].
|
|
823 |
box showAtPointer
|
|
824 |
!
|
|
825 |
|
|
826 |
classHierarchyDo:aBlock
|
|
827 |
"eavluate the 2-arg block for every class,
|
|
828 |
starting at Object; passing class and nesting level to the block."
|
|
829 |
|
|
830 |
|classes s classDict l|
|
|
831 |
|
|
832 |
classes := Smalltalk allClasses.
|
|
833 |
classDict := IdentityDictionary new:classes size.
|
|
834 |
classes do:[:aClass |
|
|
835 |
s := aClass superclass.
|
|
836 |
s notNil ifTrue:[
|
|
837 |
l := classDict at:s ifAbsent:[nil].
|
|
838 |
l isNil ifTrue:[
|
|
839 |
l := OrderedCollection new:5.
|
|
840 |
classDict at:s put:l
|
|
841 |
].
|
|
842 |
l add:aClass
|
|
843 |
]
|
|
844 |
].
|
|
845 |
self classHierarchyOf:Object level:0 do:aBlock using:classDict
|
|
846 |
!
|
|
847 |
|
|
848 |
warnLabel:what
|
|
849 |
"set the title for some warning"
|
|
850 |
|
|
851 |
self label:('System Browser WARNING: ' , what)
|
|
852 |
!
|
|
853 |
|
|
854 |
classHierarchyOf:aClass level:level do:aBlock using:aDictionary
|
|
855 |
"evaluate the 2-arg block for every subclass of aClass,
|
|
856 |
passing class and nesting level to the block."
|
|
857 |
|
|
858 |
|names subclasses|
|
|
859 |
|
|
860 |
aBlock value:aClass value:level.
|
|
861 |
subclasses := aDictionary at:aClass ifAbsent:[nil].
|
|
862 |
(subclasses size == 0) ifFalse:[
|
|
863 |
names := subclasses collect:[:class | class name].
|
|
864 |
names sortWith:subclasses.
|
|
865 |
subclasses do:[:aSubClass |
|
|
866 |
self classHierarchyOf:aSubClass level:(level + 1) do:aBlock using:aDictionary
|
|
867 |
]
|
|
868 |
]
|
|
869 |
!
|
|
870 |
|
|
871 |
compileCode:someCode
|
|
872 |
(ReadStream on:someCode) fileIn
|
|
873 |
!
|
|
874 |
|
|
875 |
extractClassAndSelectorFromSelectionInto:aBlock
|
|
876 |
"given a string which can be either 'class>>sel' or
|
|
877 |
'class sel', extract className and selector, and call aBlock with
|
|
878 |
the result."
|
|
879 |
|
|
880 |
|sel clsName isMeta sep s|
|
|
881 |
|
|
882 |
sel := codeView selection.
|
|
883 |
sel notNil ifTrue:[
|
|
884 |
sel := sel asString withoutSeparators.
|
|
885 |
('*>>*' match:sel) ifTrue:[
|
|
886 |
sep := $>
|
|
887 |
] ifFalse:[
|
|
888 |
('* *' match:sel) ifTrue:[
|
|
889 |
sep := Character space
|
|
890 |
]
|
|
891 |
].
|
|
892 |
sep notNil ifTrue:[
|
|
893 |
"
|
|
894 |
extract class/sel from selection
|
|
895 |
"
|
|
896 |
s := ReadStream on:sel.
|
|
897 |
clsName := s upTo:sep.
|
|
898 |
[s peek == sep] whileTrue:[s next].
|
|
899 |
sel := s upToEnd.
|
|
900 |
|
|
901 |
(clsName endsWith:'class') ifTrue:[
|
|
902 |
isMeta := true.
|
106
|
903 |
clsName := clsName copyWithoutLast:5 "copyTo:(clsName size - 5)"
|
74
|
904 |
] ifFalse:[
|
|
905 |
isMeta := false
|
|
906 |
].
|
|
907 |
]
|
|
908 |
].
|
|
909 |
aBlock value:clsName value:sel value:isMeta
|
|
910 |
|
|
911 |
|
|
912 |
!
|
|
913 |
|
|
914 |
busyLabel:what with:someArgument
|
|
915 |
"set the title for some warning"
|
|
916 |
|
106
|
917 |
self label:('System Browser - ' , (resources string:what with:someArgument))
|
74
|
918 |
!
|
|
919 |
|
|
920 |
classesInHierarchy:aClass do:aBlock
|
|
921 |
|index|
|
|
922 |
|
|
923 |
index := (classListView list size).
|
|
924 |
aClass withAllSuperclasses do:[:c |
|
|
925 |
(classListView isInSelection:index) ifFalse:[
|
|
926 |
aBlock value:c
|
|
927 |
].
|
|
928 |
index := index - 1
|
|
929 |
]
|
|
930 |
|
|
931 |
!
|
|
932 |
|
|
933 |
askForMethodCategory
|
|
934 |
|someCategories box txt|
|
|
935 |
|
|
936 |
someCategories := actualClass categories sort.
|
|
937 |
box := self listBoxTitle:'accept in which method category ?' okText:'accept' list:someCategories.
|
|
938 |
|
|
939 |
lastMethodCategory isNil ifTrue:[
|
|
940 |
txt := 'new methods'
|
|
941 |
] ifFalse:[
|
|
942 |
txt := lastMethodCategory
|
|
943 |
].
|
|
944 |
box initialText:txt.
|
|
945 |
box action:[:aString | ^ aString ].
|
|
946 |
box showAtPointer.
|
|
947 |
^ nil
|
|
948 |
!
|
|
949 |
|
|
950 |
askForSelectorTitle:title
|
|
951 |
"convenient method: setup enterBox with text from codeView or selected
|
|
952 |
method for browsing based on a selector. Set action and launch box"
|
|
953 |
|
|
954 |
|box|
|
|
955 |
|
|
956 |
box := self enterBoxTitle:title okText:'browse'.
|
|
957 |
box initialText:(self selectorToSearchFor).
|
93
|
958 |
box action:[:aString | aString isEmpty ifTrue:[^ nil]. ^ aString].
|
74
|
959 |
box showAtPointer.
|
|
960 |
^ nil
|
|
961 |
!
|
|
962 |
|
|
963 |
askForSelectorTitle:title openWith:selector
|
|
964 |
"convenient method: setup enterBox with text from codeView or selected
|
|
965 |
method for browsing based on a selector. Set action and launch box"
|
|
966 |
|
|
967 |
|string|
|
|
968 |
|
|
969 |
string := self askForSelectorTitle:title.
|
|
970 |
string notNil ifTrue:[
|
|
971 |
self withCursor:(Cursor questionMark) do:[
|
|
972 |
SystemBrowser perform:selector with:string
|
|
973 |
]
|
|
974 |
].
|
|
975 |
!
|
|
976 |
|
|
977 |
askForSelectorTitle:title openWith:selector and:arg
|
|
978 |
"convenient method: setup enterBox with text from codeView or selected
|
|
979 |
method for browsing based on a selector. Set action and launch box"
|
|
980 |
|
|
981 |
|string|
|
|
982 |
|
|
983 |
string := self askForSelectorTitle:title.
|
|
984 |
string notNil ifTrue:[
|
|
985 |
self withCursor:(Cursor questionMark) do:[
|
|
986 |
SystemBrowser perform:selector with:string with:arg
|
|
987 |
]
|
|
988 |
].
|
|
989 |
! !
|
|
990 |
|
|
991 |
!BrowserView methodsFor:'method category stuff'!
|
|
992 |
|
|
993 |
updateMethodCategoryListWithScroll:scroll
|
|
994 |
|categories|
|
|
995 |
|
|
996 |
methodCategoryListView notNil ifTrue:[
|
|
997 |
fullProtocol ifTrue:[
|
|
998 |
currentClassHierarchy notNil ifTrue:[
|
|
999 |
categories := self listOfAllMethodCategoriesInFullProtocolHierarchy:actualClass
|
|
1000 |
]
|
|
1001 |
] ifFalse:[
|
|
1002 |
currentClass notNil ifTrue:[
|
|
1003 |
categories := self listOfAllMethodCategoriesInClass:actualClass
|
|
1004 |
]
|
|
1005 |
].
|
|
1006 |
methodCategoryListView list = categories ifFalse:[
|
|
1007 |
scroll ifTrue:[
|
|
1008 |
methodCategoryListView contents:categories
|
|
1009 |
] ifFalse:[
|
|
1010 |
methodCategoryListView setContents:categories
|
|
1011 |
].
|
|
1012 |
currentMethodCategory notNil ifTrue:[
|
|
1013 |
methodCategoryListView selectElement:currentMethodCategory
|
|
1014 |
]
|
|
1015 |
]
|
|
1016 |
]
|
|
1017 |
!
|
|
1018 |
|
|
1019 |
listOfAllMethodCategoriesInClass:aClass
|
|
1020 |
"answer a list of all method categories of the argument, aClass"
|
|
1021 |
|
|
1022 |
|newList|
|
|
1023 |
|
79
|
1024 |
newList := Set new.
|
74
|
1025 |
aClass methodArray do:[:aMethod |
|
|
1026 |
|cat|
|
|
1027 |
|
|
1028 |
cat := aMethod category.
|
|
1029 |
cat isNil ifTrue:[
|
|
1030 |
cat := '* no category *'
|
|
1031 |
].
|
79
|
1032 |
newList add:cat
|
74
|
1033 |
].
|
|
1034 |
(newList size == 0) ifTrue:[^ nil].
|
|
1035 |
newList add:'* all *'.
|
79
|
1036 |
^ newList asOrderedCollection sort
|
74
|
1037 |
!
|
|
1038 |
|
|
1039 |
methodCategorySelection:lineNr
|
|
1040 |
"user clicked on a method category line - show selectors"
|
|
1041 |
|
|
1042 |
|oldSelector|
|
|
1043 |
|
|
1044 |
"/ oldSelector := currentSelector.
|
|
1045 |
|
|
1046 |
(fullProtocol not and:[currentClass isNil]) ifTrue:[^ self].
|
|
1047 |
|
|
1048 |
currentMethodCategory := methodCategoryListView selectionValue.
|
|
1049 |
self methodCategorySelectionChanged.
|
|
1050 |
|
|
1051 |
"if there is only one method, show it right away"
|
|
1052 |
methodListView list size == 1 ifTrue:[
|
|
1053 |
methodListView selection:1.
|
|
1054 |
self methodSelection:1
|
|
1055 |
] ifFalse:[
|
|
1056 |
oldSelector notNil ifTrue:[
|
|
1057 |
methodListView selectElement:oldSelector.
|
|
1058 |
methodListView hasSelection ifTrue:[
|
|
1059 |
self methodSelection:methodListView selection.
|
|
1060 |
]
|
|
1061 |
]
|
|
1062 |
]
|
|
1063 |
!
|
|
1064 |
|
|
1065 |
methodCategorySelectionChanged
|
|
1066 |
"method category selection has changed - update dependant views"
|
|
1067 |
|
|
1068 |
self withWaitCursorDo:[
|
|
1069 |
currentMethod := currentSelector := nil.
|
|
1070 |
|
|
1071 |
self updateMethodList.
|
|
1072 |
self updateCodeView.
|
|
1073 |
|
|
1074 |
currentMethodCategory notNil ifTrue:[
|
|
1075 |
methodCategoryListView selectElement:currentMethodCategory
|
|
1076 |
].
|
|
1077 |
|
|
1078 |
self setAcceptAndExplainActionsForMethod.
|
|
1079 |
self hilightMethodsInMethodCategoryList:false inMethodList:true.
|
|
1080 |
]
|
|
1081 |
!
|
|
1082 |
|
|
1083 |
updateMethodCategoryList
|
|
1084 |
self updateMethodCategoryListWithScroll:true
|
|
1085 |
!
|
|
1086 |
|
|
1087 |
listOfAllMethodCategoriesInFullProtocolHierarchy:aClass
|
|
1088 |
"answer a list of all method categories of the argument, aClass,
|
|
1089 |
and all of its superclasses.
|
|
1090 |
Used with fullProtocol browsing."
|
|
1091 |
|
|
1092 |
|newList|
|
|
1093 |
|
79
|
1094 |
newList := Set new.
|
74
|
1095 |
self classesInFullProtocolHierarchy:aClass do:[:c |
|
|
1096 |
|cat|
|
|
1097 |
|
|
1098 |
c methodArray do:[:aMethod |
|
|
1099 |
cat := aMethod category.
|
|
1100 |
cat isNil ifTrue:[
|
|
1101 |
cat := '* no category *'
|
|
1102 |
].
|
79
|
1103 |
newList add:cat
|
74
|
1104 |
]
|
|
1105 |
].
|
|
1106 |
(newList size == 0) ifTrue:[^ nil].
|
|
1107 |
newList add:'* all *'.
|
79
|
1108 |
^ newList asOrderedCollection sort
|
74
|
1109 |
!
|
|
1110 |
|
|
1111 |
checkMethodCategorySelected
|
|
1112 |
currentMethodCategory isNil ifTrue:[
|
|
1113 |
self warn:'select a method category first'.
|
|
1114 |
^ false
|
|
1115 |
].
|
|
1116 |
^ true
|
|
1117 |
!
|
|
1118 |
|
|
1119 |
whenMethodCategorySelected:aBlock
|
|
1120 |
self checkMethodCategorySelected ifTrue:[
|
|
1121 |
self withWaitCursorDo:aBlock
|
|
1122 |
]
|
|
1123 |
!
|
|
1124 |
|
|
1125 |
copyMethodsFromClass:aClassName
|
|
1126 |
|class box|
|
|
1127 |
|
|
1128 |
currentClass notNil ifTrue:[
|
|
1129 |
class := Smalltalk classNamed:aClassName.
|
|
1130 |
class isBehavior ifFalse:[
|
|
1131 |
self warn:'no class named %1' with:aClassName.
|
|
1132 |
^ self
|
|
1133 |
].
|
|
1134 |
|
|
1135 |
showInstance ifFalse:[
|
|
1136 |
class := class class
|
|
1137 |
].
|
|
1138 |
|
|
1139 |
"show enterbox for category to copy from"
|
|
1140 |
|
|
1141 |
box := self enterBoxTitle:'name of category to copy from (matchpattern allowed, * for all):'
|
|
1142 |
okText:'copy'.
|
|
1143 |
box action:[:aString | self copyMethodsFromClass:class category:aString].
|
|
1144 |
box showAtPointer.
|
|
1145 |
]
|
|
1146 |
!
|
|
1147 |
|
|
1148 |
copyMethodsFromClass:class category:category
|
|
1149 |
currentClass notNil ifTrue:[
|
|
1150 |
Object abortSignal catch:[
|
|
1151 |
class methodArray do:[:aMethod |
|
|
1152 |
|source|
|
|
1153 |
|
|
1154 |
(category match:aMethod category) ifTrue:[
|
|
1155 |
source := aMethod source.
|
|
1156 |
codeView contents:source.
|
|
1157 |
codeView modified:false.
|
|
1158 |
actualClass compilerClass
|
|
1159 |
compile:source
|
|
1160 |
forClass:actualClass
|
|
1161 |
inCategory:aMethod category
|
|
1162 |
notifying:codeView.
|
|
1163 |
self updateMethodCategoryListWithScroll:false.
|
|
1164 |
self updateMethodListWithScroll:false.
|
|
1165 |
]
|
|
1166 |
]
|
|
1167 |
]
|
|
1168 |
]
|
|
1169 |
!
|
|
1170 |
|
|
1171 |
newMethodCategory:aString
|
|
1172 |
|categories|
|
|
1173 |
|
|
1174 |
currentClass isNil ifTrue:[
|
|
1175 |
^ self warn:'select/create a class first'.
|
|
1176 |
].
|
|
1177 |
categories := methodCategoryListView list.
|
|
1178 |
categories isNil ifTrue:[categories := OrderedCollection new].
|
|
1179 |
(categories includes:aString) ifFalse:[
|
|
1180 |
categories add:aString.
|
|
1181 |
categories sort.
|
|
1182 |
methodCategoryListView contents:categories
|
|
1183 |
].
|
|
1184 |
currentMethodCategory := aString.
|
|
1185 |
self methodCategorySelectionChanged
|
|
1186 |
! !
|
|
1187 |
|
|
1188 |
!BrowserView methodsFor:'dependencies'!
|
|
1189 |
|
|
1190 |
update:something with:someArgument from:changedObject
|
93
|
1191 |
|list|
|
|
1192 |
|
74
|
1193 |
"
|
|
1194 |
avoid update/warn after my own changes
|
|
1195 |
"
|
|
1196 |
lockUpdates == true ifTrue:[
|
|
1197 |
"/ 'ignored my change' printNL.
|
|
1198 |
^ self
|
|
1199 |
].
|
|
1200 |
|
|
1201 |
"/ changedObject print. ' ' print. someArgument print. ' ' print.
|
|
1202 |
"/ something printNL.
|
|
1203 |
|
|
1204 |
(changedObject == Smalltalk) ifTrue:[
|
|
1205 |
something == #newClass ifTrue:[
|
|
1206 |
(currentClass notNil
|
|
1207 |
and:[someArgument name = currentClass name]) ifTrue:[
|
|
1208 |
"
|
|
1209 |
the current class was autoloaded
|
|
1210 |
"
|
|
1211 |
self warnLabel:'the selected class has changed'.
|
|
1212 |
self updateClassListWithScroll:false.
|
|
1213 |
].
|
|
1214 |
|
|
1215 |
((someArgument category = currentClassCategory)
|
|
1216 |
or:[currentClassCategory notNil
|
|
1217 |
and:[currentClassCategory startsWith:'*']]) ifTrue:[
|
|
1218 |
self updateClassListWithScroll:false.
|
|
1219 |
].
|
|
1220 |
|
|
1221 |
someArgument category ~= currentClassCategory ifTrue:[
|
|
1222 |
"
|
|
1223 |
category new ?
|
|
1224 |
"
|
|
1225 |
(classCategoryListView notNil
|
93
|
1226 |
and:[(list := classCategoryListView list) notNil
|
|
1227 |
and:[(list includes:someArgument category) not]])
|
74
|
1228 |
ifTrue:[
|
|
1229 |
self updateClassCategoryListWithScroll:false.
|
|
1230 |
]
|
|
1231 |
].
|
|
1232 |
^ self
|
|
1233 |
].
|
|
1234 |
|
|
1235 |
something == #classRemove ifTrue:[
|
|
1236 |
someArgument = currentClass ifTrue:[
|
|
1237 |
self warnLabel:'the selected class was removed'.
|
|
1238 |
^ self
|
|
1239 |
].
|
|
1240 |
" fall into general update "
|
|
1241 |
].
|
|
1242 |
|
|
1243 |
"
|
|
1244 |
any other (unknown) change
|
|
1245 |
with the Smalltalk dictionary ...
|
|
1246 |
"
|
|
1247 |
self updateClassCategoryListWithScroll:false.
|
|
1248 |
self updateClassListWithScroll:false.
|
|
1249 |
^ self
|
|
1250 |
].
|
|
1251 |
|
|
1252 |
changedObject isBehavior ifTrue:[
|
|
1253 |
"
|
|
1254 |
its a class, that has changed
|
|
1255 |
"
|
|
1256 |
(currentClass notNil
|
|
1257 |
and:[changedObject name = currentClass name]) ifTrue:[
|
|
1258 |
"
|
|
1259 |
its the current class that has changed
|
|
1260 |
"
|
|
1261 |
something == #methodDictionary ifTrue:[
|
|
1262 |
(someArgument isSymbol) ifTrue:[
|
|
1263 |
|changedMethod|
|
|
1264 |
|
|
1265 |
"
|
|
1266 |
the method with selector someArgument was changed or removed
|
|
1267 |
"
|
|
1268 |
self updateMethodCategoryListWithScroll:false.
|
|
1269 |
self updateMethodListWithScroll:false.
|
|
1270 |
|
|
1271 |
someArgument == currentSelector ifTrue:[
|
|
1272 |
"
|
|
1273 |
special care here: the currently shown method has been
|
|
1274 |
changed somehow in another browser (or via fileIn)
|
|
1275 |
"
|
|
1276 |
changedMethod := currentClass compiledMethodAt:currentSelector.
|
|
1277 |
changedMethod isNil ifTrue:[
|
|
1278 |
self warnLabel:'the method shown was removed'.
|
|
1279 |
^ self
|
|
1280 |
].
|
|
1281 |
"compare the source codes"
|
79
|
1282 |
currentMethod notNil ifTrue:[
|
|
1283 |
changedMethod source = codeView contents ifFalse:[
|
|
1284 |
self warnLabel:'the code shown may not up to date'.
|
|
1285 |
]
|
|
1286 |
].
|
74
|
1287 |
^ self
|
|
1288 |
].
|
|
1289 |
^ self
|
|
1290 |
]
|
|
1291 |
].
|
|
1292 |
|
|
1293 |
something == #comment ifTrue:[
|
|
1294 |
"
|
|
1295 |
the class has changed its comment; we dont care, except if
|
|
1296 |
currently showing the comment
|
|
1297 |
"
|
|
1298 |
aspect == #comment ifTrue:[
|
|
1299 |
self warnLabel:'the comment shown may not up to date'.
|
|
1300 |
].
|
|
1301 |
^ self
|
|
1302 |
].
|
|
1303 |
something == #definition ifTrue:[
|
|
1304 |
"
|
|
1305 |
the class has changed its definition.
|
|
1306 |
Warn, except if showing a method.
|
|
1307 |
"
|
|
1308 |
aspect notNil ifTrue:[
|
|
1309 |
self warnLabel:'the classes definition has changed'.
|
|
1310 |
].
|
|
1311 |
"/ ^ self
|
|
1312 |
].
|
|
1313 |
|
|
1314 |
"
|
|
1315 |
get the class again - in case of a changed class definition,
|
|
1316 |
we are otherwise refering to the obsolete old class
|
|
1317 |
"
|
|
1318 |
currentClass := Smalltalk at:(currentClass name asSymbol).
|
|
1319 |
showInstance ifTrue:[
|
|
1320 |
actualClass := currentClass
|
|
1321 |
] ifFalse:[
|
|
1322 |
actualClass := currentClass class
|
|
1323 |
].
|
|
1324 |
|
|
1325 |
self updateMethodCategoryListWithScroll:false.
|
|
1326 |
|
|
1327 |
"dont update codeView ...."
|
|
1328 |
"self update"
|
|
1329 |
^ self
|
|
1330 |
].
|
|
1331 |
|
|
1332 |
"
|
|
1333 |
any other class has changed (but not its organization, since
|
|
1334 |
that is cought in the above case).
|
|
1335 |
We are not interrested in it - except, if showing fullProtocol
|
|
1336 |
or hierarchy ...
|
|
1337 |
"
|
|
1338 |
currentClassHierarchy notNil ifTrue:[
|
|
1339 |
fullProtocol ifTrue:[
|
|
1340 |
(currentClass isSubclassOf:changedObject) ifTrue:[
|
|
1341 |
]
|
|
1342 |
] ifFalse:[
|
|
1343 |
((currentClass isSubclassOf:changedObject)
|
|
1344 |
or:[changedObject isSubclassOf:currentClass]) ifTrue:[
|
|
1345 |
]
|
|
1346 |
]
|
|
1347 |
].
|
|
1348 |
|
|
1349 |
^ self
|
|
1350 |
].
|
|
1351 |
|
|
1352 |
(changedObject isMethod) ifTrue:[
|
|
1353 |
|
|
1354 |
]
|
|
1355 |
! !
|
|
1356 |
|
|
1357 |
!BrowserView methodsFor:'initialize / release'!
|
|
1358 |
|
|
1359 |
initialize
|
|
1360 |
super initialize.
|
|
1361 |
|
|
1362 |
showInstance := true.
|
|
1363 |
fullClass := false.
|
|
1364 |
fullProtocol := false.
|
|
1365 |
aspect := nil.
|
|
1366 |
|
|
1367 |
"inform me, when Smalltalk changes"
|
|
1368 |
Smalltalk addDependent:self
|
|
1369 |
!
|
|
1370 |
|
|
1371 |
title:someString
|
|
1372 |
myLabel := someString.
|
|
1373 |
self label:someString.
|
|
1374 |
!
|
|
1375 |
|
|
1376 |
realize
|
|
1377 |
|v checkBlock|
|
|
1378 |
|
|
1379 |
super realize.
|
|
1380 |
|
|
1381 |
checkBlock := [:lineNr | self checkSelectionChangeAllowed].
|
|
1382 |
|
|
1383 |
v := classCategoryListView.
|
|
1384 |
v notNil ifTrue:[
|
|
1385 |
v action:[:lineNr | self classCategorySelection:lineNr].
|
|
1386 |
v selectConditionBlock:checkBlock.
|
|
1387 |
v ignoreReselect:false.
|
|
1388 |
v contents:(self listOfAllClassCategories).
|
|
1389 |
"
|
|
1390 |
tell classCategoryListView to ask for the menu
|
|
1391 |
"
|
98
|
1392 |
v menuHolder:self; menuPerformer:self; menuMessage:#classCategoryMenu.
|
74
|
1393 |
].
|
|
1394 |
|
|
1395 |
v := classListView.
|
|
1396 |
v notNil ifTrue:[
|
|
1397 |
v action:[:lineNr | self classSelection:lineNr].
|
|
1398 |
v selectConditionBlock:checkBlock.
|
|
1399 |
v ignoreReselect:false.
|
|
1400 |
"
|
|
1401 |
tell classListView to ask for the menu
|
|
1402 |
"
|
98
|
1403 |
v menuHolder:self; menuPerformer:self; menuMessage:#classMenu.
|
74
|
1404 |
].
|
|
1405 |
|
|
1406 |
v := methodCategoryListView.
|
|
1407 |
v notNil ifTrue:[
|
|
1408 |
v action:[:lineNr | self methodCategorySelection:lineNr].
|
|
1409 |
v selectConditionBlock:checkBlock.
|
|
1410 |
v ignoreReselect:false.
|
|
1411 |
"
|
|
1412 |
tell methodCategoryListView to ask for the menu
|
|
1413 |
"
|
98
|
1414 |
v menuHolder:self; menuPerformer:self; menuMessage:#methodCategoryMenu.
|
74
|
1415 |
].
|
|
1416 |
|
|
1417 |
v := methodListView.
|
|
1418 |
v notNil ifTrue:[
|
|
1419 |
v action:[:lineNr | self methodSelection:lineNr].
|
|
1420 |
v selectConditionBlock:checkBlock.
|
|
1421 |
v ignoreReselect:false.
|
|
1422 |
"
|
|
1423 |
tell methodListView to ask for the menu
|
|
1424 |
"
|
98
|
1425 |
v menuHolder:self; menuPerformer:self; menuMessage:#methodMenu.
|
74
|
1426 |
].
|
|
1427 |
|
|
1428 |
v := classMethodListView.
|
|
1429 |
v notNil ifTrue:[
|
|
1430 |
v action:[:lineNr | self classMethodSelection:lineNr].
|
|
1431 |
v selectConditionBlock:checkBlock.
|
|
1432 |
v ignoreReselect:false.
|
|
1433 |
"
|
|
1434 |
tell classMethodListView to ask for the menu
|
|
1435 |
"
|
98
|
1436 |
v menuHolder:self; menuPerformer:self; menuMessage:#classMethodMenu.
|
74
|
1437 |
].
|
|
1438 |
|
|
1439 |
v := variableListView.
|
|
1440 |
v notNil ifTrue:[
|
|
1441 |
v action:[:lineNr | self variableSelection:lineNr].
|
|
1442 |
v ignoreReselect:false.
|
98
|
1443 |
v toggleSelect:true.
|
|
1444 |
v menuHolder:self; menuPerformer:self; menuMessage:#variableListMenu.
|
74
|
1445 |
].
|
|
1446 |
|
|
1447 |
"
|
|
1448 |
normal browsers show the top at first;
|
|
1449 |
hierarchy and fullProtocol browsers better show the end
|
|
1450 |
initially
|
|
1451 |
"
|
|
1452 |
currentClassHierarchy notNil ifTrue:[
|
|
1453 |
classListView scrollToBottom.
|
|
1454 |
]
|
|
1455 |
!
|
|
1456 |
|
|
1457 |
destroy
|
|
1458 |
"relese dependant - destroy popups"
|
|
1459 |
|
|
1460 |
Smalltalk removeDependent:self.
|
|
1461 |
currentClass notNil ifTrue:[
|
|
1462 |
currentClass removeDependent:self.
|
|
1463 |
currentClass := nil
|
|
1464 |
].
|
|
1465 |
super destroy
|
|
1466 |
!
|
|
1467 |
|
|
1468 |
terminate
|
|
1469 |
(self checkSelectionChangeAllowed) ifTrue:[
|
|
1470 |
super terminate
|
|
1471 |
]
|
|
1472 |
!
|
|
1473 |
|
|
1474 |
autoSearch:aString
|
|
1475 |
"used with class-method list browsing. If true,
|
|
1476 |
selecting an entry from the list will automatically
|
|
1477 |
search for the searchstring in the codeView"
|
|
1478 |
|
|
1479 |
self setSearchPattern:aString.
|
|
1480 |
autoSearch := aString
|
|
1481 |
! !
|
|
1482 |
|
|
1483 |
!BrowserView methodsFor:'initialize subviews'!
|
|
1484 |
|
|
1485 |
createCodeViewIn:aView at:relY
|
|
1486 |
"setup the code view"
|
|
1487 |
|v|
|
|
1488 |
|
|
1489 |
v := HVScrollableView for:CodeView miniScrollerH:true miniScrollerV:false in:aView.
|
|
1490 |
v origin:(0.0 @ relY) corner:(1.0 @ 1.0).
|
|
1491 |
codeView := v scrolledView
|
|
1492 |
!
|
|
1493 |
|
|
1494 |
createCodeViewIn:aView
|
|
1495 |
"setup the code view"
|
|
1496 |
|
|
1497 |
^ self createCodeViewIn:aView at:0.25
|
|
1498 |
!
|
|
1499 |
|
|
1500 |
createTogglesIn:aFrame
|
|
1501 |
"create and setup the class/instance toggles"
|
|
1502 |
|
|
1503 |
|h halfSpace classAction instanceAction|
|
|
1504 |
|
93
|
1505 |
classAction := [self instanceProtocol:false].
|
|
1506 |
instanceAction := [self instanceProtocol:true].
|
74
|
1507 |
|
|
1508 |
halfSpace := ViewSpacing // 2.
|
|
1509 |
|
|
1510 |
instanceToggle := Toggle label:(resources at:'instance') in:aFrame.
|
|
1511 |
h := instanceToggle height.
|
|
1512 |
instanceToggle origin:(0.0 @ 1.0) corner:(0.5 @ 1.0).
|
|
1513 |
instanceToggle topInset:h negated.
|
|
1514 |
|
|
1515 |
instanceToggle turnOn.
|
|
1516 |
instanceToggle pressAction:instanceAction.
|
|
1517 |
instanceToggle releaseAction:classAction.
|
|
1518 |
|
|
1519 |
classToggle := Toggle label:(resources at:'class') in:aFrame.
|
|
1520 |
h := classToggle height.
|
|
1521 |
classToggle origin:(0.5 @ 1.0) corner:(1.0 @ 1.0).
|
|
1522 |
classToggle topInset:h negated.
|
|
1523 |
|
|
1524 |
classToggle turnOff.
|
|
1525 |
classToggle pressAction:classAction.
|
|
1526 |
classToggle releaseAction:instanceAction.
|
|
1527 |
|
105
|
1528 |
styleSheet is3D ifTrue:[
|
81
|
1529 |
instanceToggle bottomInset:halfSpace.
|
|
1530 |
classToggle bottomInset:halfSpace.
|
|
1531 |
|
74
|
1532 |
instanceToggle leftInset:halfSpace.
|
|
1533 |
classToggle leftInset:halfSpace.
|
|
1534 |
instanceToggle rightInset:ViewSpacing - halfSpace.
|
|
1535 |
classToggle rightInset:ViewSpacing - halfSpace.
|
|
1536 |
].
|
|
1537 |
!
|
|
1538 |
|
|
1539 |
setupForList:aList
|
|
1540 |
"setup subviews to browse methods from a list"
|
|
1541 |
|
|
1542 |
|vpanel v|
|
|
1543 |
|
|
1544 |
vpanel := VariableVerticalPanel
|
|
1545 |
origin:(0.0 @ 0.0)
|
|
1546 |
corner:(1.0 @ 1.0)
|
|
1547 |
in:self.
|
|
1548 |
|
|
1549 |
v := ScrollableView for:SelectionInListView in:vpanel.
|
|
1550 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 0.25).
|
|
1551 |
classMethodListView := v scrolledView.
|
|
1552 |
classMethodListView contents:aList.
|
|
1553 |
|
|
1554 |
self createCodeViewIn:vpanel.
|
|
1555 |
self updateCodeView
|
|
1556 |
!
|
|
1557 |
|
|
1558 |
createClassListViewIn:frame
|
|
1559 |
"setup the classlist subview, with its toggles"
|
|
1560 |
|
93
|
1561 |
|v panel|
|
74
|
1562 |
|
|
1563 |
self createTogglesIn:frame.
|
|
1564 |
|
|
1565 |
"
|
|
1566 |
oldstyle had no variableList ...
|
|
1567 |
"
|
93
|
1568 |
"/ v := ScrollableView for:SelectionInListView in:frame.
|
|
1569 |
"/ v origin:(0.0 @ 0.0)
|
|
1570 |
"/ extent:[frame width
|
|
1571 |
"/ @
|
|
1572 |
"/ (frame height
|
|
1573 |
"/ - ViewSpacing
|
|
1574 |
"/ - instanceToggle height
|
|
1575 |
"/ - instanceToggle borderWidth
|
|
1576 |
"/ + v borderWidth)].
|
|
1577 |
"/
|
|
1578 |
"/ classListView := v scrolledView
|
|
1579 |
|
|
1580 |
panel := VariableVerticalPanel
|
74
|
1581 |
origin:(0.0 @ 0.0)
|
|
1582 |
corner:[frame width
|
|
1583 |
@
|
|
1584 |
(frame height
|
|
1585 |
- ViewSpacing
|
|
1586 |
- instanceToggle height
|
81
|
1587 |
"-" + instanceToggle borderWidth
|
74
|
1588 |
+ v borderWidth)]
|
|
1589 |
in:frame.
|
|
1590 |
|
93
|
1591 |
v := ScrollableView for:SelectionInListView in:panel.
|
|
1592 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 0.7).
|
|
1593 |
classListView := v scrolledView.
|
|
1594 |
|
|
1595 |
|
|
1596 |
v := ScrollableView for:SelectionInListView in:panel.
|
|
1597 |
v origin:(0.0 @ 0.7) corner:(1.0 @ 1.0).
|
|
1598 |
|
|
1599 |
variableListView := v scrolledView.
|
74
|
1600 |
!
|
|
1601 |
|
|
1602 |
setupForAll
|
|
1603 |
"create subviews for a full browser"
|
|
1604 |
|
|
1605 |
|vpanel hpanel frame v|
|
|
1606 |
|
|
1607 |
vpanel := VariableVerticalPanel origin:(0.0 @ 0.0) corner:(1.0 @ 1.0)
|
|
1608 |
in:self.
|
|
1609 |
hpanel := View origin:(0.0 @ 0.0) corner:(1.0 @ 0.25) in:vpanel.
|
|
1610 |
|
|
1611 |
v := HVScrollableView for:SelectionInListView
|
|
1612 |
miniScrollerH:true miniScrollerV:false
|
|
1613 |
in:hpanel.
|
|
1614 |
v origin:(0.0 @ 0.0) corner:(0.25 @ 1.0).
|
|
1615 |
classCategoryListView := v scrolledView.
|
|
1616 |
|
|
1617 |
frame := View origin:(0.25 @ 0.0) corner:(0.5 @ 1.0) in:hpanel.
|
|
1618 |
self createClassListViewIn:frame.
|
|
1619 |
|
|
1620 |
v := HVScrollableView for:SelectionInListView miniScrollerH:true miniScrollerV:false in:hpanel.
|
|
1621 |
v origin:(0.5 @ 0.0) corner:(0.75 @ 1.0).
|
|
1622 |
methodCategoryListView := v scrolledView.
|
|
1623 |
|
|
1624 |
v := HVScrollableView for:SelectionInListView miniScrollerH:true miniScrollerV:false in:hpanel.
|
|
1625 |
v origin:(0.75 @ 0.0) corner:(1.0 @ 1.0).
|
|
1626 |
methodListView := v scrolledView.
|
|
1627 |
|
|
1628 |
self createCodeViewIn:vpanel
|
|
1629 |
!
|
|
1630 |
|
|
1631 |
focusSequence
|
|
1632 |
|s|
|
|
1633 |
|
|
1634 |
s := OrderedCollection new.
|
|
1635 |
|
|
1636 |
classCategoryListView notNil ifTrue:[
|
|
1637 |
s add:classCategoryListView
|
|
1638 |
].
|
|
1639 |
|
|
1640 |
classListView notNil ifTrue:[
|
|
1641 |
s add:classListView
|
|
1642 |
].
|
|
1643 |
|
|
1644 |
"/ variableListView notNil ifTrue:[
|
|
1645 |
"/ s add:variableListView
|
|
1646 |
"/ ].
|
|
1647 |
|
|
1648 |
instanceToggle notNil ifTrue:[
|
|
1649 |
s add:instanceToggle.
|
|
1650 |
].
|
|
1651 |
|
|
1652 |
methodCategoryListView notNil ifTrue:[
|
|
1653 |
s add:methodCategoryListView
|
|
1654 |
].
|
|
1655 |
|
|
1656 |
methodListView notNil ifTrue:[
|
|
1657 |
s add:methodListView
|
|
1658 |
].
|
|
1659 |
|
|
1660 |
classMethodListView notNil ifTrue:[
|
|
1661 |
s add:classMethodListView
|
|
1662 |
].
|
|
1663 |
|
|
1664 |
s add:codeView.
|
|
1665 |
^ s
|
|
1666 |
!
|
|
1667 |
|
|
1668 |
setupForClass:aClass
|
|
1669 |
"create subviews for browsing a single class"
|
|
1670 |
|
|
1671 |
|vpanel hpanel frame v|
|
|
1672 |
|
|
1673 |
vpanel := VariableVerticalPanel origin:(0.0 @ 0.0)
|
|
1674 |
corner:(1.0 @ 1.0)
|
|
1675 |
in:self.
|
|
1676 |
|
|
1677 |
hpanel := View origin:(0.0 @ 0.0) corner:(1.0 @ 0.25) in:vpanel.
|
|
1678 |
frame := View origin:(0.0 @ 0.0) corner:(0.5 @ 1.0)in:hpanel.
|
|
1679 |
|
|
1680 |
self createTogglesIn:frame.
|
|
1681 |
|
|
1682 |
v := ScrollableView for:SelectionInListView in:frame.
|
|
1683 |
v origin:(0.0 @ 0.0)
|
|
1684 |
extent:[frame width
|
|
1685 |
@
|
|
1686 |
(frame height
|
|
1687 |
- ViewSpacing
|
|
1688 |
- instanceToggle height
|
|
1689 |
- instanceToggle borderWidth
|
|
1690 |
+ v borderWidth)].
|
|
1691 |
methodCategoryListView := v scrolledView.
|
|
1692 |
|
|
1693 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
1694 |
v origin:(0.5 @ 0.0) corner:(1.0 @ 1.0).
|
|
1695 |
methodListView := v scrolledView.
|
|
1696 |
|
|
1697 |
self createCodeViewIn:vpanel.
|
|
1698 |
|
|
1699 |
self switchToClass:aClass.
|
|
1700 |
actualClass := acceptClass := aClass.
|
|
1701 |
self updateMethodCategoryList.
|
|
1702 |
self updateMethodList.
|
|
1703 |
self updateCodeView
|
|
1704 |
!
|
|
1705 |
|
|
1706 |
setupForClassHierarchy:aClass
|
|
1707 |
"setup subviews to browse a class hierarchy"
|
|
1708 |
|
108
|
1709 |
|vpanel hpanel frame v cls|
|
74
|
1710 |
|
|
1711 |
vpanel := VariableVerticalPanel origin:(0.0 @ 0.0)
|
|
1712 |
corner:(1.0 @ 1.0)
|
|
1713 |
in:self.
|
|
1714 |
|
|
1715 |
"
|
|
1716 |
notice: we use a different ratio here
|
|
1717 |
"
|
|
1718 |
hpanel := View origin:(0.0 @ 0.0) corner:(1.0 @ 0.4) in:vpanel.
|
|
1719 |
frame := View origin:(0.0 @ 0.0) corner:(0.33 @ 1.0) in:hpanel.
|
|
1720 |
|
|
1721 |
self createClassListViewIn:frame.
|
|
1722 |
|
|
1723 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
1724 |
v origin:(0.33 @ 0.0) corner:(0.66 @ 1.0).
|
|
1725 |
methodCategoryListView := v scrolledView.
|
|
1726 |
|
|
1727 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
1728 |
v origin:(0.66 @ 0.0) corner:(1.0 @ 1.0).
|
|
1729 |
methodListView := v scrolledView.
|
|
1730 |
|
|
1731 |
self createCodeViewIn:vpanel at:0.4.
|
|
1732 |
|
108
|
1733 |
cls := aClass.
|
|
1734 |
cls isMeta ifTrue:[
|
|
1735 |
cls := cls soleInstance
|
|
1736 |
].
|
|
1737 |
currentClassHierarchy := currentClass := actualClass := cls.
|
74
|
1738 |
self updateClassList.
|
92
|
1739 |
classListView selectElement:aClass name; makeSelectionVisible.
|
74
|
1740 |
self updateMethodCategoryList.
|
|
1741 |
self updateMethodList.
|
108
|
1742 |
self updateCodeView.
|
|
1743 |
|
|
1744 |
aClass isMeta ifTrue:[
|
|
1745 |
self instanceProtocol:false
|
|
1746 |
].
|
74
|
1747 |
!
|
|
1748 |
|
|
1749 |
setupForFullClass
|
|
1750 |
"setup subviews to browse a class as full text"
|
|
1751 |
|
|
1752 |
|vpanel hpanel v|
|
|
1753 |
|
|
1754 |
vpanel := VariableVerticalPanel origin:(0.0 @ 0.0)
|
|
1755 |
corner:(1.0 @ 1.0)
|
|
1756 |
in:self.
|
|
1757 |
|
|
1758 |
hpanel := View origin:(0.0 @ 0.0) corner:(1.0 @ 0.25) in:vpanel.
|
|
1759 |
|
|
1760 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
1761 |
v origin:(0.0 @ 0.0) corner:(0.5 @ 1.0).
|
|
1762 |
classCategoryListView := v scrolledView.
|
|
1763 |
classCategoryListView contents:(self listOfAllClassCategories).
|
|
1764 |
|
|
1765 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
1766 |
v origin:(0.5 @ 0.0) corner:(1.0 @ 1.0).
|
|
1767 |
classListView := v scrolledView.
|
|
1768 |
|
|
1769 |
self createCodeViewIn:vpanel.
|
|
1770 |
|
|
1771 |
fullClass := true.
|
|
1772 |
self updateCodeView
|
|
1773 |
!
|
|
1774 |
|
|
1775 |
setupForClassCategory:aClassCategory
|
|
1776 |
"setup subviews to browse a class category"
|
|
1777 |
|
|
1778 |
|vpanel hpanel frame v|
|
|
1779 |
|
|
1780 |
vpanel := VariableVerticalPanel origin:(0.0 @ 0.0)
|
|
1781 |
corner:(1.0 @ 1.0)
|
|
1782 |
in:self.
|
|
1783 |
|
|
1784 |
hpanel := View origin:(0.0 @ 0.0) corner:(1.0 @ 0.25) in:vpanel.
|
|
1785 |
frame := View origin:(0.0 @ 0.0) corner:(0.33 @ 1.0) in:hpanel.
|
|
1786 |
|
|
1787 |
self createClassListViewIn:frame.
|
|
1788 |
|
|
1789 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
1790 |
v origin:(0.33 @ 0.0) corner:(0.66 @ 1.0).
|
|
1791 |
methodCategoryListView := v scrolledView.
|
|
1792 |
|
|
1793 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
1794 |
v origin:(0.66 @ 0.0) corner:(1.0 @ 1.0).
|
|
1795 |
methodListView := v scrolledView.
|
|
1796 |
|
|
1797 |
self createCodeViewIn:vpanel.
|
|
1798 |
|
|
1799 |
currentClassCategory := aClassCategory.
|
|
1800 |
self updateClassList.
|
|
1801 |
self updateMethodCategoryList.
|
|
1802 |
self updateMethodList.
|
|
1803 |
self updateCodeView
|
|
1804 |
!
|
|
1805 |
|
|
1806 |
setupForClass:aClass selector:selector
|
|
1807 |
"setup subviews to browse a single method"
|
|
1808 |
|
|
1809 |
|v|
|
|
1810 |
|
|
1811 |
v := ScrollableView for:CodeView in:self.
|
|
1812 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
|
|
1813 |
codeView := v scrolledView.
|
|
1814 |
|
|
1815 |
currentClassCategory := aClass category.
|
|
1816 |
self switchToClass:aClass.
|
|
1817 |
actualClass := acceptClass := aClass.
|
|
1818 |
currentSelector := selector.
|
|
1819 |
currentMethod := currentClass compiledMethodAt:selector.
|
|
1820 |
currentMethodCategory := currentMethod category.
|
|
1821 |
self updateCodeView
|
|
1822 |
!
|
|
1823 |
|
|
1824 |
setupForClassList:aList
|
|
1825 |
"setup subviews to browse classes from a list"
|
|
1826 |
|
|
1827 |
|vpanel hpanel frame l v|
|
|
1828 |
|
|
1829 |
vpanel := VariableVerticalPanel
|
|
1830 |
origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:self.
|
|
1831 |
|
|
1832 |
hpanel := View origin:(0.0 @ 0.0) corner:(1.0 @ 0.25) in:vpanel.
|
|
1833 |
frame := View origin:(0.0 @ 0.0) corner:(0.33 @ 1.0) in:hpanel.
|
|
1834 |
|
|
1835 |
self createClassListViewIn:frame.
|
|
1836 |
|
|
1837 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
1838 |
v origin:(0.33 @ 0.0) corner:(0.66 @ 1.0).
|
|
1839 |
methodCategoryListView := v scrolledView.
|
|
1840 |
|
|
1841 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
1842 |
v origin:(0.66 @ 0.0) corner:(1.0 @ 1.0).
|
|
1843 |
methodListView := v scrolledView.
|
|
1844 |
|
|
1845 |
self createCodeViewIn:vpanel.
|
|
1846 |
|
|
1847 |
l := aList collect:[:entry | entry name].
|
|
1848 |
classListView list:(l sort).
|
|
1849 |
|
|
1850 |
self updateMethodCategoryList.
|
|
1851 |
self updateMethodList.
|
|
1852 |
self updateCodeView
|
|
1853 |
!
|
|
1854 |
|
|
1855 |
setupForClass:aClass methodCategory:aMethodCategory
|
|
1856 |
"setup subviews to browse a method category"
|
|
1857 |
|
|
1858 |
|vpanel v|
|
|
1859 |
|
|
1860 |
vpanel := VariableVerticalPanel
|
|
1861 |
origin:(0.0 @ 0.0) corner:(1.0 @ 1.0)
|
|
1862 |
in:self.
|
|
1863 |
|
|
1864 |
v := ScrollableView for:SelectionInListView in:vpanel.
|
|
1865 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 0.25).
|
|
1866 |
methodListView := v scrolledView.
|
|
1867 |
|
|
1868 |
self createCodeViewIn:vpanel.
|
|
1869 |
|
|
1870 |
currentClassCategory := aClass category.
|
|
1871 |
self switchToClass:aClass.
|
|
1872 |
actualClass := acceptClass := aClass.
|
|
1873 |
currentMethodCategory := aMethodCategory.
|
|
1874 |
self updateMethodList.
|
|
1875 |
self updateCodeView
|
|
1876 |
!
|
|
1877 |
|
|
1878 |
setupForFullClassProtocol:aClass
|
|
1879 |
"setup subviews to browse a classes full protocol"
|
|
1880 |
|
108
|
1881 |
|vpanel hpanel frame v cls|
|
74
|
1882 |
|
|
1883 |
vpanel := VariableVerticalPanel origin:(0.0 @ 0.0)
|
|
1884 |
corner:(1.0 @ 1.0)
|
|
1885 |
in:self.
|
|
1886 |
|
|
1887 |
"
|
|
1888 |
notice: we use a different ratio here
|
|
1889 |
"
|
|
1890 |
hpanel := View origin:(0.0 @ 0.0) corner:(1.0 @ 0.4) in:vpanel.
|
|
1891 |
frame := View origin:(0.0 @ 0.0) corner:(0.33 @ 1.0) in:hpanel.
|
|
1892 |
|
|
1893 |
self createClassListViewIn:frame.
|
|
1894 |
classListView multipleSelectOk:true.
|
|
1895 |
classListView toggleSelect:true.
|
|
1896 |
classListView strikeOut:true.
|
|
1897 |
|
|
1898 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
1899 |
v origin:(0.33 @ 0.0) corner:(0.66 @ 1.0).
|
|
1900 |
methodCategoryListView := v scrolledView.
|
|
1901 |
|
|
1902 |
v := ScrollableView for:SelectionInListView in:hpanel.
|
|
1903 |
v origin:(0.66 @ 0.0) corner:(1.0 @ 1.0).
|
|
1904 |
methodListView := v scrolledView.
|
|
1905 |
|
|
1906 |
self createCodeViewIn:vpanel at:0.4.
|
|
1907 |
|
108
|
1908 |
cls := aClass.
|
|
1909 |
cls isMeta ifTrue:[
|
|
1910 |
cls := cls soleInstance
|
|
1911 |
].
|
|
1912 |
currentClassHierarchy := actualClass := acceptClass := currentClass := cls.
|
74
|
1913 |
fullProtocol := true.
|
|
1914 |
|
|
1915 |
self updateClassList.
|
|
1916 |
self updateMethodCategoryList.
|
|
1917 |
self updateMethodList.
|
|
1918 |
self updateCodeView.
|
|
1919 |
self updateVariableList.
|
108
|
1920 |
aClass isMeta ifTrue:[
|
|
1921 |
self instanceProtocol:false
|
|
1922 |
].
|
74
|
1923 |
! !
|
|
1924 |
|
|
1925 |
!BrowserView methodsFor:'class stuff'!
|
|
1926 |
|
|
1927 |
switchToClass:newClass
|
108
|
1928 |
|cls|
|
|
1929 |
|
74
|
1930 |
fullProtocol ifTrue:[^ self].
|
108
|
1931 |
|
|
1932 |
cls := newClass.
|
|
1933 |
cls isMeta ifTrue:[
|
|
1934 |
cls := cls soleInstance
|
|
1935 |
].
|
74
|
1936 |
currentClass notNil ifTrue:[
|
|
1937 |
currentClass removeDependent:self
|
|
1938 |
].
|
|
1939 |
currentClass := newClass.
|
|
1940 |
currentClass notNil ifTrue:[
|
|
1941 |
currentClass addDependent:self.
|
|
1942 |
].
|
108
|
1943 |
self normalLabel.
|
|
1944 |
newClass isMeta ifTrue:[
|
|
1945 |
self instanceProtocol:false
|
|
1946 |
]
|
74
|
1947 |
!
|
|
1948 |
|
|
1949 |
classSelectionChanged
|
|
1950 |
|oldMethodCategory oldMethod oldSelector|
|
|
1951 |
|
|
1952 |
self withWaitCursorDo:[
|
|
1953 |
oldMethodCategory := currentMethodCategory.
|
|
1954 |
oldMethod := currentMethod.
|
|
1955 |
oldSelector := currentSelector.
|
|
1956 |
|
|
1957 |
showInstance ifTrue:[
|
|
1958 |
actualClass := acceptClass := currentClass
|
|
1959 |
] ifFalse:[
|
|
1960 |
actualClass := acceptClass := currentClass class
|
|
1961 |
].
|
|
1962 |
currentMethodCategory := nil.
|
|
1963 |
currentMethod := nil.
|
|
1964 |
currentSelector := nil.
|
|
1965 |
|
|
1966 |
self updateVariableList.
|
|
1967 |
self updateMethodCategoryList.
|
|
1968 |
|
|
1969 |
oldMethodCategory notNil ifTrue:[
|
|
1970 |
methodCategoryListView selectElement:oldMethodCategory.
|
|
1971 |
methodCategoryListView hasSelection ifTrue:[
|
|
1972 |
currentMethodCategory := oldMethodCategory.
|
|
1973 |
self methodCategorySelectionChanged
|
|
1974 |
]
|
|
1975 |
].
|
|
1976 |
self updateMethodList.
|
|
1977 |
self updateCodeView.
|
|
1978 |
|
|
1979 |
fullClass ifTrue:[
|
|
1980 |
codeView acceptAction:[:theCode |
|
|
1981 |
codeView cursor:Cursor execute.
|
|
1982 |
Object abortSignal catch:[
|
|
1983 |
self compileCode:theCode asString.
|
|
1984 |
codeView modified:false.
|
|
1985 |
].
|
|
1986 |
codeView cursor:Cursor normal.
|
|
1987 |
].
|
|
1988 |
] ifFalse:[
|
|
1989 |
self classDefinition.
|
|
1990 |
codeView acceptAction:[:theCode |
|
|
1991 |
codeView cursor:Cursor execute.
|
|
1992 |
Object abortSignal catch:[
|
|
1993 |
(Compiler evaluate:theCode asString notifying:codeView compile:false)
|
|
1994 |
isBehavior ifTrue:[
|
|
1995 |
self classCategoryUpdate.
|
|
1996 |
self updateClassListWithScroll:false.
|
|
1997 |
codeView modified:false.
|
|
1998 |
].
|
|
1999 |
].
|
|
2000 |
codeView cursor:Cursor normal.
|
|
2001 |
].
|
|
2002 |
].
|
|
2003 |
codeView explainAction:nil.
|
|
2004 |
|
|
2005 |
classCategoryListView notNil ifTrue:[
|
|
2006 |
(currentClassCategory = currentClass category) ifFalse:[
|
|
2007 |
currentClassCategory := currentClass category.
|
|
2008 |
classCategoryListView selectElement:currentClassCategory
|
|
2009 |
]
|
|
2010 |
].
|
|
2011 |
|
|
2012 |
self setDoitActionForClass
|
|
2013 |
]
|
|
2014 |
!
|
|
2015 |
|
|
2016 |
updateClassListWithScroll:scroll
|
|
2017 |
|classes oldClassName|
|
|
2018 |
|
|
2019 |
classListView notNil ifTrue:[
|
|
2020 |
"
|
|
2021 |
refetch in case we are not up to date
|
|
2022 |
"
|
|
2023 |
(currentClass notNil and:[fullProtocol not]) ifTrue:[
|
|
2024 |
oldClassName := currentClass name.
|
|
2025 |
currentClass := Smalltalk at:(oldClassName asSymbol).
|
|
2026 |
].
|
|
2027 |
|
|
2028 |
currentClassCategory notNil ifTrue:[
|
|
2029 |
classes := self listOfAllClassesInCategory:currentClassCategory
|
|
2030 |
] ifFalse:[
|
|
2031 |
currentClassHierarchy notNil ifTrue:[
|
|
2032 |
classes := self listOfClassHierarchyOf:currentClassHierarchy
|
|
2033 |
]
|
|
2034 |
].
|
|
2035 |
|
|
2036 |
classListView list = classes ifFalse:[
|
|
2037 |
scroll ifTrue:[
|
|
2038 |
classListView contents:classes
|
|
2039 |
] ifFalse:[
|
|
2040 |
classListView setContents:classes
|
|
2041 |
].
|
|
2042 |
oldClassName notNil ifTrue:[
|
|
2043 |
classListView setContents:classes.
|
|
2044 |
classListView selectElement:oldClassName
|
|
2045 |
] ifFalse:[
|
|
2046 |
variableListView notNil ifTrue:[variableListView contents:nil]
|
|
2047 |
]
|
|
2048 |
].
|
|
2049 |
scroll ifTrue:[
|
|
2050 |
fullProtocol ifTrue:[
|
|
2051 |
classListView scrollToBottom
|
|
2052 |
]
|
|
2053 |
]
|
|
2054 |
]
|
|
2055 |
!
|
|
2056 |
|
|
2057 |
doClassMenu:aBlock
|
|
2058 |
"a helper - check if class is selected and evaluate aBlock
|
|
2059 |
while showing waitCursor"
|
|
2060 |
|
|
2061 |
self checkClassSelected ifTrue:[
|
|
2062 |
self withWaitCursorDo:[aBlock value:currentClass]
|
|
2063 |
]
|
|
2064 |
!
|
|
2065 |
|
|
2066 |
checkClassSelected
|
|
2067 |
"warn and return false, if no class is selected"
|
|
2068 |
|
|
2069 |
currentClass isNil ifTrue:[
|
|
2070 |
self warn:'select a class first'.
|
|
2071 |
^ false
|
|
2072 |
].
|
|
2073 |
^ true
|
|
2074 |
!
|
|
2075 |
|
|
2076 |
listOfAllClassesInCategory:aCategory
|
|
2077 |
"return a list of all classes in a given category"
|
|
2078 |
|
79
|
2079 |
|newList classes searchCategory nm|
|
|
2080 |
|
|
2081 |
(aCategory = '* hierarchy *') ifTrue:[
|
|
2082 |
newList := OrderedCollection new.
|
|
2083 |
classes := Set new.
|
|
2084 |
self classHierarchyDo:[:aClass :lvl|
|
|
2085 |
nm := aClass name.
|
|
2086 |
(classes includes:nm) ifFalse:[
|
|
2087 |
classes add:nm.
|
|
2088 |
newList add:(String new:lvl) , nm
|
|
2089 |
]
|
|
2090 |
].
|
|
2091 |
^ newList
|
|
2092 |
].
|
|
2093 |
|
|
2094 |
newList := Set new.
|
|
2095 |
|
74
|
2096 |
(aCategory = '* all *') ifTrue:[
|
|
2097 |
Smalltalk allBehaviorsDo:[:aClass |
|
79
|
2098 |
newList add:aClass name
|
74
|
2099 |
]
|
|
2100 |
] ifFalse:[
|
79
|
2101 |
(aCategory = '* no category *') ifTrue:[
|
|
2102 |
searchCategory := nil
|
74
|
2103 |
] ifFalse:[
|
79
|
2104 |
searchCategory := aCategory
|
|
2105 |
].
|
|
2106 |
Smalltalk allBehaviorsDo:[:aClass |
|
105
|
2107 |
|thisCategory|
|
|
2108 |
|
79
|
2109 |
aClass isMeta ifFalse:[
|
105
|
2110 |
thisCategory := aClass category.
|
|
2111 |
((thisCategory = searchCategory)
|
|
2112 |
or:[thisCategory = aCategory]) ifTrue:[
|
79
|
2113 |
newList add:aClass name
|
74
|
2114 |
]
|
|
2115 |
]
|
|
2116 |
]
|
|
2117 |
].
|
|
2118 |
(newList size == 0) ifTrue:[^ nil].
|
79
|
2119 |
^ newList asOrderedCollection sort
|
74
|
2120 |
!
|
|
2121 |
|
|
2122 |
classSelection:lineNr
|
|
2123 |
"user clicked on a class line - show method categories"
|
|
2124 |
|
|
2125 |
|classSymbol cls oldSelector|
|
|
2126 |
|
|
2127 |
(currentClassHierarchy notNil
|
|
2128 |
and:[fullProtocol]) ifTrue:[
|
|
2129 |
oldSelector := currentSelector.
|
|
2130 |
|
|
2131 |
self updateMethodCategoryListWithScroll:false.
|
|
2132 |
self updateMethodListWithScroll:false.
|
|
2133 |
self updateVariableList.
|
|
2134 |
^ self
|
|
2135 |
].
|
|
2136 |
|
|
2137 |
cls := Smalltalk classNamed:classListView selectionValue withoutSpaces.
|
|
2138 |
"
|
|
2139 |
classSymbol := classListView selectionValue withoutSpaces asSymbol.
|
|
2140 |
(Smalltalk includesKey:classSymbol) ifTrue:[
|
|
2141 |
cls := Smalltalk at:classSymbol
|
|
2142 |
].
|
|
2143 |
"
|
|
2144 |
cls notNil ifTrue:[
|
|
2145 |
self switchToClass:cls.
|
|
2146 |
self classSelectionChanged
|
|
2147 |
]
|
|
2148 |
!
|
|
2149 |
|
|
2150 |
updateClassList
|
|
2151 |
self updateClassListWithScroll:true
|
|
2152 |
!
|
|
2153 |
|
|
2154 |
templateFor:className in:cat
|
|
2155 |
"return a class definition template - be smart in what is offered initially"
|
|
2156 |
|
|
2157 |
|aString name i|
|
|
2158 |
|
|
2159 |
name := 'NewClass'.
|
|
2160 |
i := 1.
|
|
2161 |
[name knownAsSymbol and:[Smalltalk includesKey:name asSymbol]] whileTrue:[
|
|
2162 |
i := i + 1.
|
|
2163 |
name := 'NewClass' , i printString
|
|
2164 |
].
|
|
2165 |
|
|
2166 |
aString := className , ' subclass:#' , name , '
|
|
2167 |
instanceVariableNames: ''''
|
|
2168 |
classVariableNames: ''''
|
|
2169 |
poolDictionaries: ''''
|
|
2170 |
category: '''.
|
|
2171 |
|
|
2172 |
cat notNil ifTrue:[
|
|
2173 |
aString := aString , cat
|
|
2174 |
].
|
|
2175 |
aString := aString , '''
|
|
2176 |
|
|
2177 |
|
|
2178 |
|
|
2179 |
|
|
2180 |
|
|
2181 |
"
|
|
2182 |
Replace ''' , className , ''', ''', name , ''' and
|
|
2183 |
the empty string arguments by true values.
|
|
2184 |
|
|
2185 |
Install (or change) the class by ''accepting'',
|
|
2186 |
either via the menu or the keyboard (usually CMD-A).
|
|
2187 |
|
|
2188 |
To be nice to others (and yourself later), do not forget to
|
|
2189 |
add some documentation; either under the classes documentation
|
|
2190 |
protocol, or as a class comment.
|
|
2191 |
"
|
|
2192 |
'.
|
|
2193 |
^ aString
|
|
2194 |
!
|
|
2195 |
|
|
2196 |
listOfClassHierarchyOf:aClass
|
|
2197 |
"return a hierarchy class-list"
|
|
2198 |
|
|
2199 |
|startClass classes thisOne|
|
|
2200 |
|
|
2201 |
showInstance ifTrue:[
|
|
2202 |
startClass := aClass
|
|
2203 |
] ifFalse:[
|
|
2204 |
startClass := aClass class.
|
|
2205 |
].
|
|
2206 |
classes := startClass allSuperclasses.
|
|
2207 |
thisOne := Array with:startClass.
|
|
2208 |
|
|
2209 |
classes notNil ifTrue:[
|
|
2210 |
classes := classes reverse , thisOne.
|
|
2211 |
] ifFalse:[
|
|
2212 |
classes := thisOne
|
|
2213 |
].
|
|
2214 |
|
|
2215 |
fullProtocol ifFalse:[
|
|
2216 |
classes := classes , startClass allSubclassesInOrder
|
|
2217 |
].
|
|
2218 |
^ classes collect:[:c | c name]
|
|
2219 |
!
|
|
2220 |
|
|
2221 |
switchToClassNamed:aString
|
93
|
2222 |
|classSymbol theClass newCat element|
|
74
|
2223 |
|
|
2224 |
classSymbol := aString asSymbolIfInterned.
|
|
2225 |
classSymbol isNil ifTrue:[^ self].
|
|
2226 |
|
|
2227 |
theClass := Smalltalk at:classSymbol.
|
|
2228 |
theClass isBehavior ifTrue:[
|
|
2229 |
classCategoryListView notNil ifTrue:[
|
|
2230 |
currentClassHierarchy isNil ifTrue:[
|
|
2231 |
((newCat := theClass category) ~= currentClassCategory) ifTrue:[
|
|
2232 |
currentClassCategory := newCat.
|
|
2233 |
newCat isNil ifTrue:[
|
93
|
2234 |
element := '* no category *'
|
74
|
2235 |
] ifFalse:[
|
93
|
2236 |
element := newCat.
|
74
|
2237 |
].
|
93
|
2238 |
classCategoryListView selectElement:element.
|
74
|
2239 |
"/ classCategoryListView makeSelectionVisible.
|
|
2240 |
]
|
|
2241 |
]
|
|
2242 |
].
|
|
2243 |
self updateClassList.
|
|
2244 |
self switchToClass:theClass.
|
|
2245 |
classListView selectElement:aString.
|
|
2246 |
self classSelectionChanged
|
|
2247 |
]
|
|
2248 |
!
|
|
2249 |
|
|
2250 |
classClassDefinitionTemplateFor:name in:cat
|
|
2251 |
"common helper for newClass and newSubclass
|
|
2252 |
- show a template to define class name in category cat.
|
|
2253 |
Also, set acceptaction to install the class."
|
|
2254 |
|
|
2255 |
currentMethodCategory := nil.
|
|
2256 |
currentMethod := currentSelector := nil.
|
|
2257 |
|
|
2258 |
classListView deselect.
|
|
2259 |
|
|
2260 |
fullClass ifFalse:[
|
|
2261 |
methodCategoryListView contents:nil.
|
|
2262 |
methodListView contents:nil
|
|
2263 |
].
|
|
2264 |
|
|
2265 |
codeView contents:(self templateFor:name in:cat).
|
|
2266 |
codeView modified:false.
|
|
2267 |
|
|
2268 |
codeView acceptAction:[:theCode |
|
|
2269 |
codeView cursor:Cursor execute.
|
|
2270 |
Object abortSignal catch:[
|
|
2271 |
|cls|
|
|
2272 |
|
|
2273 |
cls := (Compiler evaluate:theCode asString notifying:codeView compile:false).
|
|
2274 |
cls isBehavior ifTrue:[
|
|
2275 |
codeView modified:false.
|
|
2276 |
self classCategoryUpdate.
|
|
2277 |
self updateClassListWithScroll:false.
|
|
2278 |
self switchToClassNamed:(cls name).
|
|
2279 |
]
|
|
2280 |
].
|
|
2281 |
codeView cursor:(Cursor normal).
|
|
2282 |
].
|
|
2283 |
codeView explainAction:nil.
|
|
2284 |
self switchToClass:nil
|
|
2285 |
!
|
|
2286 |
|
|
2287 |
renameCurrentClassTo:aString
|
|
2288 |
"helper - do the rename"
|
|
2289 |
|
|
2290 |
self doClassMenu:[:currentClass |
|
|
2291 |
|oldName oldSym newSym|
|
|
2292 |
|
|
2293 |
oldName := currentClass name.
|
|
2294 |
oldSym := oldName asSymbol.
|
|
2295 |
"
|
|
2296 |
currentClass setName:aString.
|
|
2297 |
newSym := aString asSymbol.
|
|
2298 |
Smalltalk at:oldSym put:nil.
|
|
2299 |
Smalltalk removeKey:oldSym.
|
|
2300 |
Smalltalk at:newSym put:currentClass.
|
|
2301 |
"
|
|
2302 |
"
|
|
2303 |
currentClass renameTo:aString.
|
|
2304 |
"
|
|
2305 |
Smalltalk renameClass:currentClass to:aString.
|
|
2306 |
|
|
2307 |
self updateClassList.
|
|
2308 |
self updateMethodCategoryListWithScroll:false.
|
|
2309 |
self updateMethodListWithScroll:false.
|
|
2310 |
self withWaitCursorDo:[
|
|
2311 |
Transcript showCr:('searching for users of ' , oldSym); endEntry.
|
|
2312 |
SystemBrowser browseReferendsOf:oldSym warnIfNone:false
|
|
2313 |
]
|
|
2314 |
]
|
|
2315 |
!
|
|
2316 |
|
|
2317 |
switchToClassNameMatching:aMatchString
|
|
2318 |
|classNames thisName box|
|
|
2319 |
|
|
2320 |
classNames := OrderedCollection new.
|
|
2321 |
Smalltalk allBehaviorsDo:[:aClass |
|
|
2322 |
thisName := aClass name.
|
|
2323 |
(aMatchString match:thisName) ifTrue:[
|
|
2324 |
classNames add:thisName
|
|
2325 |
]
|
|
2326 |
].
|
|
2327 |
(classNames size == 0) ifTrue:[^ nil].
|
|
2328 |
(classNames size == 1) ifTrue:[
|
|
2329 |
^ self switchToClassNamed:(classNames at:1)
|
|
2330 |
].
|
|
2331 |
|
|
2332 |
box := self listBoxTitle:'select class to switch to:'
|
|
2333 |
okText:'ok'
|
|
2334 |
list:classNames sort.
|
|
2335 |
box action:[:aString | self switchToClassNamed:aString].
|
|
2336 |
box showAtPointer
|
|
2337 |
! !
|
|
2338 |
|
|
2339 |
!BrowserView methodsFor:'variable stuff'!
|
|
2340 |
|
|
2341 |
unhilightMethods
|
|
2342 |
"unhighlight items in method list"
|
|
2343 |
|
|
2344 |
variableListView isNil ifTrue:[^ self].
|
|
2345 |
|
|
2346 |
methodListView notNil ifTrue:[
|
|
2347 |
1 to:methodListView list size do:[:entry |
|
|
2348 |
methodListView attributeAt:entry put:nil.
|
|
2349 |
].
|
|
2350 |
].
|
|
2351 |
|
|
2352 |
|
|
2353 |
!
|
|
2354 |
|
|
2355 |
hilightMethodsInMethodCategoryList:inCat inMethodList:inMethods
|
|
2356 |
"search for methods which access the selected
|
|
2357 |
variable, and highlight them"
|
|
2358 |
|
|
2359 |
|name redefinedSelectors|
|
|
2360 |
|
|
2361 |
variableListView isNil ifTrue:[^ self].
|
|
2362 |
|
|
2363 |
inCat ifTrue:[self unhilightMethodCategories].
|
|
2364 |
inMethods ifTrue:[self unhilightMethods].
|
|
2365 |
|
|
2366 |
actualClass isNil ifTrue:[^ self].
|
|
2367 |
(methodCategoryListView isNil
|
|
2368 |
and:[methodListView isNil]) ifTrue:[^ self].
|
|
2369 |
|
|
2370 |
name := variableListView selectionValue.
|
|
2371 |
name isNil ifTrue:[^ self].
|
|
2372 |
|
|
2373 |
self withCursor:(Cursor questionMark) do:[
|
|
2374 |
|classes filter any|
|
|
2375 |
|
|
2376 |
classes := Array with:actualClass.
|
|
2377 |
currentClassHierarchy notNil ifTrue:[
|
|
2378 |
classes := classes , actualClass allSuperclasses.
|
|
2379 |
redefinedSelectors := IdentitySet new.
|
|
2380 |
].
|
|
2381 |
|
93
|
2382 |
filter := SystemBrowser filterToSearchRefsTo:name classVars:showInstance not modificationsOnly:false.
|
74
|
2383 |
|
|
2384 |
any := false.
|
|
2385 |
"
|
|
2386 |
highlight the method that ref this variable
|
|
2387 |
"
|
|
2388 |
classes do:[:someClass |
|
|
2389 |
(fullProtocol
|
|
2390 |
and:[classListView valueIsInSelection:(someClass name)]) ifFalse:[
|
|
2391 |
someClass methodArray with:someClass selectorArray
|
|
2392 |
do:[:method :selector |
|
|
2393 |
|
|
2394 |
(inCat
|
|
2395 |
or:[methodListView list notNil
|
|
2396 |
and:[methodListView list includes:selector]])
|
|
2397 |
ifTrue:[
|
|
2398 |
(redefinedSelectors isNil
|
|
2399 |
or:[(redefinedSelectors includes:selector) not])
|
|
2400 |
ifTrue:[
|
|
2401 |
(filter value:someClass value:method value:selector) ifTrue:[
|
|
2402 |
|idx cat|
|
|
2403 |
|
|
2404 |
(inCat
|
|
2405 |
and:[methodCategoryListView notNil
|
|
2406 |
and:[methodCategoryListView list notNil]]) ifTrue:[
|
|
2407 |
cat := method category.
|
|
2408 |
"
|
|
2409 |
highlight the methodCategory
|
|
2410 |
"
|
|
2411 |
idx := methodCategoryListView list indexOf:cat.
|
|
2412 |
idx ~~ 0 ifTrue:[
|
|
2413 |
methodCategoryListView attributeAt:idx put:#bold.
|
|
2414 |
].
|
|
2415 |
].
|
|
2416 |
|
|
2417 |
(inMethods
|
|
2418 |
and:[methodListView notNil
|
|
2419 |
and:[methodListView list notNil]]) ifTrue:[
|
|
2420 |
"
|
|
2421 |
highlight the method
|
|
2422 |
"
|
|
2423 |
idx := methodListView list indexOf:selector.
|
|
2424 |
idx ~~ 0 ifTrue:[
|
|
2425 |
methodListView attributeAt:idx put:#bold.
|
|
2426 |
].
|
|
2427 |
any := true
|
|
2428 |
].
|
|
2429 |
].
|
|
2430 |
redefinedSelectors notNil ifTrue:[
|
|
2431 |
redefinedSelectors add:selector
|
|
2432 |
]
|
|
2433 |
]
|
|
2434 |
]
|
|
2435 |
]
|
|
2436 |
]
|
|
2437 |
].
|
|
2438 |
any ifTrue:[
|
|
2439 |
self setSearchPattern:name
|
|
2440 |
]
|
|
2441 |
]
|
|
2442 |
!
|
|
2443 |
|
|
2444 |
updateVariableList
|
|
2445 |
|l subList last nameAccessSelector class oldSelection|
|
|
2446 |
|
|
2447 |
variableListView isNil ifTrue:[^ self].
|
|
2448 |
|
|
2449 |
oldSelection := variableListView selectionValue.
|
|
2450 |
|
|
2451 |
l := OrderedCollection new.
|
|
2452 |
"
|
|
2453 |
show classVars, if classProtocol is shown (instead of classInstance vars)
|
|
2454 |
"
|
|
2455 |
showInstance ifTrue:[
|
|
2456 |
nameAccessSelector := #instVarNames
|
|
2457 |
] ifFalse:[
|
|
2458 |
nameAccessSelector := #classVarNames
|
|
2459 |
].
|
|
2460 |
|
|
2461 |
"/ class := currentClass notNil ifTrue:[currentClass] ifFalse:[actualClass].
|
|
2462 |
"/ class isNil ifTrue:[class := currentClassHierarchy].
|
|
2463 |
class := currentClassHierarchy notNil ifTrue:[currentClassHierarchy] ifFalse:[currentClass].
|
|
2464 |
class withAllSuperclasses do:[:aClass |
|
|
2465 |
|ignore|
|
|
2466 |
|
|
2467 |
ignore := fullProtocol
|
|
2468 |
and:[classListView valueIsInSelection:(aClass name asString)].
|
|
2469 |
ignore ifFalse:[
|
|
2470 |
subList := aClass perform:nameAccessSelector.
|
|
2471 |
subList size ~~ 0 ifTrue:[
|
|
2472 |
l := l , (subList asOrderedCollection reverse).
|
|
2473 |
l := l , (OrderedCollection with:'---- ' , aClass name , ' ---------').
|
|
2474 |
]
|
|
2475 |
]
|
|
2476 |
].
|
|
2477 |
l reverse.
|
|
2478 |
variableListView setAttributes:nil.
|
|
2479 |
variableListView list:l.
|
|
2480 |
l keysAndValuesDo:[:index :entry |
|
|
2481 |
(entry startsWith:'---') ifTrue:[
|
|
2482 |
variableListView attributeAt:index put:#disabled.
|
|
2483 |
last := index
|
|
2484 |
]
|
|
2485 |
].
|
|
2486 |
last notNil ifTrue:[variableListView scrollToLine:last].
|
|
2487 |
|
|
2488 |
oldSelection notNil ifTrue:[
|
|
2489 |
variableListView selectElement:oldSelection.
|
|
2490 |
self hilightMethodsInMethodCategoryList:true inMethodList:true.
|
|
2491 |
]
|
|
2492 |
!
|
|
2493 |
|
|
2494 |
unhilightMethodCategories
|
|
2495 |
"unhighlight items in method list"
|
|
2496 |
|
|
2497 |
variableListView isNil ifTrue:[^ self].
|
|
2498 |
|
|
2499 |
methodCategoryListView notNil ifTrue:[
|
|
2500 |
1 to:methodCategoryListView list size do:[:entry |
|
|
2501 |
methodCategoryListView attributeAt:entry put:nil.
|
|
2502 |
]
|
|
2503 |
].
|
|
2504 |
|
|
2505 |
|
|
2506 |
!
|
|
2507 |
|
|
2508 |
hilightMethodsInMethodCategoryList
|
|
2509 |
"search for methods which access the selected
|
|
2510 |
variable, and highlight them"
|
|
2511 |
|
|
2512 |
self hilightMethodsInMethodCategoryList:true inMethodList:false
|
|
2513 |
|
|
2514 |
|
|
2515 |
|
|
2516 |
!
|
|
2517 |
|
|
2518 |
hilightMethodsInMethodList
|
|
2519 |
"search for methods which access the selected
|
|
2520 |
variable, and highlight them"
|
|
2521 |
|
|
2522 |
self hilightMethodsInMethodCategoryList:false inMethodList:true
|
|
2523 |
|
|
2524 |
|
|
2525 |
|
|
2526 |
! !
|
|
2527 |
|
|
2528 |
!BrowserView methodsFor:'class list menu'!
|
|
2529 |
|
|
2530 |
classDefinition
|
|
2531 |
"show class definition in codeView and setup accept-action for
|
|
2532 |
a class-definition change.
|
|
2533 |
Extract documentation either from a documentation method or
|
|
2534 |
from the comment - not a biggy, but beginners will like
|
|
2535 |
it when exploring the system."
|
|
2536 |
|
|
2537 |
self doClassMenu:[:currentClass |
|
|
2538 |
|m s aStream isComment|
|
|
2539 |
|
|
2540 |
aStream := WriteStream on:(String new:200).
|
|
2541 |
currentClass fileOutDefinitionOn:aStream.
|
|
2542 |
|
|
2543 |
currentClass isLoaded ifTrue:[
|
|
2544 |
"
|
|
2545 |
add documentation as a comment, if there is any
|
|
2546 |
"
|
|
2547 |
m := currentClass class compiledMethodAt:#documentation.
|
|
2548 |
m notNil ifTrue:[
|
|
2549 |
s := m comment.
|
|
2550 |
isComment := false.
|
|
2551 |
] ifFalse:[
|
|
2552 |
"try comment"
|
|
2553 |
s := currentClass comment.
|
|
2554 |
s notNil ifTrue:[
|
93
|
2555 |
s isEmpty ifTrue:[
|
|
2556 |
s := nil
|
|
2557 |
] ifFalse:[
|
|
2558 |
isComment := true
|
|
2559 |
]
|
74
|
2560 |
]
|
|
2561 |
].
|
|
2562 |
].
|
93
|
2563 |
aStream cr.
|
|
2564 |
aStream cr.
|
|
2565 |
aStream cr.
|
|
2566 |
aStream cr.
|
|
2567 |
aStream cr.
|
|
2568 |
s isNil ifTrue:[
|
|
2569 |
aStream nextPut:$" ; cr; nextPutAll:' no comment or documentation found'; cr.
|
|
2570 |
] ifFalse:[
|
74
|
2571 |
aStream nextPut:$" ; cr; nextPutAll:' Documentation:'; cr.
|
|
2572 |
aStream cr.
|
|
2573 |
aStream nextPutAll:s.
|
|
2574 |
aStream cr; cr.
|
|
2575 |
aStream nextPutAll:' Notice: '; cr.
|
|
2576 |
aStream nextPutAll:' the above string has been extracted from the classes '.
|
|
2577 |
aStream nextPutAll:(isComment ifTrue:['comment.'] ifFalse:['documentation method.']).
|
|
2578 |
aStream cr.
|
|
2579 |
aStream nextPutAll:' It will not be preserved when accepting a new class definition.'; cr.
|
|
2580 |
].
|
93
|
2581 |
aStream nextPut:$".
|
74
|
2582 |
|
|
2583 |
codeView contents:(aStream contents).
|
|
2584 |
codeView modified:false.
|
|
2585 |
codeView acceptAction:[:theCode |
|
|
2586 |
codeView cursor:Cursor execute.
|
|
2587 |
Object abortSignal catch:[
|
|
2588 |
(Compiler evaluate:theCode asString notifying:codeView compile:false)
|
|
2589 |
isBehavior ifTrue:[
|
|
2590 |
codeView modified:false.
|
|
2591 |
self classCategoryUpdate.
|
|
2592 |
self updateClassListWithScroll:false.
|
|
2593 |
]
|
|
2594 |
].
|
|
2595 |
codeView cursor:Cursor normal.
|
|
2596 |
].
|
|
2597 |
codeView explainAction:nil.
|
|
2598 |
|
|
2599 |
methodListView notNil ifTrue:[
|
|
2600 |
methodListView deselect
|
|
2601 |
].
|
|
2602 |
aspect := #definition.
|
|
2603 |
self normalLabel
|
|
2604 |
]
|
|
2605 |
!
|
|
2606 |
|
|
2607 |
classMenu
|
|
2608 |
"sent by classListView to ask for the menu"
|
|
2609 |
|
|
2610 |
|labels selectors|
|
|
2611 |
|
105
|
2612 |
(device ctrlDown
|
|
2613 |
and:[currentClass notNil]) ifTrue:[
|
107
|
2614 |
labels := #(
|
|
2615 |
'inspect class'
|
|
2616 |
'-'
|
|
2617 |
'primitive definitions'
|
|
2618 |
'primitive variables'
|
|
2619 |
'primitive functions'
|
|
2620 |
).
|
|
2621 |
selectors := #(
|
|
2622 |
classInspect
|
|
2623 |
nil
|
|
2624 |
classPrimitiveDefinitions
|
|
2625 |
classPrimitiveVariables
|
|
2626 |
classPrimitiveFunctions
|
|
2627 |
).
|
74
|
2628 |
] ifFalse:[
|
105
|
2629 |
currentClass isNil ifTrue:[
|
74
|
2630 |
labels := #(
|
|
2631 |
'new class'
|
|
2632 |
).
|
|
2633 |
selectors := #(
|
|
2634 |
classNewClass
|
|
2635 |
).
|
105
|
2636 |
] ifFalse:[
|
|
2637 |
currentClass isLoaded ifFalse:[
|
74
|
2638 |
labels := #(
|
105
|
2639 |
'new class'
|
|
2640 |
'-'
|
|
2641 |
'load '
|
74
|
2642 |
).
|
|
2643 |
selectors := #(
|
105
|
2644 |
classNewClass
|
74
|
2645 |
nil
|
105
|
2646 |
classLoad
|
|
2647 |
).
|
|
2648 |
] ifTrue:[
|
|
2649 |
fullProtocol ifTrue:[
|
|
2650 |
labels := #(
|
|
2651 |
'hierarchy'
|
|
2652 |
'definition'
|
|
2653 |
'comment'
|
|
2654 |
'class instvars'
|
|
2655 |
).
|
|
2656 |
selectors := #(
|
|
2657 |
classHierarchy
|
|
2658 |
classDefinition
|
|
2659 |
classComment
|
|
2660 |
classClassInstVars
|
|
2661 |
).
|
|
2662 |
] ifFalse:[
|
|
2663 |
labels := #(
|
|
2664 |
'fileOut'
|
|
2665 |
'printOut'
|
|
2666 |
'printOut protocol'
|
|
2667 |
" 'printOut full protocol' "
|
|
2668 |
'-'
|
|
2669 |
'SPAWN_CLASS'
|
|
2670 |
'spawn full protocol'
|
|
2671 |
'spawn hierarchy'
|
|
2672 |
'spawn subclasses'
|
|
2673 |
'-'
|
|
2674 |
).
|
|
2675 |
selectors := #(
|
|
2676 |
classFileOut
|
|
2677 |
classPrintOut
|
|
2678 |
classPrintOutProtocol
|
|
2679 |
" classPrintOutFullProtocol "
|
|
2680 |
nil
|
|
2681 |
classSpawn
|
|
2682 |
classSpawnFullProtocol
|
|
2683 |
classSpawnHierarchy
|
|
2684 |
classSpawnSubclasses
|
|
2685 |
nil
|
|
2686 |
).
|
|
2687 |
|
|
2688 |
fullClass ifFalse:[
|
|
2689 |
labels := labels , #(
|
|
2690 |
'hierarchy'
|
|
2691 |
'definition'
|
|
2692 |
'comment'
|
|
2693 |
'class instvars'
|
|
2694 |
"/ 'protocols'
|
|
2695 |
'-'
|
|
2696 |
).
|
|
2697 |
selectors := selectors , #(
|
|
2698 |
classHierarchy
|
|
2699 |
classDefinition
|
|
2700 |
classComment
|
|
2701 |
classClassInstVars
|
|
2702 |
"/ classProtocols
|
|
2703 |
nil
|
|
2704 |
).
|
|
2705 |
].
|
|
2706 |
|
|
2707 |
"
|
|
2708 |
dont offer this menu for now - you cannot recompile
|
|
2709 |
the stuff anyway. So there is only confusion in showing
|
|
2710 |
those ...
|
|
2711 |
"
|
|
2712 |
false "currentClass primitiveSpec notNil" ifTrue:[
|
|
2713 |
labels := labels , #(
|
|
2714 |
'primitive definitions'
|
|
2715 |
'primitive variables'
|
|
2716 |
'primitive functions'
|
|
2717 |
'-'
|
|
2718 |
).
|
|
2719 |
selectors := selectors , #(
|
|
2720 |
classPrimitiveDefinitions
|
|
2721 |
classPrimitiveVariables
|
|
2722 |
classPrimitiveFunctions
|
|
2723 |
nil
|
|
2724 |
).
|
|
2725 |
].
|
|
2726 |
|
74
|
2727 |
labels := labels , #(
|
105
|
2728 |
"/ 'variable search'
|
|
2729 |
'class refs'
|
|
2730 |
'-'
|
|
2731 |
'new class'
|
|
2732 |
'new subclass'
|
|
2733 |
'rename ...'
|
|
2734 |
'remove'
|
|
2735 |
).
|
74
|
2736 |
selectors := selectors , #(
|
105
|
2737 |
"/ variables
|
|
2738 |
classRefs
|
|
2739 |
nil
|
|
2740 |
classNewClass
|
|
2741 |
classNewSubclass
|
|
2742 |
classRename
|
|
2743 |
classRemove
|
|
2744 |
).
|
|
2745 |
currentClass wasAutoloaded ifTrue:[
|
|
2746 |
labels := labels , #(
|
|
2747 |
'unload'
|
|
2748 |
).
|
|
2749 |
selectors := selectors , #(
|
|
2750 |
classUnload
|
|
2751 |
).
|
|
2752 |
]
|
74
|
2753 |
]
|
105
|
2754 |
].
|
74
|
2755 |
].
|
|
2756 |
].
|
|
2757 |
|
|
2758 |
|
|
2759 |
^ PopUpMenu labels:(resources array:labels)
|
|
2760 |
selectors:selectors
|
|
2761 |
!
|
|
2762 |
|
|
2763 |
classFileOut
|
|
2764 |
"fileOut the current class.
|
|
2765 |
Catch errors (sure, you like to know if it failed) and
|
|
2766 |
warn if any)"
|
|
2767 |
|
|
2768 |
self doClassMenu:[:currentClass |
|
105
|
2769 |
|msg|
|
|
2770 |
|
74
|
2771 |
self busyLabel:'saving %1' with:currentClass name.
|
|
2772 |
Class fileOutErrorSignal handle:[:ex |
|
105
|
2773 |
self warn:'cannot create: %1\(%2)' with:ex parameter with:ex errorString.
|
|
2774 |
|
74
|
2775 |
ex return.
|
|
2776 |
] do:[
|
|
2777 |
currentClass fileOut.
|
|
2778 |
].
|
|
2779 |
self normalLabel.
|
|
2780 |
]
|
|
2781 |
!
|
|
2782 |
|
|
2783 |
doClassMenuWithSelection:aBlock
|
|
2784 |
"a helper - if there is a selection, which represents a classes name,
|
|
2785 |
evaluate aBlock, passing that class and optional selector as arguments.
|
|
2786 |
Otherwise, check if a class is selected and evaluate aBlock with the
|
|
2787 |
current class."
|
|
2788 |
|
|
2789 |
|string words clsName cls sel isMeta|
|
|
2790 |
|
|
2791 |
string := codeView selection.
|
|
2792 |
string notNil ifTrue:[
|
|
2793 |
self extractClassAndSelectorFromSelectionInto:[:c :s :m |
|
|
2794 |
clsName := c.
|
|
2795 |
sel := s.
|
|
2796 |
isMeta := m.
|
|
2797 |
].
|
|
2798 |
clsName isNil ifTrue:[
|
|
2799 |
string := string asString withoutSeparators.
|
|
2800 |
words := string asCollectionOfWords.
|
|
2801 |
words notNil ifTrue:[
|
|
2802 |
clsName := words first.
|
|
2803 |
(clsName endsWith:'class') ifTrue:[
|
|
2804 |
isMeta := true.
|
106
|
2805 |
clsName := clsName copyWithoutLast:5 "copyTo:(clsName size - 5)"
|
74
|
2806 |
] ifFalse:[
|
|
2807 |
isMeta := false
|
|
2808 |
].
|
|
2809 |
sel := Parser selectorInExpression:string.
|
|
2810 |
]
|
|
2811 |
].
|
|
2812 |
clsName notNil ifTrue:[
|
|
2813 |
(cls := Smalltalk classNamed:clsName) notNil ifTrue:[
|
|
2814 |
isMeta ifTrue:[
|
|
2815 |
cls := cls class
|
|
2816 |
].
|
|
2817 |
self withWaitCursorDo:[
|
|
2818 |
aBlock value:cls value:sel.
|
|
2819 |
].
|
|
2820 |
^ self
|
|
2821 |
] ifFalse:[
|
|
2822 |
self warn:'no class named: %1 - spawning current' with:clsName
|
|
2823 |
]
|
|
2824 |
].
|
|
2825 |
].
|
|
2826 |
|
|
2827 |
classMethodListView notNil ifTrue:[
|
|
2828 |
sel := classMethodListView selectionValue.
|
|
2829 |
sel notNil ifTrue:[
|
|
2830 |
sel := self selectorFromClassMethodString:sel
|
|
2831 |
]
|
|
2832 |
].
|
|
2833 |
self doClassMenu:[:currentClass | aBlock value:currentClass value:sel]
|
|
2834 |
!
|
|
2835 |
|
|
2836 |
classSpawn
|
|
2837 |
"create a new SystemBrowser browsing current class,
|
|
2838 |
or if there is a selection, spawn a browser on the selected class
|
|
2839 |
even a class/selector pair can be specified."
|
|
2840 |
|
|
2841 |
self doClassMenuWithSelection:[:cls :sel |
|
|
2842 |
|browser|
|
|
2843 |
|
|
2844 |
cls isMeta ifTrue:[
|
|
2845 |
Smalltalk allBehaviorsDo:[:aClass |
|
|
2846 |
aClass class == cls ifTrue:[
|
|
2847 |
browser := SystemBrowser browseClass:aClass.
|
95
|
2848 |
browser instanceProtocol:false.
|
74
|
2849 |
sel notNil ifTrue:[
|
|
2850 |
browser switchToMethodNamed:sel
|
|
2851 |
].
|
|
2852 |
^ self
|
|
2853 |
].
|
|
2854 |
].
|
|
2855 |
self warn:'oops, no class for this metaclass'.
|
|
2856 |
^ self
|
|
2857 |
].
|
|
2858 |
browser := SystemBrowser browseClass:cls.
|
|
2859 |
cls hasMethods ifFalse:[
|
95
|
2860 |
browser instanceProtocol:false.
|
74
|
2861 |
].
|
|
2862 |
sel notNil ifTrue:[
|
|
2863 |
browser switchToMethodNamed:sel
|
|
2864 |
].
|
|
2865 |
]
|
|
2866 |
|
|
2867 |
"
|
|
2868 |
select 'Smalltalk allClassesDo:' and use spawn from the class menu
|
|
2869 |
select 'Smalltalk' and use spawn from the class menu
|
|
2870 |
"
|
|
2871 |
!
|
|
2872 |
|
|
2873 |
classSpawnHierarchy
|
|
2874 |
"create a new HierarchyBrowser browsing current class"
|
|
2875 |
|
|
2876 |
self doClassMenuWithSelection:[:cls :sel |
|
|
2877 |
SystemBrowser browseClassHierarchy:cls
|
|
2878 |
]
|
|
2879 |
!
|
|
2880 |
|
|
2881 |
classSpawnSubclasses
|
|
2882 |
"create a new browser browsing current class's subclasses"
|
|
2883 |
|
|
2884 |
self doClassMenuWithSelection:[:cls :sel |
|
|
2885 |
|subs|
|
|
2886 |
|
|
2887 |
subs := cls allSubclasses.
|
|
2888 |
(subs notNil and:[subs size ~~ 0]) ifTrue:[
|
|
2889 |
SystemBrowser browseClasses:subs title:('subclasses of ' , cls name)
|
|
2890 |
]
|
|
2891 |
]
|
|
2892 |
!
|
|
2893 |
|
93
|
2894 |
classPrintOutWith:aSelector
|
74
|
2895 |
self doClassMenu:[:currentClass |
|
|
2896 |
|printStream|
|
|
2897 |
|
|
2898 |
printStream := Printer new.
|
93
|
2899 |
currentClass perform:aSelector with:printStream.
|
74
|
2900 |
printStream close
|
|
2901 |
]
|
|
2902 |
!
|
|
2903 |
|
93
|
2904 |
classPrintOutFullProtocol
|
|
2905 |
self classPrintOutWith:#printOutFullProtocolOn:
|
|
2906 |
!
|
|
2907 |
|
74
|
2908 |
classPrintOutProtocol
|
93
|
2909 |
self classPrintOutWith:#printOutProtocolOn:
|
74
|
2910 |
!
|
|
2911 |
|
|
2912 |
classPrintOut
|
93
|
2913 |
self classPrintOutWith:#printOutOn:
|
74
|
2914 |
!
|
|
2915 |
|
|
2916 |
classHierarchy
|
|
2917 |
"show current classes hierarchy in codeView"
|
|
2918 |
|
|
2919 |
self doClassMenu:[:currentClass |
|
|
2920 |
|aStream|
|
|
2921 |
|
|
2922 |
aStream := WriteStream on:(String new:200).
|
|
2923 |
actualClass printHierarchyOn:aStream.
|
|
2924 |
codeView contents:(aStream contents).
|
|
2925 |
codeView modified:false.
|
|
2926 |
codeView acceptAction:nil.
|
|
2927 |
codeView explainAction:nil.
|
|
2928 |
methodListView notNil ifTrue:[
|
|
2929 |
methodListView deselect
|
|
2930 |
].
|
|
2931 |
aspect := #hierarchy.
|
|
2932 |
self normalLabel
|
|
2933 |
]
|
|
2934 |
!
|
|
2935 |
|
|
2936 |
classNewClass
|
|
2937 |
"create a class-definition prototype in codeview"
|
|
2938 |
|
105
|
2939 |
|nm cls cat|
|
|
2940 |
|
|
2941 |
nm := 'Object'.
|
74
|
2942 |
currentClass notNil ifTrue:[
|
105
|
2943 |
(cls := currentClass superclass) notNil ifTrue:[
|
|
2944 |
nm := cls name
|
|
2945 |
]
|
74
|
2946 |
].
|
|
2947 |
cat := currentClassCategory.
|
|
2948 |
cat isNil ifTrue:[
|
79
|
2949 |
cat := '* no category *'
|
74
|
2950 |
].
|
|
2951 |
self classClassDefinitionTemplateFor:nm in:cat.
|
|
2952 |
aspect := nil.
|
|
2953 |
!
|
|
2954 |
|
|
2955 |
classClassInstVars
|
|
2956 |
"show class instance variables in codeView and setup accept-action
|
|
2957 |
for a class-instvar-definition change"
|
|
2958 |
|
|
2959 |
self doClassMenu:[:currentClass |
|
|
2960 |
|s|
|
|
2961 |
|
|
2962 |
s := WriteStream on:(String new).
|
|
2963 |
currentClass fileOutClassInstVarDefinitionOn:s.
|
|
2964 |
codeView contents:(s contents).
|
|
2965 |
codeView modified:false.
|
|
2966 |
codeView acceptAction:[:theCode |
|
|
2967 |
codeView cursor:Cursor execute.
|
|
2968 |
Object abortSignal catch:[
|
|
2969 |
Compiler evaluate:theCode asString notifying:codeView compile:false.
|
|
2970 |
codeView modified:false.
|
|
2971 |
self updateClassList.
|
|
2972 |
].
|
|
2973 |
codeView cursor:Cursor normal.
|
|
2974 |
].
|
|
2975 |
codeView explainAction:nil.
|
|
2976 |
methodListView notNil ifTrue:[
|
|
2977 |
methodListView deselect
|
|
2978 |
].
|
|
2979 |
aspect := #classInstVars.
|
|
2980 |
self normalLabel
|
|
2981 |
]
|
|
2982 |
!
|
|
2983 |
|
|
2984 |
classSpawnFullProtocol
|
|
2985 |
"create a new browser, browsing current classes full protocol"
|
|
2986 |
|
|
2987 |
self doClassMenuWithSelection:[:cls :sel |
|
|
2988 |
SystemBrowser browseFullClassProtocol:cls
|
|
2989 |
]
|
|
2990 |
!
|
|
2991 |
|
|
2992 |
classLoad
|
|
2993 |
"load an autoloaded class"
|
|
2994 |
|
79
|
2995 |
|nm|
|
|
2996 |
|
74
|
2997 |
self checkClassSelected ifFalse:[^ self].
|
79
|
2998 |
nm := currentClass name.
|
|
2999 |
currentClass autoload.
|
|
3000 |
self switchToClassNamed:nm
|
74
|
3001 |
!
|
|
3002 |
|
|
3003 |
classUnload
|
79
|
3004 |
"unload an autoloaded class"
|
|
3005 |
|
|
3006 |
|nm|
|
74
|
3007 |
|
|
3008 |
self checkClassSelected ifFalse:[^ self].
|
79
|
3009 |
nm := currentClass name.
|
74
|
3010 |
currentClass unload.
|
79
|
3011 |
self switchToClassNamed:nm
|
74
|
3012 |
!
|
|
3013 |
|
105
|
3014 |
classInspect
|
|
3015 |
"inspect the current class"
|
|
3016 |
|
|
3017 |
self checkClassSelected ifFalse:[^ self].
|
|
3018 |
|
|
3019 |
currentClass inspect.
|
|
3020 |
!
|
|
3021 |
|
74
|
3022 |
classProtocols
|
|
3023 |
^ self
|
|
3024 |
!
|
|
3025 |
|
|
3026 |
classRemove
|
|
3027 |
"user requested remove of current class and all subclasses -
|
|
3028 |
count subclasses and let user confirm removal."
|
|
3029 |
|
|
3030 |
|count t box|
|
|
3031 |
|
|
3032 |
currentClass notNil ifTrue:[
|
|
3033 |
count := currentClass allSubclasses size.
|
|
3034 |
t := 'remove %1'.
|
|
3035 |
count ~~ 0 ifTrue:[
|
|
3036 |
t := t , '\(with %2 subclass'.
|
|
3037 |
count ~~ 1 ifTrue:[
|
|
3038 |
t := t , 'es'
|
|
3039 |
].
|
|
3040 |
t := (t , ')')
|
|
3041 |
].
|
|
3042 |
t := t , ' ?'.
|
|
3043 |
t := (resources string:t with:currentClass name with:count) withCRs.
|
|
3044 |
|
|
3045 |
box := YesNoBox
|
|
3046 |
title:t
|
|
3047 |
yesText:(resources at:'remove')
|
|
3048 |
noText:(resources at:'abort').
|
|
3049 |
box confirm ifTrue:[
|
|
3050 |
"after querying user - do really remove current class
|
|
3051 |
and all subclasses
|
|
3052 |
"
|
|
3053 |
self doClassMenu:[:currentClass |
|
|
3054 |
|didRemove|
|
|
3055 |
|
|
3056 |
didRemove := false.
|
|
3057 |
|
|
3058 |
"
|
|
3059 |
query ?
|
|
3060 |
"
|
|
3061 |
currentClass allSubclassesDo:[:aSubClass |
|
|
3062 |
(CheckForInstancesWhenRemovingClasses not
|
|
3063 |
or:[aSubClass hasInstances not
|
|
3064 |
or:[self confirm:(aSubClass name , ' has instances - remove anyway ?')]])
|
|
3065 |
ifTrue:[
|
|
3066 |
Smalltalk removeClass:aSubClass
|
|
3067 |
]
|
|
3068 |
].
|
|
3069 |
(CheckForInstancesWhenRemovingClasses not
|
|
3070 |
or:[currentClass hasInstances not
|
|
3071 |
or:[self confirm:(currentClass name , ' has instances - remove anyway ?')]])
|
|
3072 |
ifTrue:[
|
|
3073 |
didRemove := true.
|
|
3074 |
Smalltalk removeClass:currentClass.
|
|
3075 |
].
|
|
3076 |
|
|
3077 |
self switchToClass:nil.
|
|
3078 |
Smalltalk changed.
|
|
3079 |
self updateClassList.
|
|
3080 |
|
|
3081 |
"if it was the last in its category, update class category list"
|
|
3082 |
"
|
|
3083 |
classListView numberOfLines == 0 ifTrue:[
|
|
3084 |
self updateClassCategoryListWithScroll:false
|
|
3085 |
].
|
|
3086 |
"
|
|
3087 |
didRemove ifTrue:[
|
|
3088 |
methodCategoryListView notNil ifTrue:[methodCategoryListView contents:nil].
|
|
3089 |
methodListView notNil ifTrue:[methodListView contents:nil].
|
|
3090 |
codeView contents:nil.
|
|
3091 |
codeView modified:false
|
|
3092 |
]
|
|
3093 |
]
|
|
3094 |
]
|
|
3095 |
]
|
|
3096 |
!
|
|
3097 |
|
107
|
3098 |
classShowFrom:getSelector set:setSelector aspect:aspectSymbol default:default
|
74
|
3099 |
"common helper for comment, primitive-stuff etc.
|
|
3100 |
show the string returned from the classes getSelector-method,
|
|
3101 |
Set acceptaction to change it via setSelector."
|
|
3102 |
|
|
3103 |
self doClassMenu:[:currentClass |
|
107
|
3104 |
|text|
|
|
3105 |
|
|
3106 |
text := currentClass perform:getSelector.
|
|
3107 |
text isNil ifTrue:[
|
|
3108 |
text := default
|
|
3109 |
].
|
|
3110 |
codeView contents:text.
|
74
|
3111 |
codeView modified:false.
|
|
3112 |
codeView acceptAction:[:theCode |
|
|
3113 |
Object abortSignal catch:[
|
|
3114 |
lockUpdates := true.
|
|
3115 |
currentClass perform:setSelector with:theCode asString.
|
|
3116 |
codeView modified:false.
|
|
3117 |
].
|
|
3118 |
lockUpdates := false.
|
|
3119 |
].
|
|
3120 |
codeView explainAction:nil.
|
|
3121 |
|
|
3122 |
methodListView notNil ifTrue:[
|
|
3123 |
methodListView deselect
|
|
3124 |
].
|
|
3125 |
aspect := aspectSymbol.
|
|
3126 |
self normalLabel
|
|
3127 |
]
|
|
3128 |
!
|
|
3129 |
|
|
3130 |
classComment
|
|
3131 |
"show the classes comment in the codeView.
|
93
|
3132 |
Also, set accept action to change the comment."
|
74
|
3133 |
|
107
|
3134 |
self classShowFrom:#comment
|
|
3135 |
set:#comment:
|
|
3136 |
aspect:#comment
|
|
3137 |
default:nil
|
74
|
3138 |
!
|
|
3139 |
|
|
3140 |
classPrimitiveDefinitions
|
|
3141 |
"show the classes primitiveDefinition in the codeView.
|
93
|
3142 |
Also, set accept action to change it."
|
74
|
3143 |
|
107
|
3144 |
self classShowFrom:#primitiveDefinitionsString
|
|
3145 |
set:#primitiveDefinitions:
|
|
3146 |
aspect:#primitiveDefinitions
|
|
3147 |
default:'%{
|
|
3148 |
|
|
3149 |
/*
|
|
3150 |
* includes, defines, structure definitions
|
|
3151 |
* and typedefs come here.
|
|
3152 |
*/
|
|
3153 |
|
|
3154 |
%}'
|
74
|
3155 |
!
|
|
3156 |
|
|
3157 |
classPrimitiveVariables
|
|
3158 |
"show the classes primitiveVariables in the codeView.
|
93
|
3159 |
Also, set accept action to change it."
|
74
|
3160 |
|
107
|
3161 |
self classShowFrom:#primitiveVariablesString
|
|
3162 |
set:#primitiveVariables:
|
|
3163 |
aspect:#primitiveVariables
|
|
3164 |
default:'%{
|
|
3165 |
|
|
3166 |
/*
|
|
3167 |
* any local C variables
|
|
3168 |
* come here (please, define as static)
|
|
3169 |
*/
|
|
3170 |
|
|
3171 |
%}'
|
74
|
3172 |
!
|
|
3173 |
|
|
3174 |
classPrimitiveFunctions
|
|
3175 |
"show the classes primitiveFunctions in the codeView.
|
93
|
3176 |
Also, set accept action to change it."
|
74
|
3177 |
|
107
|
3178 |
self classShowFrom:#primitiveFunctionsString
|
|
3179 |
set:#primitiveFunctions:
|
|
3180 |
aspect:#primitiveFunctions
|
|
3181 |
default:'%{
|
|
3182 |
|
|
3183 |
/*
|
|
3184 |
* any local C (helper) functions
|
|
3185 |
* come here (please, define as static)
|
|
3186 |
*/
|
|
3187 |
|
|
3188 |
%}'
|
74
|
3189 |
!
|
|
3190 |
|
|
3191 |
classNewSubclass
|
|
3192 |
"create a subclass-definition prototype in codeview"
|
|
3193 |
|
|
3194 |
self doClassMenu:[:currentClass |
|
|
3195 |
self classClassDefinitionTemplateFor:(currentClass name)
|
|
3196 |
in:(currentClass category).
|
|
3197 |
aspect := nil
|
|
3198 |
]
|
|
3199 |
!
|
|
3200 |
|
|
3201 |
classRefs
|
|
3202 |
self doClassMenu:[:currentClass |
|
|
3203 |
self withCursor:(Cursor questionMark) do:[
|
|
3204 |
SystemBrowser browseReferendsOf:currentClass name asSymbol
|
|
3205 |
]
|
|
3206 |
]
|
|
3207 |
!
|
|
3208 |
|
|
3209 |
classUses
|
|
3210 |
"a powerful tool, when trying to learn more about where
|
|
3211 |
a class is used. This one searches all uses of a class,
|
|
3212 |
and shows a list of uses - try it and like it"
|
|
3213 |
|
|
3214 |
self doClassMenu:[:currentClass |
|
|
3215 |
self withCursor:(Cursor questionMark) do:[
|
|
3216 |
SystemBrowser browseUsesOf:currentClass
|
|
3217 |
]
|
|
3218 |
]
|
|
3219 |
!
|
|
3220 |
|
|
3221 |
classRename
|
|
3222 |
"launch an enterBox for new name and query user"
|
|
3223 |
|
|
3224 |
|box|
|
|
3225 |
|
|
3226 |
self checkClassSelected ifFalse:[^ self].
|
|
3227 |
box := self enterBoxTitle:(resources string:'rename %1 to:' with:currentClass name) okText:'rename'.
|
|
3228 |
box initialText:(currentClass name).
|
|
3229 |
box action:[:aString | self renameCurrentClassTo:aString].
|
|
3230 |
box showAtPointer
|
|
3231 |
! !
|
|
3232 |
|
|
3233 |
!BrowserView methodsFor:'unused'!
|
|
3234 |
|
|
3235 |
listOfAllSelectorsInCategory:aCategory inHierarchyOfClass:aClass
|
|
3236 |
"answer a list of all selectors in a given method category
|
|
3237 |
of the argument, aClass and its superclasses"
|
|
3238 |
|
|
3239 |
|newList|
|
|
3240 |
|
|
3241 |
newList := Set new.
|
|
3242 |
self classesInHierarchy:aClass do:[:c |
|
|
3243 |
|searchCategory|
|
|
3244 |
|
|
3245 |
(aCategory = '* all *') ifTrue:[
|
|
3246 |
newList addAll:(c selectorArray)
|
|
3247 |
] ifFalse:[
|
|
3248 |
(aCategory = '* no category *') ifTrue:[
|
|
3249 |
searchCategory := nil
|
|
3250 |
] ifFalse:[
|
|
3251 |
searchCategory := aCategory
|
|
3252 |
].
|
|
3253 |
c methodArray with:c selectorArray do:[:aMethod :selector |
|
|
3254 |
(aMethod category = searchCategory) ifTrue:[
|
|
3255 |
newList add:selector
|
|
3256 |
]
|
|
3257 |
]
|
|
3258 |
].
|
|
3259 |
].
|
|
3260 |
(newList size == 0) ifTrue:[^ nil].
|
|
3261 |
^ newList asOrderedCollection sort
|
|
3262 |
!
|
|
3263 |
|
|
3264 |
listOfAllMethodCategoriesInHierarchy:aClass
|
|
3265 |
"answer a list of all method categories of the argument, aClass,
|
|
3266 |
and all of its superclasses"
|
|
3267 |
|
|
3268 |
|newList cat|
|
|
3269 |
|
79
|
3270 |
newList := Set new.
|
74
|
3271 |
self classesInHierarchy:aClass do:[:c |
|
|
3272 |
c methodArray do:[:aMethod |
|
|
3273 |
cat := aMethod category.
|
|
3274 |
cat isNil ifTrue:[
|
|
3275 |
cat := '* no category *'
|
|
3276 |
].
|
79
|
3277 |
newList add:cat
|
74
|
3278 |
]
|
|
3279 |
].
|
|
3280 |
(newList size == 0) ifTrue:[^ nil].
|
|
3281 |
newList add:'* all *'.
|
79
|
3282 |
^ newList asOrderedCollection sort
|
74
|
3283 |
|
|
3284 |
! !
|
|
3285 |
|
|
3286 |
!BrowserView methodsFor:'class category stuff'!
|
|
3287 |
|
|
3288 |
listOfAllClassCategories
|
|
3289 |
"return a list of all class categories"
|
|
3290 |
|
|
3291 |
|newList cat|
|
|
3292 |
|
79
|
3293 |
newList := Set with:'* all *' with:'* hierarchy *'.
|
74
|
3294 |
Smalltalk allBehaviorsDo:[:aClass |
|
108
|
3295 |
aClass isMeta ifFalse:[
|
|
3296 |
cat := aClass category.
|
|
3297 |
cat isNil ifTrue:[
|
|
3298 |
cat := '* no category *'
|
|
3299 |
].
|
|
3300 |
cat ~= 'obsolete' ifTrue:[
|
|
3301 |
newList add:cat
|
|
3302 |
]
|
93
|
3303 |
]
|
74
|
3304 |
].
|
79
|
3305 |
^ newList asOrderedCollection sort.
|
74
|
3306 |
!
|
|
3307 |
|
|
3308 |
classCategorySelectionChanged
|
|
3309 |
"class category has changed - update dependent views"
|
|
3310 |
|
|
3311 |
self withWaitCursorDo:[
|
|
3312 |
self switchToClass:nil.
|
|
3313 |
actualClass := acceptClass := nil.
|
|
3314 |
currentMethodCategory := nil.
|
|
3315 |
currentMethod := currentSelector := nil.
|
|
3316 |
|
|
3317 |
self updateClassList.
|
|
3318 |
self updateMethodCategoryList.
|
|
3319 |
self updateMethodList.
|
|
3320 |
self updateCodeView.
|
|
3321 |
|
|
3322 |
codeView explainAction:nil.
|
|
3323 |
codeView acceptAction:nil
|
|
3324 |
]
|
|
3325 |
!
|
|
3326 |
|
|
3327 |
classCategorySelection:lineNr
|
|
3328 |
"user clicked on a class category line - show classes.
|
|
3329 |
If switching to hierarchy or all, keep current selections"
|
|
3330 |
|
|
3331 |
|newCategory oldClass oldName classIndex|
|
|
3332 |
|
|
3333 |
newCategory := classCategoryListView selectionValue.
|
|
3334 |
(newCategory startsWith:'*') ifTrue:[
|
|
3335 |
"etiher all or hierarchy;
|
|
3336 |
remember current selections and switch after showing class list"
|
|
3337 |
oldClass := currentClass
|
|
3338 |
].
|
|
3339 |
currentClassCategory := newCategory.
|
|
3340 |
oldClass isNil ifTrue:[
|
|
3341 |
self classCategorySelectionChanged
|
|
3342 |
] ifFalse:[
|
|
3343 |
oldName := oldClass name.
|
|
3344 |
self withWaitCursorDo:[
|
|
3345 |
self updateClassList
|
|
3346 |
].
|
|
3347 |
"stupid - search for class name in (indented) list"
|
|
3348 |
classIndex := classListView list findFirst:[:elem | elem endsWith:oldName].
|
|
3349 |
classIndex ~~ 0 ifTrue:[
|
|
3350 |
classListView selection:classIndex.
|
|
3351 |
self switchToClass:(Smalltalk at:(oldName asSymbol))
|
|
3352 |
] ifFalse:[
|
|
3353 |
self normalLabel.
|
|
3354 |
]
|
|
3355 |
]
|
|
3356 |
!
|
|
3357 |
|
|
3358 |
updateClassCategoryListWithScroll:scroll
|
|
3359 |
|oldClassCategory oldClass oldMethodCategory oldMethod
|
|
3360 |
oldSelector newCategoryList|
|
|
3361 |
|
|
3362 |
classMethodListView notNil ifTrue:[ ^ self ].
|
|
3363 |
|
|
3364 |
oldClassCategory := currentClassCategory.
|
|
3365 |
oldClass := currentClass.
|
|
3366 |
oldMethodCategory := currentMethodCategory.
|
|
3367 |
oldMethod := currentMethod.
|
|
3368 |
oldMethod notNil ifTrue:[
|
|
3369 |
oldSelector := currentSelector
|
|
3370 |
].
|
|
3371 |
|
|
3372 |
classCategoryListView notNil ifTrue:[
|
|
3373 |
newCategoryList := self listOfAllClassCategories.
|
|
3374 |
newCategoryList = classCategoryListView list ifFalse:[
|
|
3375 |
scroll ifTrue:[
|
|
3376 |
classCategoryListView contents:newCategoryList
|
|
3377 |
] ifFalse:[
|
|
3378 |
classCategoryListView setContents:newCategoryList
|
|
3379 |
]
|
|
3380 |
]
|
|
3381 |
].
|
|
3382 |
|
|
3383 |
oldClassCategory notNil ifTrue:[
|
|
3384 |
classCategoryListView notNil ifTrue:[
|
|
3385 |
classCategoryListView selectElement:oldClassCategory
|
|
3386 |
]
|
|
3387 |
].
|
|
3388 |
classListView notNil ifTrue:[
|
|
3389 |
oldClass notNil ifTrue:[
|
|
3390 |
classListView selectElement:(oldClass name)
|
|
3391 |
]
|
|
3392 |
].
|
|
3393 |
oldMethodCategory notNil ifTrue:[
|
|
3394 |
methodCategoryListView notNil ifTrue:[
|
|
3395 |
methodCategoryListView selectElement:oldMethodCategory
|
|
3396 |
].
|
|
3397 |
].
|
|
3398 |
oldSelector notNil ifTrue:[
|
|
3399 |
methodListView notNil ifTrue:[
|
|
3400 |
methodListView selectElement:oldSelector
|
|
3401 |
].
|
|
3402 |
]
|
|
3403 |
!
|
|
3404 |
|
|
3405 |
checkClassCategorySelected
|
|
3406 |
currentClassCategory isNil ifTrue:[
|
|
3407 |
self warn:'select a class category first'.
|
|
3408 |
^ false
|
|
3409 |
].
|
|
3410 |
^ true
|
|
3411 |
!
|
|
3412 |
|
|
3413 |
updateClassCategoryList
|
|
3414 |
self updateClassCategoryListWithScroll:true
|
|
3415 |
!
|
|
3416 |
|
|
3417 |
renameCurrentClassCategoryTo:aString
|
|
3418 |
"helper - do the rename"
|
|
3419 |
|
|
3420 |
|any categories|
|
|
3421 |
|
|
3422 |
currentClassCategory notNil ifTrue:[
|
|
3423 |
any := false.
|
|
3424 |
Smalltalk allBehaviorsDo:[:aClass |
|
|
3425 |
aClass category = currentClassCategory ifTrue:[
|
|
3426 |
aClass category:aString.
|
|
3427 |
any := true
|
|
3428 |
]
|
|
3429 |
].
|
|
3430 |
any ifFalse:[
|
|
3431 |
categories := classCategoryListView list.
|
|
3432 |
categories remove:currentClassCategory.
|
|
3433 |
categories add:aString.
|
|
3434 |
categories sort.
|
|
3435 |
classCategoryListView setContents:categories.
|
|
3436 |
currentClassCategory := aString.
|
|
3437 |
classCategoryListView selectElement:aString.
|
|
3438 |
] ifTrue:[
|
|
3439 |
currentClassCategory := aString.
|
|
3440 |
self updateClassCategoryList.
|
|
3441 |
self updateClassListWithScroll:false
|
|
3442 |
]
|
|
3443 |
]
|
|
3444 |
! !
|
|
3445 |
|
|
3446 |
!BrowserView methodsFor:'class-method stuff'!
|
|
3447 |
|
|
3448 |
classFromClassMethodString:aString
|
|
3449 |
"helper for classMethod-list - extract class name from the string"
|
|
3450 |
|
93
|
3451 |
"/ |pos|
|
|
3452 |
"/
|
|
3453 |
"/ pos := aString indexOf:(Character space).
|
|
3454 |
"/ ^ aString copyTo:(pos - 1)
|
|
3455 |
|
|
3456 |
^ aString upTo:Character space
|
74
|
3457 |
!
|
|
3458 |
|
|
3459 |
selectorFromClassMethodString:aString
|
|
3460 |
"helper for classMethod-list - extract selector from the string"
|
|
3461 |
|
|
3462 |
|pos|
|
|
3463 |
|
|
3464 |
pos := aString indexOf:(Character space).
|
|
3465 |
^ aString copyFrom:(pos + 1)
|
|
3466 |
!
|
|
3467 |
|
|
3468 |
classMethodSelection:lineNr
|
|
3469 |
"user clicked on a class/method line - show code"
|
|
3470 |
|
|
3471 |
|string classString selectorString|
|
|
3472 |
|
|
3473 |
string := classMethodListView selectionValue.
|
|
3474 |
classString := self classFromClassMethodString:string.
|
|
3475 |
selectorString := self selectorFromClassMethodString:string.
|
|
3476 |
((classString ~= 'Metaclass') and:[classString endsWith:'class']) ifTrue:[
|
106
|
3477 |
classString := classString copyWithoutLast:5 "copyTo:(classString size - 5)".
|
74
|
3478 |
self switchToClass:(Smalltalk at:classString asSymbol).
|
|
3479 |
actualClass := acceptClass := currentClass class
|
|
3480 |
] ifFalse:[
|
|
3481 |
self switchToClass:(Smalltalk at:classString asSymbol).
|
|
3482 |
actualClass := acceptClass := currentClass
|
|
3483 |
].
|
|
3484 |
currentClass isNil ifTrue:[
|
|
3485 |
self warn:'oops class is gone'
|
|
3486 |
] ifFalse:[
|
|
3487 |
currentClassCategory := currentClass category.
|
|
3488 |
currentSelector := selectorString asSymbol.
|
|
3489 |
currentMethod := actualClass compiledMethodAt:currentSelector.
|
92
|
3490 |
currentMethod isNil ifTrue:[
|
|
3491 |
self warn:'oops method is gone'
|
|
3492 |
] ifFalse:[
|
|
3493 |
currentMethodCategory := currentMethod category.
|
|
3494 |
].
|
74
|
3495 |
|
|
3496 |
self methodSelectionChanged
|
|
3497 |
].
|
|
3498 |
|
|
3499 |
self setDoitActionForClass
|
|
3500 |
! !
|
|
3501 |
|
|
3502 |
!BrowserView methodsFor:'class category list menu'!
|
|
3503 |
|
|
3504 |
classCategoryMenu
|
|
3505 |
|labels selectors|
|
|
3506 |
|
|
3507 |
currentClassCategory isNil ifTrue:[
|
|
3508 |
labels := #(
|
|
3509 |
'spawn full class'
|
|
3510 |
'-'
|
|
3511 |
'update'
|
|
3512 |
'find class ...'
|
|
3513 |
'-'
|
|
3514 |
'new class category ...'
|
|
3515 |
).
|
|
3516 |
selectors := #(
|
|
3517 |
classCategorySpawnFullClass
|
|
3518 |
nil
|
|
3519 |
classCategoryUpdate
|
|
3520 |
classCategoryFindClass
|
|
3521 |
nil
|
|
3522 |
classCategoryNewCategory
|
|
3523 |
).
|
|
3524 |
] ifFalse:[
|
|
3525 |
labels := #(
|
|
3526 |
'fileOut'
|
|
3527 |
'fileOut each'
|
|
3528 |
"
|
|
3529 |
'fileOut binary'
|
|
3530 |
"
|
|
3531 |
'printOut'
|
|
3532 |
'printOut protocol'
|
|
3533 |
'-'
|
|
3534 |
'SPAWN_CATEGORY'
|
|
3535 |
'spawn full class'
|
|
3536 |
'-'
|
|
3537 |
'update'
|
|
3538 |
'find class ...'
|
|
3539 |
'-'
|
|
3540 |
'new class category ...'
|
|
3541 |
'rename ...'
|
|
3542 |
'remove'
|
|
3543 |
).
|
|
3544 |
selectors := #(
|
|
3545 |
classCategoryFileOut
|
|
3546 |
classCategoryFileOutEach
|
|
3547 |
classCategoryPrintOut
|
|
3548 |
classCategoryPrintOutProtocol
|
|
3549 |
nil
|
|
3550 |
classCategorySpawn
|
|
3551 |
classCategorySpawnFullClass
|
|
3552 |
nil
|
|
3553 |
classCategoryUpdate
|
|
3554 |
classCategoryFindClass
|
|
3555 |
nil
|
|
3556 |
classCategoryNewCategory
|
|
3557 |
classCategoryRename
|
|
3558 |
classCategoryRemove
|
|
3559 |
).
|
|
3560 |
].
|
|
3561 |
|
|
3562 |
^ PopUpMenu labels:(resources array:labels)
|
|
3563 |
selectors:selectors
|
|
3564 |
!
|
|
3565 |
|
|
3566 |
classCategoryUpdate
|
|
3567 |
"update class category list and dependants"
|
|
3568 |
|
|
3569 |
|oldClassName oldMethodCategory|
|
|
3570 |
|
|
3571 |
classCategoryListView notNil ifTrue:[
|
|
3572 |
currentClass notNil ifTrue:[
|
|
3573 |
oldClassName := currentClass name.
|
|
3574 |
(oldClassName endsWith:'-old') ifTrue:[
|
106
|
3575 |
oldClassName := oldClassName copyWithoutLast:4 "copyTo:(oldClassName size - 4)"
|
74
|
3576 |
]
|
|
3577 |
].
|
|
3578 |
oldMethodCategory := currentMethodCategory.
|
|
3579 |
|
|
3580 |
classCategoryListView setContents:(self listOfAllClassCategories).
|
|
3581 |
currentClassCategory notNil ifTrue:[
|
|
3582 |
classCategoryListView selectElement:currentClassCategory.
|
|
3583 |
self classCategorySelectionChanged.
|
|
3584 |
oldClassName notNil ifTrue:[
|
|
3585 |
classListView selectElement:oldClassName.
|
|
3586 |
self switchToClass:(Smalltalk at:oldClassName asSymbol).
|
|
3587 |
self classSelectionChanged.
|
|
3588 |
oldMethodCategory notNil ifTrue:[
|
|
3589 |
methodCategoryListView selectElement:oldMethodCategory.
|
|
3590 |
currentMethodCategory := oldMethodCategory.
|
|
3591 |
self methodCategorySelectionChanged
|
|
3592 |
]
|
|
3593 |
]
|
|
3594 |
]
|
|
3595 |
]
|
|
3596 |
!
|
|
3597 |
|
|
3598 |
classCategoryPrintOutProtocol
|
|
3599 |
|printStream|
|
|
3600 |
|
106
|
3601 |
Smalltalk allClassesInCategory:currentClassCategory inOrderDo:[:aClass |
|
74
|
3602 |
printStream := Printer new.
|
|
3603 |
aClass printOutProtocolOn:printStream.
|
|
3604 |
printStream close
|
|
3605 |
]
|
|
3606 |
!
|
|
3607 |
|
|
3608 |
classCategoryPrintOut
|
|
3609 |
|printStream|
|
|
3610 |
|
106
|
3611 |
Smalltalk allClassesInCategory:currentClassCategory do:[:aClass |
|
74
|
3612 |
printStream := Printer new.
|
|
3613 |
aClass printOutOn:printStream.
|
|
3614 |
printStream close
|
|
3615 |
]
|
|
3616 |
!
|
|
3617 |
|
|
3618 |
classCategorySpawn
|
|
3619 |
"create a new SystemBrowser browsing current classCategory"
|
|
3620 |
|
|
3621 |
currentClassCategory notNil ifTrue:[
|
|
3622 |
self withWaitCursorDo:[
|
|
3623 |
SystemBrowser browseClassCategory:currentClassCategory
|
|
3624 |
]
|
|
3625 |
]
|
|
3626 |
!
|
|
3627 |
|
|
3628 |
classCategoryFileOut
|
|
3629 |
"create a file 'categoryName' consisting of all classes in current category"
|
|
3630 |
|
|
3631 |
|aStream fileName|
|
|
3632 |
|
|
3633 |
self checkClassCategorySelected ifFalse:[^ self].
|
|
3634 |
|
|
3635 |
fileName := currentClassCategory asString.
|
|
3636 |
fileName replaceAll:Character space by:$_.
|
|
3637 |
"
|
|
3638 |
this test allows a smalltalk to be built without Projects/ChangeSets
|
|
3639 |
"
|
|
3640 |
Project notNil ifTrue:[
|
|
3641 |
fileName := Project currentProjectDirectory , fileName.
|
|
3642 |
].
|
|
3643 |
|
106
|
3644 |
self withWaitCursorDo:[
|
|
3645 |
"
|
|
3646 |
if file exists, save original in a .sav file
|
|
3647 |
"
|
|
3648 |
fileName asFilename exists ifTrue:[
|
|
3649 |
self busyLabel:'saving existing %1' with:fileName.
|
|
3650 |
fileName asFilename copyTo:(fileName , '.sav')
|
|
3651 |
].
|
|
3652 |
|
|
3653 |
aStream := FileStream newFileNamed:fileName.
|
|
3654 |
aStream isNil ifTrue:[
|
|
3655 |
self warn:'cannot create: %1' with:fileName
|
|
3656 |
] ifFalse:[
|
|
3657 |
self busyLabel:'writing: %1' with:fileName.
|
|
3658 |
Smalltalk allClassesInCategory:currentClassCategory inOrderDo:[:aClass |
|
|
3659 |
aClass fileOutOn:aStream.
|
|
3660 |
].
|
|
3661 |
aStream close.
|
|
3662 |
]
|
74
|
3663 |
].
|
106
|
3664 |
self normalLabel.
|
74
|
3665 |
!
|
|
3666 |
|
|
3667 |
classCategorySpawnFullClass
|
|
3668 |
"create a new SystemBrowser browsing full class"
|
|
3669 |
|
|
3670 |
|newBrowser|
|
|
3671 |
|
|
3672 |
self withWaitCursorDo:[
|
|
3673 |
newBrowser := SystemBrowser browseFullClasses
|
|
3674 |
" "
|
|
3675 |
.
|
|
3676 |
currentClass notNil ifTrue:[
|
|
3677 |
newBrowser switchToClassNamed:(currentClass name)
|
|
3678 |
]
|
|
3679 |
" "
|
|
3680 |
]
|
|
3681 |
!
|
|
3682 |
|
|
3683 |
classCategoryFileOutEach
|
|
3684 |
self withWaitCursorDo:[
|
106
|
3685 |
Smalltalk allClassesInCategory:currentClassCategory do:[:aClass |
|
|
3686 |
self busyLabel:'saving: %1' with:aClass name.
|
74
|
3687 |
Class fileOutErrorSignal handle:[:ex |
|
|
3688 |
self warn:'cannot create: %1' with:ex parameter.
|
|
3689 |
ex return.
|
|
3690 |
] do:[
|
|
3691 |
aClass fileOut
|
|
3692 |
]
|
|
3693 |
].
|
|
3694 |
self normalLabel.
|
|
3695 |
]
|
|
3696 |
!
|
|
3697 |
|
|
3698 |
classCategoryNewCategory
|
|
3699 |
|box|
|
|
3700 |
|
|
3701 |
box := self enterBoxTitle:'name of new class category:' okText:'create'.
|
|
3702 |
box action:[:aString |
|
|
3703 |
|categories|
|
|
3704 |
|
|
3705 |
currentClass notNil ifTrue:[
|
79
|
3706 |
categories := Set new.
|
74
|
3707 |
currentClass withAllSuperclasses do:[:aClass |
|
|
3708 |
aClass methodArray do:[:aMethod |
|
79
|
3709 |
categories add:aMethod category
|
74
|
3710 |
]
|
|
3711 |
].
|
79
|
3712 |
categories := categories asOrderedCollection
|
74
|
3713 |
].
|
|
3714 |
categories isNil ifTrue:[
|
|
3715 |
categories := classCategoryListView list.
|
|
3716 |
].
|
|
3717 |
(categories includes:aString) ifFalse:[
|
|
3718 |
categories add:aString.
|
|
3719 |
categories sort.
|
|
3720 |
classCategoryListView setContents:categories.
|
|
3721 |
currentClassCategory := aString.
|
|
3722 |
classCategoryListView selectElement:aString.
|
|
3723 |
self switchToClass:nil.
|
|
3724 |
actualClass := acceptClass := nil.
|
|
3725 |
self classCategorySelectionChanged
|
|
3726 |
]
|
|
3727 |
].
|
|
3728 |
box showAtPointer
|
|
3729 |
!
|
|
3730 |
|
|
3731 |
classCategoryFindClass
|
|
3732 |
|box|
|
|
3733 |
|
|
3734 |
box := self enterBoxForCodeSelectionTitle:'class to find:' okText:'find'.
|
118
|
3735 |
box entryCompletionBlock:[
|
|
3736 |
|s what m|
|
|
3737 |
|
|
3738 |
s := box contents asString withoutSpaces.
|
|
3739 |
what := Smalltalk classnameCompletion:s.
|
|
3740 |
box contents:what first.
|
|
3741 |
(what at:2) size ~~ 1 ifTrue:[
|
|
3742 |
device beep
|
|
3743 |
]
|
|
3744 |
].
|
74
|
3745 |
box action:[:aString | self switchToClassNameMatching:aString].
|
|
3746 |
box showAtPointer
|
|
3747 |
!
|
|
3748 |
|
|
3749 |
classCategoryRename
|
|
3750 |
"launch an enterBox to rename current class category"
|
|
3751 |
|
|
3752 |
|box|
|
|
3753 |
|
|
3754 |
self checkClassCategorySelected ifFalse:[^ self].
|
|
3755 |
|
|
3756 |
box := self enterBoxTitle:'rename class category to:' okText:'rename'.
|
|
3757 |
box initialText:currentClassCategory.
|
|
3758 |
box action:[:aString | self renameCurrentClassCategoryTo:aString].
|
|
3759 |
box showAtPointer
|
|
3760 |
!
|
|
3761 |
|
|
3762 |
classCategoryRemove
|
|
3763 |
"remove all classes in current category"
|
|
3764 |
|
|
3765 |
|count t classesToRemove subclassesRemoved box|
|
|
3766 |
|
|
3767 |
self checkClassCategorySelected ifFalse:[^ self].
|
|
3768 |
|
|
3769 |
classesToRemove := OrderedCollection new.
|
|
3770 |
Smalltalk allBehaviorsDo:[:aClass |
|
|
3771 |
aClass category = currentClassCategory ifTrue:[
|
|
3772 |
classesToRemove add:aClass
|
|
3773 |
]
|
|
3774 |
].
|
|
3775 |
subclassesRemoved := OrderedCollection new.
|
|
3776 |
classesToRemove do:[:aClass |
|
|
3777 |
aClass allSubclassesDo:[:aSubclass |
|
|
3778 |
(classesToRemove includes:aSubclass) ifFalse:[
|
|
3779 |
(subclassesRemoved includes:aSubclass) ifFalse:[
|
|
3780 |
subclassesRemoved add:aSubclass
|
|
3781 |
]
|
|
3782 |
]
|
|
3783 |
]
|
|
3784 |
].
|
|
3785 |
|
|
3786 |
count := classesToRemove size.
|
|
3787 |
t := resources string:'remove %1 ?' with:currentClassCategory.
|
|
3788 |
count ~~ 0 ifTrue:[
|
|
3789 |
t := t , (resources at:'\(with ') , count printString.
|
|
3790 |
count == 1 ifTrue:[
|
|
3791 |
t := t , (resources at:' class')
|
|
3792 |
] ifFalse:[
|
|
3793 |
t := t , (resources at:' classes')
|
|
3794 |
].
|
|
3795 |
t := (t , ')') withCRs
|
|
3796 |
].
|
|
3797 |
|
|
3798 |
count := subclassesRemoved size.
|
|
3799 |
count ~~ 0 ifTrue:[
|
|
3800 |
t := t , (resources at:'\(and ') , count printString.
|
|
3801 |
count == 1 ifTrue:[
|
|
3802 |
t := t , (resources at:' subclass ')
|
|
3803 |
] ifFalse:[
|
|
3804 |
t := t , (resources at:' subclasses ')
|
|
3805 |
].
|
|
3806 |
t := (t , ')') withCRs
|
|
3807 |
].
|
|
3808 |
|
|
3809 |
t := t withCRs.
|
|
3810 |
|
|
3811 |
box := YesNoBox
|
|
3812 |
title:t
|
|
3813 |
yesText:(resources at:'remove')
|
|
3814 |
noText:(resources at:'abort').
|
|
3815 |
box confirm ifTrue:[
|
|
3816 |
"after querying user - do really remove classes in list1 and list2"
|
|
3817 |
|
|
3818 |
subclassesRemoved do:[:aClass |
|
|
3819 |
(CheckForInstancesWhenRemovingClasses not
|
|
3820 |
or:[aClass hasInstances not
|
|
3821 |
or:[self confirm:(aClass name , ' has instances - remove anyway ?')]])
|
|
3822 |
ifTrue:[
|
|
3823 |
Smalltalk removeClass:aClass
|
|
3824 |
]
|
|
3825 |
].
|
|
3826 |
classesToRemove do:[:aClass |
|
|
3827 |
(CheckForInstancesWhenRemovingClasses not
|
|
3828 |
or:[aClass hasInstances not
|
|
3829 |
or:[self confirm:(aClass name , ' has instances - remove anyway ?')]])
|
|
3830 |
ifTrue:[
|
|
3831 |
Smalltalk removeClass:aClass
|
|
3832 |
].
|
|
3833 |
].
|
|
3834 |
currentClassCategory := nil.
|
|
3835 |
self switchToClass:nil.
|
|
3836 |
Smalltalk changed
|
|
3837 |
]
|
|
3838 |
! !
|
|
3839 |
|
|
3840 |
!BrowserView methodsFor:'method list menu'!
|
|
3841 |
|
|
3842 |
methodMenu
|
|
3843 |
"return a popupmenu as appropriate for the methodList"
|
|
3844 |
|
107
|
3845 |
|m labels selectors
|
74
|
3846 |
newLabels newSelectors
|
|
3847 |
mthdLabels mthdSelectors
|
|
3848 |
brkLabels brkSelectors
|
|
3849 |
fileLabels fileSelectors
|
|
3850 |
searchLabels searchSelectors
|
|
3851 |
sepLocalLabels sepLocalSelectors
|
|
3852 |
localSearchLabels localSearchSelectors|
|
|
3853 |
|
105
|
3854 |
device ctrlDown ifTrue:[
|
|
3855 |
"/ 'secret' developpers menu
|
|
3856 |
|
107
|
3857 |
currentMethod isNil ifTrue:[
|
|
3858 |
methodListView flash.
|
|
3859 |
^ nil
|
|
3860 |
].
|
105
|
3861 |
labels := #(
|
|
3862 |
'inspect method'
|
117
|
3863 |
'compile to machine code'
|
|
3864 |
'decompile'
|
107
|
3865 |
'-'
|
|
3866 |
'make private'
|
|
3867 |
'make protected'
|
|
3868 |
'make public'
|
105
|
3869 |
).
|
|
3870 |
selectors := #(
|
|
3871 |
methodInspect
|
117
|
3872 |
methodSTCCompile
|
110
|
3873 |
methodDecompile
|
107
|
3874 |
nil
|
|
3875 |
methodMakePrivate
|
|
3876 |
methodMakeProtected
|
|
3877 |
methodMakePublic
|
105
|
3878 |
)
|
|
3879 |
] ifFalse:[
|
|
3880 |
|
|
3881 |
sepLocalLabels := sepLocalSelectors := #().
|
|
3882 |
|
|
3883 |
searchLabels := #(
|
|
3884 |
'senders ...'
|
|
3885 |
'implementors ...'
|
|
3886 |
'globals ...'
|
|
3887 |
'string search ...'
|
|
3888 |
'apropos ...'
|
74
|
3889 |
).
|
105
|
3890 |
searchSelectors := #(
|
|
3891 |
methodSenders
|
|
3892 |
methodImplementors
|
|
3893 |
methodGlobalReferends
|
|
3894 |
methodStringSearch
|
|
3895 |
methodAproposSearch
|
74
|
3896 |
).
|
105
|
3897 |
|
|
3898 |
currentClass notNil ifTrue:[
|
|
3899 |
localSearchLabels := #(
|
|
3900 |
'-'
|
|
3901 |
'local senders ...'
|
|
3902 |
'local implementors ...'
|
|
3903 |
'local string search ...'
|
|
3904 |
'local apropos ...'
|
74
|
3905 |
).
|
105
|
3906 |
localSearchSelectors := #(
|
|
3907 |
nil
|
|
3908 |
methodLocalSenders
|
|
3909 |
methodLocalImplementors
|
|
3910 |
methodLocalStringSearch
|
|
3911 |
methodLocalAproposSearch
|
|
3912 |
).
|
|
3913 |
] ifFalse:[
|
|
3914 |
localSearchLabels := localSearchSelectors := #()
|
|
3915 |
].
|
|
3916 |
|
|
3917 |
currentMethodCategory notNil ifTrue:[
|
|
3918 |
sepLocalLabels := #('-'). sepLocalSelectors := #(nil).
|
|
3919 |
|
|
3920 |
newLabels := #(
|
|
3921 |
'new method'
|
|
3922 |
).
|
|
3923 |
|
|
3924 |
newSelectors := #(
|
|
3925 |
methodNewMethod
|
|
3926 |
).
|
74
|
3927 |
] ifFalse:[
|
105
|
3928 |
newLabels := newSelectors := #()
|
|
3929 |
].
|
|
3930 |
|
|
3931 |
currentMethod notNil ifTrue:[
|
|
3932 |
fileLabels := #(
|
|
3933 |
'fileOut'
|
|
3934 |
'printOut'
|
|
3935 |
'-'
|
|
3936 |
'SPAWN_METHOD'
|
|
3937 |
'-'
|
|
3938 |
).
|
|
3939 |
|
|
3940 |
fileSelectors := #(
|
|
3941 |
methodFileOut
|
|
3942 |
methodPrintOut
|
|
3943 |
nil
|
|
3944 |
methodSpawn
|
|
3945 |
nil
|
|
3946 |
).
|
|
3947 |
|
|
3948 |
sepLocalLabels := #('-'). sepLocalSelectors := #(nil).
|
|
3949 |
|
|
3950 |
mthdLabels := #(
|
|
3951 |
'change category ...'
|
|
3952 |
'remove'
|
|
3953 |
).
|
|
3954 |
|
|
3955 |
mthdSelectors := #(
|
|
3956 |
methodChangeCategory
|
|
3957 |
methodRemove
|
|
3958 |
).
|
|
3959 |
|
|
3960 |
currentMethod isWrapped ifTrue:[
|
|
3961 |
brkLabels := #(
|
|
3962 |
'remove break/trace'
|
|
3963 |
'-'
|
|
3964 |
).
|
|
3965 |
|
|
3966 |
brkSelectors := #(
|
|
3967 |
methodRemoveBreakOrTrace
|
|
3968 |
nil
|
|
3969 |
)
|
|
3970 |
] ifFalse:[
|
|
3971 |
brkLabels := #(
|
|
3972 |
'breakpoint'
|
|
3973 |
'trace'
|
|
3974 |
'trace sender'
|
|
3975 |
'-'
|
|
3976 |
).
|
|
3977 |
|
|
3978 |
brkSelectors := #(
|
|
3979 |
methodBreakPoint
|
|
3980 |
methodTrace
|
|
3981 |
methodTraceSender
|
|
3982 |
nil
|
|
3983 |
)
|
|
3984 |
]
|
|
3985 |
] ifFalse:[
|
|
3986 |
fileLabels := fileSelectors := #().
|
|
3987 |
brkLabels := brkSelectors := #().
|
|
3988 |
mthdLabels := mthdSelectors := #().
|
|
3989 |
].
|
|
3990 |
|
|
3991 |
|
|
3992 |
|
|
3993 |
labels :=
|
|
3994 |
fileLabels ,
|
|
3995 |
searchLabels ,
|
|
3996 |
localSearchLabels ,
|
|
3997 |
sepLocalLabels ,
|
|
3998 |
brkLabels ,
|
|
3999 |
newLabels ,
|
|
4000 |
mthdLabels.
|
|
4001 |
|
|
4002 |
selectors :=
|
|
4003 |
fileSelectors ,
|
|
4004 |
searchSelectors ,
|
|
4005 |
localSearchSelectors ,
|
|
4006 |
sepLocalSelectors ,
|
|
4007 |
brkSelectors ,
|
|
4008 |
newSelectors ,
|
|
4009 |
mthdSelectors.
|
74
|
4010 |
|
|
4011 |
"
|
105
|
4012 |
labels := #(
|
|
4013 |
'fileOut'
|
|
4014 |
'printOut'
|
|
4015 |
'-'
|
|
4016 |
'SPAWN_METHOD'
|
|
4017 |
'-'
|
|
4018 |
'senders ...'
|
|
4019 |
'implementors ...'
|
|
4020 |
'globals ...'
|
|
4021 |
'string search ...'
|
|
4022 |
'apropos ...'
|
|
4023 |
'-'
|
|
4024 |
'local senders ...'
|
|
4025 |
'local implementors ...'
|
|
4026 |
'local string search ...'
|
|
4027 |
'local apropos ...'
|
|
4028 |
'-'
|
|
4029 |
'breakpoint'
|
|
4030 |
'trace'
|
|
4031 |
'trace sender'
|
|
4032 |
'-'
|
|
4033 |
'new method'
|
|
4034 |
'change category ...'
|
|
4035 |
'remove'
|
|
4036 |
).
|
|
4037 |
selectors := #(
|
|
4038 |
methodFileOut
|
|
4039 |
methodPrintOut
|
|
4040 |
nil
|
|
4041 |
methodSpawn
|
|
4042 |
nil
|
|
4043 |
methodSenders
|
|
4044 |
methodImplementors
|
|
4045 |
methodGlobalReferends
|
|
4046 |
methodStringSearch
|
|
4047 |
methodAproposSearch
|
|
4048 |
nil
|
|
4049 |
methodLocalSenders
|
|
4050 |
methodLocalImplementors
|
|
4051 |
methodLocalStringSearch
|
|
4052 |
methodLocalAproposSearch
|
|
4053 |
nil
|
|
4054 |
methodBreakPoint
|
|
4055 |
methodTrace
|
|
4056 |
methodTraceSender
|
|
4057 |
nil
|
|
4058 |
methodNewMethod
|
|
4059 |
methodChangeCategory
|
|
4060 |
methodRemove
|
|
4061 |
)
|
74
|
4062 |
"
|
105
|
4063 |
].
|
107
|
4064 |
m := PopUpMenu
|
74
|
4065 |
labels:(resources array:labels)
|
107
|
4066 |
selectors:selectors.
|
|
4067 |
|
|
4068 |
currentMethod notNil ifTrue:[
|
|
4069 |
currentMethod isPrivate ifTrue:[
|
|
4070 |
m disable:#methodMakePrivate
|
|
4071 |
].
|
|
4072 |
currentMethod isProtected ifTrue:[
|
|
4073 |
m disable:#methodMakeProtected
|
|
4074 |
].
|
|
4075 |
currentMethod isPublic ifTrue:[
|
|
4076 |
m disable:#methodMakePublic
|
|
4077 |
].
|
|
4078 |
].
|
117
|
4079 |
currentMethod notNil ifTrue:[
|
|
4080 |
(currentMethod code notNil
|
|
4081 |
or:[Compiler canCreateMachineCode not]) ifTrue:[
|
|
4082 |
m disable:#methodSTCCompile
|
|
4083 |
].
|
|
4084 |
currentMethod byteCode isNil ifTrue:[
|
|
4085 |
m disable:#methodDecompile
|
|
4086 |
].
|
|
4087 |
].
|
107
|
4088 |
^ m
|
74
|
4089 |
!
|
|
4090 |
|
|
4091 |
methodRemove
|
|
4092 |
"remove the current method"
|
|
4093 |
|
|
4094 |
self checkMethodSelected ifFalse:[^ self].
|
93
|
4095 |
actualClass removeSelector:(actualClass selectorAtMethod:currentMethod).
|
74
|
4096 |
currentMethod := currentSelector := nil.
|
|
4097 |
self updateMethodListWithScroll:false
|
|
4098 |
!
|
|
4099 |
|
107
|
4100 |
methodMakePublic
|
|
4101 |
"make the current method public.
|
|
4102 |
EXPERIMENTAL"
|
|
4103 |
|
|
4104 |
self checkMethodSelected ifFalse:[^ self].
|
|
4105 |
|
|
4106 |
currentMethod setToPublic.
|
|
4107 |
self updateMethodListWithScroll:false keepSelection:true.
|
|
4108 |
ObjectMemory flushCaches
|
|
4109 |
|
|
4110 |
!
|
|
4111 |
|
|
4112 |
methodMakeProtected
|
|
4113 |
"make the current method protected.
|
|
4114 |
EXPERIMENTAL"
|
|
4115 |
|
|
4116 |
self checkMethodSelected ifFalse:[^ self].
|
|
4117 |
|
|
4118 |
currentMethod setToProtected.
|
|
4119 |
self updateMethodListWithScroll:false keepSelection:true.
|
|
4120 |
ObjectMemory flushCaches
|
|
4121 |
|
|
4122 |
!
|
|
4123 |
|
|
4124 |
methodMakePrivate
|
|
4125 |
"make the current method private.
|
|
4126 |
EXPERIMENTAL"
|
|
4127 |
|
|
4128 |
self checkMethodSelected ifFalse:[^ self].
|
|
4129 |
|
|
4130 |
currentMethod setToPrivate.
|
|
4131 |
self updateMethodListWithScroll:false keepSelection:true.
|
|
4132 |
ObjectMemory flushCaches
|
|
4133 |
|
|
4134 |
!
|
|
4135 |
|
74
|
4136 |
methodSenders
|
|
4137 |
"launch an enterBox for selector to search for"
|
|
4138 |
|
|
4139 |
self askForSelectorTitle:'selector to browse senders of:'
|
|
4140 |
openWith:#browseAllCallsOn:
|
|
4141 |
!
|
|
4142 |
|
|
4143 |
methodImplementors
|
|
4144 |
"launch an enterBox for selector to search for"
|
|
4145 |
|
|
4146 |
self askForSelectorTitle:'selector to browse implementors of:'
|
|
4147 |
openWith:#browseImplementorsOf:
|
|
4148 |
!
|
|
4149 |
|
|
4150 |
methodLocalSenders
|
|
4151 |
"launch an enterBox for selector to search for in current class & subclasses"
|
|
4152 |
|
|
4153 |
self checkClassSelected ifFalse:[^ self].
|
|
4154 |
self askForSelectorTitle:'selector to browse local senders of:'
|
|
4155 |
openWith:#browseCallsOn:under:
|
|
4156 |
and:currentClass
|
|
4157 |
!
|
|
4158 |
|
|
4159 |
methodPrintOut
|
|
4160 |
"print out the current method"
|
|
4161 |
|
|
4162 |
|printStream|
|
|
4163 |
|
|
4164 |
self checkMethodSelected ifFalse:[^ self].
|
|
4165 |
|
|
4166 |
printStream := Printer new.
|
|
4167 |
actualClass printOutSource:(currentMethod source) on:printStream.
|
|
4168 |
printStream close
|
|
4169 |
!
|
|
4170 |
|
|
4171 |
methodLocalImplementors
|
|
4172 |
"launch an enterBox for selector to search for"
|
|
4173 |
|
|
4174 |
self checkClassSelected ifFalse:[^ self].
|
|
4175 |
self askForSelectorTitle:'selector to browse local implementors of:'
|
|
4176 |
openWith:#browseImplementorsOf:under:
|
|
4177 |
and:currentClass
|
|
4178 |
!
|
|
4179 |
|
|
4180 |
methodGlobalReferends
|
|
4181 |
"launch an enterBox for global symbol to search for"
|
|
4182 |
|
|
4183 |
self enterBoxForBrowseTitle:'global variable to browse users of:'
|
|
4184 |
action:[:aString |
|
|
4185 |
SystemBrowser browseReferendsOf:aString asSymbol
|
|
4186 |
]
|
|
4187 |
!
|
|
4188 |
|
|
4189 |
methodSpawn
|
|
4190 |
"create a new SystemBrowser browsing current method,
|
|
4191 |
or if the current selection is of the form 'class>>selector', spawan
|
|
4192 |
a browser on that method."
|
|
4193 |
|
|
4194 |
|s sel selSymbol clsName clsSymbol cls isMeta w|
|
|
4195 |
|
|
4196 |
classMethodListView notNil ifTrue:[
|
|
4197 |
s := classMethodListView selectionValue.
|
|
4198 |
clsName := self classFromClassMethodString:s.
|
|
4199 |
sel := self selectorFromClassMethodString:s.
|
|
4200 |
isMeta := false
|
|
4201 |
].
|
|
4202 |
|
|
4203 |
self extractClassAndSelectorFromSelectionInto:[:c :s :m |
|
|
4204 |
clsName := c.
|
|
4205 |
sel := s.
|
|
4206 |
isMeta := m
|
|
4207 |
].
|
|
4208 |
|
|
4209 |
(sel notNil and:[clsName notNil]) ifTrue:[
|
|
4210 |
(clsName knownAsSymbol and:[sel knownAsSymbol]) ifTrue:[
|
|
4211 |
clsSymbol := clsName asSymbol.
|
|
4212 |
(Smalltalk includesKey:clsSymbol) ifTrue:[
|
|
4213 |
cls := Smalltalk at:clsSymbol.
|
|
4214 |
isMeta ifTrue:[
|
|
4215 |
cls := cls class
|
|
4216 |
].
|
|
4217 |
cls isBehavior ifFalse:[
|
|
4218 |
cls := cls class
|
|
4219 |
].
|
|
4220 |
cls isBehavior ifTrue:[
|
|
4221 |
selSymbol := sel asSymbol.
|
|
4222 |
self withWaitCursorDo:[
|
|
4223 |
(cls implements:selSymbol) ifFalse:[
|
|
4224 |
cls := cls class.
|
|
4225 |
].
|
|
4226 |
(cls implements:selSymbol) ifTrue:[
|
|
4227 |
SystemBrowser browseClass:cls selector:selSymbol.
|
|
4228 |
^ self
|
|
4229 |
].
|
|
4230 |
w := ' does not implement #' , sel
|
|
4231 |
]
|
|
4232 |
] ifFalse:[
|
|
4233 |
w := ' is not a class'
|
|
4234 |
]
|
|
4235 |
] ifFalse:[
|
|
4236 |
w := ' is unknown'
|
|
4237 |
]
|
|
4238 |
] ifFalse:[
|
|
4239 |
w := ' and/or ' , sel , ' are unknown'
|
|
4240 |
].
|
|
4241 |
self warn:(clsName , w).
|
|
4242 |
^ self
|
|
4243 |
].
|
|
4244 |
|
|
4245 |
self checkMethodSelected ifFalse:[
|
|
4246 |
self warn:'select a method first'.
|
|
4247 |
^ self
|
|
4248 |
].
|
|
4249 |
|
|
4250 |
self withWaitCursorDo:[
|
|
4251 |
w := currentMethod who.
|
|
4252 |
SystemBrowser browseClass:(w at:1) selector:(w at:2)
|
|
4253 |
]
|
|
4254 |
!
|
|
4255 |
|
|
4256 |
methodChangeCategory
|
|
4257 |
"move the current method into another category -
|
|
4258 |
nothing done here, but a query for the new category.
|
|
4259 |
Remember the last category, to allow faster category change of a group of methods."
|
|
4260 |
|
|
4261 |
|box txt|
|
|
4262 |
|
|
4263 |
self checkMethodSelected ifFalse:[^ self].
|
|
4264 |
|
|
4265 |
actualClass isNil ifTrue:[
|
|
4266 |
box := self enterBoxTitle:'' okText:'change'.
|
|
4267 |
] ifFalse:[
|
|
4268 |
|someCategories|
|
|
4269 |
|
|
4270 |
someCategories := actualClass categories sort.
|
|
4271 |
box := self listBoxTitle:'' okText:'change' list:someCategories.
|
|
4272 |
].
|
|
4273 |
box title:('change category from ''' , currentMethod category , ''' to:').
|
|
4274 |
lastMethodCategory isNil ifTrue:[
|
|
4275 |
txt := currentMethod category.
|
|
4276 |
] ifFalse:[
|
|
4277 |
txt := lastMethodCategory
|
|
4278 |
].
|
|
4279 |
box initialText:txt.
|
|
4280 |
box action:[:aString |
|
|
4281 |
lastMethodCategory := aString.
|
|
4282 |
|
|
4283 |
currentMethod category:aString asSymbol.
|
|
4284 |
actualClass changed.
|
|
4285 |
currentMethod changed:#category.
|
|
4286 |
actualClass addChangeRecordForMethodCategory:currentMethod category:aString.
|
|
4287 |
self updateMethodCategoryListWithScroll:false.
|
|
4288 |
self updateMethodListWithScroll:false
|
|
4289 |
].
|
|
4290 |
box showAtPointer
|
|
4291 |
!
|
|
4292 |
|
|
4293 |
methodFileOut
|
|
4294 |
"file out the current method"
|
|
4295 |
|
|
4296 |
self checkMethodSelected ifFalse:[^ self].
|
|
4297 |
|
|
4298 |
self busyLabel:'saving:' with:currentSelector.
|
|
4299 |
Class fileOutErrorSignal handle:[:ex |
|
|
4300 |
self warn:'cannot create: %1' with:ex parameter.
|
|
4301 |
ex return
|
|
4302 |
] do:[
|
|
4303 |
actualClass fileOutMethod:currentMethod.
|
|
4304 |
].
|
|
4305 |
self normalLabel.
|
|
4306 |
!
|
|
4307 |
|
|
4308 |
methodStringSearch
|
|
4309 |
"launch an enterBox for string to search for"
|
|
4310 |
|
|
4311 |
self askForSelectorTitle:'string to search for in sources:'
|
|
4312 |
openWith:#browseForString:
|
|
4313 |
!
|
|
4314 |
|
|
4315 |
methodLocalStringSearch
|
|
4316 |
"launch an enterBox for string to search for"
|
|
4317 |
|
|
4318 |
self checkClassSelected ifFalse:[^ self].
|
|
4319 |
self askForSelectorTitle:'string to search for in local methods:'
|
|
4320 |
openWith:#browseForString:in:
|
|
4321 |
and:(currentClass withAllSubclasses)
|
|
4322 |
!
|
|
4323 |
|
|
4324 |
methodAproposSearch
|
|
4325 |
"launch an enterBox for a keyword search"
|
|
4326 |
|
|
4327 |
self askForSelectorTitle:'keyword to search for:'
|
|
4328 |
openWith:#aproposSearch:
|
|
4329 |
!
|
|
4330 |
|
|
4331 |
methodLocalAproposSearch
|
|
4332 |
"launch an enterBox for a local keyword search"
|
|
4333 |
|
|
4334 |
self askForSelectorTitle:'keyword to search for:'
|
|
4335 |
openWith:#aproposSearch:in:
|
|
4336 |
and:(currentClass withAllSubclasses)
|
|
4337 |
!
|
|
4338 |
|
|
4339 |
methodNewMethod
|
|
4340 |
"prepare for definition of a new method - put a template into
|
|
4341 |
code view and define accept-action to compile it"
|
|
4342 |
|
|
4343 |
currentClass isNil ifTrue:[
|
|
4344 |
^ self warn:'select/create a class first'.
|
|
4345 |
].
|
|
4346 |
currentMethodCategory isNil ifTrue:[
|
|
4347 |
^ self warn:'select/create a method category first'.
|
|
4348 |
].
|
|
4349 |
|
|
4350 |
currentMethod := currentSelector := nil.
|
|
4351 |
|
|
4352 |
methodListView deselect.
|
|
4353 |
codeView contents:(self template).
|
|
4354 |
codeView modified:false.
|
|
4355 |
|
|
4356 |
self setAcceptAndExplainActionsForMethod.
|
|
4357 |
!
|
|
4358 |
|
|
4359 |
methodBreakPoint
|
|
4360 |
"set a breakpoint on the current method"
|
|
4361 |
|
|
4362 |
currentSelector notNil ifTrue:[
|
|
4363 |
currentMethod := actualClass compiledMethodAt:currentSelector.
|
|
4364 |
currentMethod isWrapped ifFalse:[
|
93
|
4365 |
(currentMethod notNil and:[currentMethod isWrapped not]) ifTrue:[
|
|
4366 |
self commonTraceHelperWith:#trapMethod:
|
|
4367 |
]
|
74
|
4368 |
].
|
|
4369 |
]
|
|
4370 |
!
|
|
4371 |
|
|
4372 |
methodTrace
|
|
4373 |
"turn on tracing of the current method"
|
|
4374 |
|
107
|
4375 |
currentClass notNil ifTrue:[
|
|
4376 |
currentSelector notNil ifTrue:[
|
|
4377 |
currentMethod := actualClass compiledMethodAt:currentSelector
|
|
4378 |
]
|
|
4379 |
].
|
74
|
4380 |
|
93
|
4381 |
(currentMethod notNil and:[currentMethod isWrapped not]) ifTrue:[
|
|
4382 |
self commonTraceHelperWith:#traceMethod:
|
74
|
4383 |
]
|
|
4384 |
!
|
|
4385 |
|
93
|
4386 |
commonTraceHelperWith:aSelector
|
|
4387 |
currentMethod := MessageTracer perform:aSelector with:currentMethod.
|
107
|
4388 |
self updateMethodListWithScroll:false keepSelection:true.
|
93
|
4389 |
currentClass changed:#methodDictionary with:currentSelector.
|
|
4390 |
!
|
|
4391 |
|
74
|
4392 |
methodRemoveBreakOrTrace
|
|
4393 |
"turn off tracing of the current method"
|
|
4394 |
|
93
|
4395 |
(currentMethod notNil and:[currentMethod isWrapped]) ifTrue:[
|
|
4396 |
self commonTraceHelperWith:#unwrapMethod:
|
74
|
4397 |
]
|
|
4398 |
!
|
|
4399 |
|
|
4400 |
methodTraceSender
|
|
4401 |
"turn on tracing of the current method"
|
|
4402 |
|
93
|
4403 |
(currentMethod notNil and:[currentMethod isWrapped not]) ifTrue:[
|
|
4404 |
self commonTraceHelperWith:#traceMethodSender:
|
74
|
4405 |
]
|
105
|
4406 |
!
|
|
4407 |
|
|
4408 |
methodInspect
|
|
4409 |
"inspect the current method"
|
|
4410 |
|
|
4411 |
self checkMethodSelected ifFalse:[^ self].
|
|
4412 |
|
|
4413 |
currentMethod inspect.
|
110
|
4414 |
!
|
|
4415 |
|
117
|
4416 |
methodSTCCompile
|
|
4417 |
"compile the current method to machine code.
|
|
4418 |
This is not supported on all machines, and never supported in
|
|
4419 |
the demo version."
|
|
4420 |
|
|
4421 |
|prev|
|
|
4422 |
|
|
4423 |
self checkMethodSelected ifFalse:[^ self].
|
|
4424 |
prev := Compiler stcCompilation:#always.
|
|
4425 |
[
|
|
4426 |
codeView accept.
|
|
4427 |
] valueNowOrOnUnwindDo:[
|
|
4428 |
Compiler stcCompilation:prev
|
|
4429 |
].
|
|
4430 |
!
|
|
4431 |
|
110
|
4432 |
methodDecompile
|
|
4433 |
"decompile the current methods bytecodes.
|
|
4434 |
The Decompiler is delivered as an extra, and not normally
|
|
4435 |
avaliable with the system."
|
|
4436 |
|
|
4437 |
self checkMethodSelected ifFalse:[^ self].
|
|
4438 |
Decompiler notNil ifTrue:[
|
|
4439 |
Autoload autoloadFailedSignal handle:[:ex |
|
|
4440 |
ex return
|
|
4441 |
] do:[
|
|
4442 |
Decompiler autoload.
|
|
4443 |
].
|
|
4444 |
].
|
|
4445 |
Decompiler isLoaded ifFalse:[
|
117
|
4446 |
Smalltalk
|
|
4447 |
fileIn:'/phys/clam/claus/work/libcomp/not_delivered/Decomp.st'
|
|
4448 |
logged:false.
|
110
|
4449 |
].
|
|
4450 |
Decompiler isLoaded ifFalse:[
|
|
4451 |
^ self warn:'No decompiler available'.
|
|
4452 |
].
|
|
4453 |
|
|
4454 |
Decompiler decompile:currentMethod.
|
74
|
4455 |
! !
|
|
4456 |
|
|
4457 |
!BrowserView methodsFor:'method category list menu'!
|
|
4458 |
|
|
4459 |
methodCategoryMenu
|
|
4460 |
|labels selectors i|
|
|
4461 |
|
|
4462 |
currentClass isNil ifTrue:[
|
|
4463 |
methodCategoryListView flash.
|
|
4464 |
^ nil
|
|
4465 |
].
|
|
4466 |
currentMethodCategory isNil ifTrue:[
|
|
4467 |
labels := #(
|
|
4468 |
'find method here ...'
|
|
4469 |
'find method ...'
|
|
4470 |
'-'
|
|
4471 |
'new category ...'
|
85
|
4472 |
'copy category ...'
|
74
|
4473 |
'create access methods'
|
|
4474 |
).
|
|
4475 |
selectors := #(
|
|
4476 |
methodCategoryFindMethod
|
|
4477 |
methodCategoryFindAnyMethod
|
|
4478 |
nil
|
|
4479 |
methodCategoryNewCategory
|
85
|
4480 |
methodCategoryCopyCategory
|
74
|
4481 |
methodCategoryCreateAccessMethods
|
|
4482 |
).
|
|
4483 |
] ifFalse:[
|
|
4484 |
labels := #(
|
|
4485 |
'fileOut'
|
|
4486 |
'fileOut all'
|
|
4487 |
'printOut'
|
|
4488 |
'-'
|
|
4489 |
'SPAWN_METHODCATEGORY'
|
|
4490 |
'spawn category'
|
|
4491 |
'-'
|
|
4492 |
'find method here ...'
|
|
4493 |
'find method ...'
|
|
4494 |
'-'
|
|
4495 |
'new category ...'
|
|
4496 |
'copy category ...'
|
|
4497 |
'create access methods'
|
|
4498 |
'rename ...'
|
|
4499 |
'remove'
|
|
4500 |
).
|
|
4501 |
selectors := #(
|
|
4502 |
methodCategoryFileOut
|
|
4503 |
methodCategoryFileOutAll
|
|
4504 |
methodCategoryPrintOut
|
|
4505 |
nil
|
|
4506 |
methodCategorySpawn
|
|
4507 |
methodCategorySpawnCategory
|
|
4508 |
nil
|
|
4509 |
methodCategoryFindMethod
|
|
4510 |
methodCategoryFindAnyMethod
|
|
4511 |
nil
|
|
4512 |
methodCategoryNewCategory
|
|
4513 |
methodCategoryCopyCategory
|
|
4514 |
methodCategoryCreateAccessMethods
|
|
4515 |
methodCategoryRename
|
|
4516 |
methodCategoryRemove
|
|
4517 |
).
|
|
4518 |
].
|
|
4519 |
|
|
4520 |
showInstance ifFalse:[
|
|
4521 |
labels := labels copy.
|
|
4522 |
selectors := selectors copy.
|
|
4523 |
i := labels indexOf:'create access methods'.
|
|
4524 |
labels at:i put:'create documentation stubs'.
|
|
4525 |
selectors at:i put:#methodCategoryCreateDocumentationMethods
|
|
4526 |
].
|
|
4527 |
|
|
4528 |
^ PopUpMenu labels:(resources array:labels)
|
|
4529 |
selectors:selectors
|
|
4530 |
!
|
|
4531 |
|
|
4532 |
methodCategoryFindAnyMethod
|
|
4533 |
|box|
|
|
4534 |
|
|
4535 |
box := self enterBoxForSearchSelectorTitle:'method selector to search for:'.
|
|
4536 |
box action:[:aString | self switchToAnyMethodNamed:aString].
|
|
4537 |
box showAtPointer
|
|
4538 |
!
|
|
4539 |
|
|
4540 |
methodCategoryFindMethod
|
|
4541 |
|box|
|
|
4542 |
|
|
4543 |
box := self enterBoxForSearchSelectorTitle:'method selector to search for:'.
|
|
4544 |
box action:[:aString | self switchToMethodNamed:aString].
|
|
4545 |
box showAtPointer
|
|
4546 |
!
|
|
4547 |
|
|
4548 |
methodCategoryPrintOut
|
|
4549 |
|printStream|
|
|
4550 |
|
|
4551 |
self checkClassSelected ifFalse:[^ self].
|
|
4552 |
self whenMethodCategorySelected:[
|
|
4553 |
printStream := Printer new.
|
|
4554 |
actualClass printOutCategory:currentMethodCategory on:printStream.
|
|
4555 |
printStream close
|
|
4556 |
]
|
|
4557 |
!
|
|
4558 |
|
|
4559 |
methodCategoryFileOut
|
|
4560 |
"fileOut all methods in the selected methodcategory of
|
|
4561 |
the current class"
|
|
4562 |
|
|
4563 |
self checkClassSelected ifFalse:[^ self].
|
|
4564 |
self whenMethodCategorySelected:[
|
|
4565 |
self busyLabel:'saving: %1' with:currentClass name , '-' , currentMethodCategory.
|
|
4566 |
Class fileOutErrorSignal handle:[:ex |
|
|
4567 |
self warn:'cannot create: %1' with:ex parameter.
|
|
4568 |
ex return.
|
|
4569 |
] do:[
|
|
4570 |
actualClass fileOutCategory:currentMethodCategory.
|
|
4571 |
].
|
|
4572 |
self normalLabel.
|
|
4573 |
]
|
|
4574 |
!
|
|
4575 |
|
|
4576 |
methodCategorySpawn
|
|
4577 |
"create a new SystemBrowser browsing current method category"
|
|
4578 |
|
|
4579 |
currentMethodCategory notNil ifTrue:[
|
|
4580 |
self withWaitCursorDo:[
|
|
4581 |
SystemBrowser browseClass:actualClass
|
|
4582 |
methodCategory:currentMethodCategory
|
|
4583 |
]
|
|
4584 |
]
|
|
4585 |
!
|
|
4586 |
|
|
4587 |
methodCategoryNewCategory
|
|
4588 |
"show the enter box to add a new method category.
|
|
4589 |
Offer existing superclass categories in box to help avoiding
|
|
4590 |
useless typing."
|
|
4591 |
|
|
4592 |
|someCategories existingCategories box|
|
|
4593 |
|
|
4594 |
actualClass notNil ifTrue:[
|
|
4595 |
someCategories := actualClass allCategories
|
|
4596 |
] ifFalse:[
|
|
4597 |
"
|
|
4598 |
mhmh - offer some typical categories ...
|
|
4599 |
"
|
|
4600 |
showInstance ifTrue:[
|
|
4601 |
someCategories := #('accessing'
|
|
4602 |
'initialization'
|
|
4603 |
'private'
|
|
4604 |
'printing & storing'
|
|
4605 |
'queries'
|
|
4606 |
'testing'
|
|
4607 |
)
|
|
4608 |
] ifFalse:[
|
|
4609 |
someCategories := #(
|
|
4610 |
'documentation'
|
|
4611 |
'initialization'
|
|
4612 |
'instance creation'
|
|
4613 |
).
|
|
4614 |
].
|
|
4615 |
].
|
|
4616 |
someCategories sort.
|
|
4617 |
|
|
4618 |
"
|
|
4619 |
remove existing categories
|
|
4620 |
"
|
|
4621 |
existingCategories := methodCategoryListView list.
|
|
4622 |
existingCategories notNil ifTrue:[
|
|
4623 |
someCategories := someCategories select:[:cat | (existingCategories includes:cat) not].
|
|
4624 |
].
|
|
4625 |
|
|
4626 |
box := self listBoxTitle:'name of new method category:'
|
|
4627 |
okText:'create'
|
|
4628 |
list:someCategories.
|
|
4629 |
box action:[:aString | self newMethodCategory:aString].
|
|
4630 |
box showAtPointer
|
|
4631 |
|
|
4632 |
|
|
4633 |
|
|
4634 |
!
|
|
4635 |
|
|
4636 |
methodCategoryFileOutAll
|
|
4637 |
"fileOut all methods in the selected methodcategory of
|
|
4638 |
the current class"
|
|
4639 |
|
|
4640 |
|
|
4641 |
self whenMethodCategorySelected:[
|
|
4642 |
|fileName outStream|
|
|
4643 |
|
|
4644 |
fileName := currentMethodCategory , '.st'.
|
|
4645 |
fileName replaceAll:Character space by:$_.
|
|
4646 |
"
|
|
4647 |
this test allows a smalltalk to be built without Projects/ChangeSets
|
|
4648 |
"
|
|
4649 |
Project notNil ifTrue:[
|
|
4650 |
fileName := Project currentProjectDirectory , fileName.
|
|
4651 |
].
|
|
4652 |
"
|
|
4653 |
if file exists, save original in a .sav file
|
|
4654 |
"
|
|
4655 |
fileName asFilename exists ifTrue:[
|
|
4656 |
fileName asFilename copyTo:(fileName , '.sav')
|
|
4657 |
].
|
|
4658 |
outStream := FileStream newFileNamed:fileName.
|
|
4659 |
outStream isNil ifTrue:[
|
|
4660 |
^ self warn:'cannot create: %1' with:fileName
|
|
4661 |
].
|
|
4662 |
|
|
4663 |
self busyLabel:'saving: ' with:currentMethodCategory.
|
|
4664 |
Class fileOutErrorSignal handle:[:ex |
|
|
4665 |
self warn:'cannot create: %1' with:ex parameter.
|
|
4666 |
ex return
|
|
4667 |
] do:[
|
|
4668 |
Smalltalk allBehaviorsDo:[:class |
|
|
4669 |
|hasMethodsInThisCategory|
|
|
4670 |
|
|
4671 |
hasMethodsInThisCategory := false.
|
|
4672 |
class methodArray do:[:method |
|
|
4673 |
method category = currentMethodCategory ifTrue:[
|
|
4674 |
hasMethodsInThisCategory := true
|
|
4675 |
]
|
|
4676 |
].
|
|
4677 |
hasMethodsInThisCategory ifTrue:[
|
|
4678 |
class fileOutCategory:currentMethodCategory on:outStream.
|
|
4679 |
outStream cr
|
|
4680 |
].
|
|
4681 |
hasMethodsInThisCategory := false.
|
|
4682 |
class class methodArray do:[:method |
|
|
4683 |
method category = currentMethodCategory ifTrue:[
|
|
4684 |
hasMethodsInThisCategory := true
|
|
4685 |
]
|
|
4686 |
].
|
|
4687 |
hasMethodsInThisCategory ifTrue:[
|
|
4688 |
class class fileOutCategory:currentMethodCategory on:outStream.
|
|
4689 |
outStream cr
|
|
4690 |
]
|
|
4691 |
].
|
|
4692 |
].
|
|
4693 |
outStream close.
|
|
4694 |
self normalLabel.
|
|
4695 |
].
|
|
4696 |
!
|
|
4697 |
|
|
4698 |
methodCategorySpawnCategory
|
|
4699 |
"create a new SystemBrowser browsing all methods from all
|
|
4700 |
classes with same category as current method category"
|
|
4701 |
|
|
4702 |
self askAndBrowseMethodCategory:'category to browse methods:'
|
|
4703 |
action:[:aString |
|
|
4704 |
SystemBrowser browseMethodCategory:aString
|
|
4705 |
]
|
|
4706 |
!
|
|
4707 |
|
|
4708 |
methodCategoryCreateAccessMethods
|
|
4709 |
"create access methods for all instvars"
|
|
4710 |
|
|
4711 |
self checkClassSelected ifFalse:[^ self].
|
|
4712 |
|
|
4713 |
showInstance ifFalse:[
|
|
4714 |
self warn:'select instance - and try again'.
|
|
4715 |
^ self.
|
|
4716 |
].
|
|
4717 |
|
|
4718 |
self withWaitCursorDo:[
|
|
4719 |
|nm names source|
|
|
4720 |
|
|
4721 |
(variableListView notNil
|
|
4722 |
and:[(nm := variableListView selectionValue) notNil]) ifTrue:[
|
|
4723 |
names := Array with:nm
|
|
4724 |
] ifFalse:[
|
|
4725 |
names := currentClass instVarNames
|
|
4726 |
].
|
|
4727 |
names do:[:name |
|
|
4728 |
"check, if method is not already present"
|
|
4729 |
(currentClass implements:(name asSymbol)) ifFalse:[
|
|
4730 |
source := (name , '\ "return ' , name , '"\\ ^ ' , name) withCRs.
|
|
4731 |
Compiler compile:source forClass:currentClass inCategory:'accessing'.
|
|
4732 |
] ifTrue:[
|
|
4733 |
Transcript showCr:'method ''', name , ''' already present'
|
|
4734 |
].
|
|
4735 |
(currentClass implements:((name , ':') asSymbol)) ifFalse:[
|
|
4736 |
source := (name , ':something\ "set ' , name , '"\\ ' , name , ' := something.') withCRs.
|
|
4737 |
Compiler compile:source forClass:currentClass inCategory:'accessing'.
|
|
4738 |
] ifTrue:[
|
|
4739 |
Transcript showCr:'method ''', name , ':'' already present'
|
|
4740 |
].
|
|
4741 |
].
|
|
4742 |
self updateMethodCategoryListWithScroll:false.
|
|
4743 |
self updateMethodListWithScroll:false
|
|
4744 |
]
|
|
4745 |
!
|
|
4746 |
|
|
4747 |
methodCategoryCreateDocumentationMethods
|
|
4748 |
"create empty documentation methods"
|
|
4749 |
|
120
|
4750 |
|cls histStream|
|
74
|
4751 |
|
|
4752 |
self checkClassSelected ifFalse:[^ self].
|
|
4753 |
|
|
4754 |
cls := currentClass class.
|
|
4755 |
|
|
4756 |
self withWaitCursorDo:[
|
|
4757 |
|nm names source|
|
|
4758 |
|
120
|
4759 |
"/ add version method containing RCS template
|
|
4760 |
"/ but only if not already present.
|
|
4761 |
|
74
|
4762 |
(cls implements:#version) ifFalse:[
|
|
4763 |
Compiler compile:
|
|
4764 |
'version
|
|
4765 |
"
|
|
4766 |
$' , 'Header$
|
|
4767 |
"
|
120
|
4768 |
' forClass:cls
|
|
4769 |
inCategory:'documentation'.
|
74
|
4770 |
].
|
120
|
4771 |
|
|
4772 |
"/ add documentation method containing doc template
|
|
4773 |
"/ but only if not already present.
|
|
4774 |
|
74
|
4775 |
(cls implements:#documentation) ifFalse:[
|
|
4776 |
Compiler compile:
|
|
4777 |
'documentation
|
|
4778 |
"
|
|
4779 |
documentation to be added.
|
|
4780 |
"
|
120
|
4781 |
' forClass:cls
|
|
4782 |
inCategory:'documentation'.
|
74
|
4783 |
].
|
120
|
4784 |
|
|
4785 |
"/ add examples method containing examples template
|
|
4786 |
"/ but only if not already present.
|
|
4787 |
|
74
|
4788 |
(cls implements:#examples) ifFalse:[
|
|
4789 |
Compiler compile:
|
|
4790 |
'examples
|
|
4791 |
"
|
|
4792 |
examples to be added.
|
|
4793 |
"
|
120
|
4794 |
' forClass:cls
|
|
4795 |
inCategory:'documentation'.
|
74
|
4796 |
].
|
120
|
4797 |
|
|
4798 |
"/ add history method containing created-entry
|
|
4799 |
"/ but only if not already present.
|
|
4800 |
|
|
4801 |
(cls implements:#history) ifFalse:[
|
|
4802 |
histStream := ReadWriteStream on: String new.
|
|
4803 |
histStream nextPutAll: 'history'; cr.
|
|
4804 |
HistoryLine isBehavior ifTrue:[
|
|
4805 |
histStream nextPutAll: (HistoryLine created printString); cr.
|
|
4806 |
] ifFalse:[
|
|
4807 |
histStream cr.
|
|
4808 |
].
|
|
4809 |
Compiler compile:(histStream contents)
|
|
4810 |
forClass:cls
|
|
4811 |
inCategory:'documentation'.
|
|
4812 |
].
|
|
4813 |
|
95
|
4814 |
self instanceProtocol:false.
|
74
|
4815 |
self switchToMethodNamed:#documentation
|
|
4816 |
"/ self updateMethodCategoryListWithScroll:false.
|
|
4817 |
"/ self updateMethodListWithScroll:false
|
|
4818 |
]
|
|
4819 |
!
|
|
4820 |
|
|
4821 |
methodCategoryCopyCategory
|
|
4822 |
"show the enter box to copy from an existing method category"
|
|
4823 |
|
|
4824 |
|title box|
|
|
4825 |
|
|
4826 |
showInstance ifTrue:[
|
|
4827 |
title := 'class to copy instance method category from:'
|
|
4828 |
] ifFalse:[
|
|
4829 |
title := 'class to copy class method category from:'
|
|
4830 |
].
|
|
4831 |
|
|
4832 |
box := self listBoxTitle:title
|
|
4833 |
okText:'ok'
|
|
4834 |
list:(Smalltalk allClasses collect:[:cls | cls name]) asArray sort.
|
|
4835 |
|
|
4836 |
box action:[:aString | self copyMethodsFromClass:aString].
|
|
4837 |
box showAtPointer
|
|
4838 |
!
|
|
4839 |
|
|
4840 |
methodCategoryRename
|
|
4841 |
"launch an enterBox to rename current method category"
|
|
4842 |
|
|
4843 |
|box|
|
|
4844 |
|
|
4845 |
self checkMethodCategorySelected ifFalse:[^ self].
|
|
4846 |
|
|
4847 |
box := self enterBoxTitle:(resources string:'rename method category %1 to:' with:currentMethodCategory)
|
|
4848 |
okText:(resources at:'rename').
|
|
4849 |
box initialText:currentMethodCategory.
|
|
4850 |
box action:[:aString |
|
|
4851 |
actualClass renameCategory:currentMethodCategory to:aString.
|
|
4852 |
currentMethodCategory := aString.
|
|
4853 |
currentMethod := currentSelector := nil.
|
|
4854 |
self updateMethodCategoryList.
|
|
4855 |
self updateMethodListWithScroll:false
|
|
4856 |
].
|
|
4857 |
box showAtPointer
|
|
4858 |
!
|
|
4859 |
|
|
4860 |
methodCategoryRemove
|
|
4861 |
"show number of methods to remove and query user"
|
|
4862 |
|
|
4863 |
|count t box|
|
|
4864 |
|
|
4865 |
currentMethodCategory notNil ifTrue:[
|
|
4866 |
count := 0.
|
|
4867 |
actualClass methodArray do:[:aMethod |
|
|
4868 |
(aMethod category = currentMethodCategory) ifTrue:[
|
|
4869 |
count := count + 1
|
|
4870 |
]
|
|
4871 |
].
|
|
4872 |
(count == 0) ifTrue:[
|
|
4873 |
currentMethodCategory := nil.
|
|
4874 |
currentMethod := currentSelector := nil.
|
|
4875 |
self updateMethodCategoryListWithScroll:false.
|
|
4876 |
self updateMethodList
|
|
4877 |
] ifFalse:[
|
|
4878 |
(count == 1) ifTrue:[
|
|
4879 |
t := 'remove %1\(with 1 method) ?'
|
|
4880 |
] ifFalse:[
|
|
4881 |
t := 'remove %1\(with %2 methods) ?'
|
|
4882 |
].
|
|
4883 |
t := resources string:t with:currentMethodCategory with:count printString.
|
|
4884 |
t := t withCRs.
|
|
4885 |
|
|
4886 |
box := YesNoBox
|
|
4887 |
title:t
|
|
4888 |
yesText:(resources at:'remove')
|
|
4889 |
noText:(resources at:'abort').
|
|
4890 |
box confirm ifTrue:[
|
|
4891 |
actualClass methodArray do:[:aMethod |
|
|
4892 |
(aMethod category = currentMethodCategory) ifTrue:[
|
|
4893 |
actualClass
|
93
|
4894 |
removeSelector:(actualClass selectorAtMethod:aMethod)
|
74
|
4895 |
]
|
|
4896 |
].
|
|
4897 |
currentMethodCategory := nil.
|
|
4898 |
currentMethod := currentSelector := nil.
|
|
4899 |
self updateMethodCategoryList.
|
|
4900 |
self updateMethodList
|
|
4901 |
]
|
|
4902 |
]
|
|
4903 |
]
|
|
4904 |
! !
|
|
4905 |
|
|
4906 |
!BrowserView methodsFor:'variable list menu'!
|
|
4907 |
|
93
|
4908 |
variableListMenu
|
107
|
4909 |
|labels selectors|
|
93
|
4910 |
|
|
4911 |
currentClass isNil ifTrue:[
|
|
4912 |
variableListView flash.
|
|
4913 |
^ nil
|
|
4914 |
].
|
|
4915 |
|
|
4916 |
labels := #(
|
|
4917 |
'instvar refs ...'
|
|
4918 |
'classvar refs ...'
|
|
4919 |
'all instvar refs ...'
|
|
4920 |
'all classvar refs ...'
|
|
4921 |
'-'
|
|
4922 |
'instvar mods ...'
|
|
4923 |
'classvar mods ...'
|
|
4924 |
'all instvar mods ...'
|
|
4925 |
'all classvar mods ...'
|
|
4926 |
).
|
|
4927 |
selectors := #(
|
|
4928 |
instVarRefs
|
|
4929 |
classVarRefs
|
|
4930 |
allInstVarRefs
|
|
4931 |
allClassVarRefs
|
|
4932 |
nil
|
|
4933 |
instVarMods
|
|
4934 |
classVarMods
|
|
4935 |
allInstVarMods
|
|
4936 |
allClassVarMods
|
|
4937 |
).
|
|
4938 |
|
|
4939 |
(showInstance and:[variableListView hasSelection]) ifTrue:[
|
|
4940 |
labels := labels , #(
|
|
4941 |
'-'
|
|
4942 |
'type information'
|
|
4943 |
).
|
|
4944 |
selectors := selectors , #(
|
|
4945 |
nil
|
|
4946 |
varTypeInfo
|
|
4947 |
).
|
|
4948 |
].
|
|
4949 |
|
|
4950 |
^ PopUpMenu labels:(resources array:labels)
|
|
4951 |
selectors:selectors
|
74
|
4952 |
!
|
|
4953 |
|
|
4954 |
variableSelection:lineNr
|
|
4955 |
"variable selection changed"
|
|
4956 |
|
|
4957 |
|name idx|
|
|
4958 |
|
|
4959 |
name := variableListView selectionValue.
|
|
4960 |
name isNil ifTrue:[
|
|
4961 |
self unhilightMethodCategories.
|
|
4962 |
self unhilightMethods.
|
|
4963 |
self autoSearch:nil.
|
|
4964 |
^ self
|
|
4965 |
].
|
|
4966 |
|
|
4967 |
"
|
|
4968 |
first, check if the selected variable is really the one
|
|
4969 |
we get - reselect if its hidden (for example, a class variable
|
|
4970 |
with the same name could be defined in a subclass)
|
|
4971 |
"
|
|
4972 |
idx := variableListView list findLast:[:entry | entry = name].
|
|
4973 |
idx ~~ lineNr ifTrue:[
|
|
4974 |
"select it - user will see whats going on"
|
|
4975 |
variableListView selection:idx
|
|
4976 |
].
|
|
4977 |
|
|
4978 |
"search for methods in the current category, which access the selected
|
|
4979 |
variable, and highlight them"
|
|
4980 |
|
|
4981 |
self hilightMethodsInMethodCategoryList:true inMethodList:true.
|
|
4982 |
self autoSearch:name.
|
|
4983 |
!
|
|
4984 |
|
|
4985 |
enterBoxForVariableSearch:title
|
|
4986 |
|box sel|
|
|
4987 |
|
|
4988 |
box := self enterBoxForCodeSelectionTitle:title okText:'browse'.
|
|
4989 |
variableListView notNil ifTrue:[
|
|
4990 |
codeView hasSelection ifFalse:[
|
|
4991 |
(sel := variableListView selectionValue) notNil ifTrue:[
|
|
4992 |
(sel startsWith:'---') ifFalse:[
|
|
4993 |
box initialText:sel
|
|
4994 |
]
|
|
4995 |
]
|
|
4996 |
]
|
|
4997 |
].
|
|
4998 |
^ box
|
|
4999 |
!
|
|
5000 |
|
|
5001 |
allClassOrInstVarRefsTitle:title access:access mods:modifications
|
|
5002 |
"show an enterbox for instVar to search for"
|
|
5003 |
|
|
5004 |
self doClassMenu:[:currentClass |
|
|
5005 |
|box|
|
|
5006 |
|
|
5007 |
box := self enterBoxForVariableSearch:title.
|
93
|
5008 |
box action:[:aVariableName |
|
|
5009 |
|homeClass|
|
|
5010 |
|
|
5011 |
aVariableName isEmpty ifFalse:[
|
106
|
5012 |
windowGroup showCursor:Cursor questionMark.
|
93
|
5013 |
|
|
5014 |
homeClass := self findClassOfVariable:aVariableName accessWith:access.
|
108
|
5015 |
access == #classVarNames ifTrue:[
|
|
5016 |
SystemBrowser
|
|
5017 |
browseClassRefsTo:aVariableName
|
|
5018 |
under:homeClass
|
|
5019 |
modificationsOnly:modifications
|
|
5020 |
] ifFalse:[
|
|
5021 |
SystemBrowser
|
|
5022 |
browseInstRefsTo:aVariableName
|
|
5023 |
under:homeClass
|
|
5024 |
modificationsOnly:modifications
|
|
5025 |
]
|
74
|
5026 |
]
|
|
5027 |
].
|
|
5028 |
box showAtPointer
|
|
5029 |
]
|
|
5030 |
!
|
|
5031 |
|
|
5032 |
instVarRefsOrModsTitle:title mods:mods
|
|
5033 |
"show an enterbox for instvar to search for"
|
|
5034 |
|
|
5035 |
self doClassMenu:[:currentClass |
|
|
5036 |
|box|
|
|
5037 |
|
|
5038 |
box := self enterBoxForVariableSearch:title.
|
93
|
5039 |
box action:[:aString |
|
|
5040 |
aString notEmpty ifTrue:[
|
106
|
5041 |
windowGroup showCursor:(Cursor questionMark).
|
93
|
5042 |
SystemBrowser
|
|
5043 |
browseInstRefsTo:aString
|
|
5044 |
in:(Array with:currentClass)
|
|
5045 |
modificationsOnly:mods
|
74
|
5046 |
]
|
|
5047 |
].
|
|
5048 |
box showAtPointer
|
|
5049 |
]
|
|
5050 |
!
|
|
5051 |
|
|
5052 |
allClassVarMods
|
|
5053 |
"show an enterbox for classVar to search for"
|
|
5054 |
|
|
5055 |
self allClassOrInstVarRefsTitle:'class variable to browse modifications of:'
|
|
5056 |
access:#classVarNames
|
|
5057 |
mods:true
|
|
5058 |
!
|
|
5059 |
|
|
5060 |
instVarMods
|
|
5061 |
"show an enterbox for instVar to search for"
|
|
5062 |
|
|
5063 |
self instVarRefsOrModsTitle:'instance variable to browse modifications of:'
|
|
5064 |
mods:true
|
|
5065 |
!
|
|
5066 |
|
|
5067 |
instVarRefs
|
|
5068 |
"show an enterbox for instVar to search for"
|
|
5069 |
|
|
5070 |
self instVarRefsOrModsTitle:'instance variable to browse references to:'
|
|
5071 |
mods:false
|
|
5072 |
!
|
|
5073 |
|
|
5074 |
classVarRefsOrModsTitle:title mods:mods
|
|
5075 |
"show an enterbox for classVar to search for"
|
|
5076 |
|
|
5077 |
self doClassMenu:[:currentClass |
|
|
5078 |
|box|
|
|
5079 |
|
|
5080 |
box := self enterBoxForVariableSearch:title.
|
93
|
5081 |
box action:[:aString |
|
|
5082 |
aString notEmpty ifTrue:[
|
106
|
5083 |
windowGroup showCursor:(Cursor questionMark).
|
93
|
5084 |
SystemBrowser
|
|
5085 |
browseClassRefsTo:aString
|
|
5086 |
in:(Array with:currentClass)
|
|
5087 |
modificationsOnly:mods
|
74
|
5088 |
]
|
|
5089 |
].
|
|
5090 |
box showAtPointer
|
|
5091 |
]
|
|
5092 |
!
|
|
5093 |
|
|
5094 |
allInstVarRefs
|
|
5095 |
"show an enterbox for instVar to search for"
|
|
5096 |
|
|
5097 |
self allClassOrInstVarRefsTitle:'instance variable to browse references to:'
|
|
5098 |
access:#instVarNames
|
|
5099 |
mods:false
|
|
5100 |
!
|
|
5101 |
|
|
5102 |
classVarRefs
|
|
5103 |
"show an enterbox for classVar to search for"
|
|
5104 |
|
|
5105 |
self classVarRefsOrModsTitle:'class variable to browse references to:'
|
|
5106 |
mods:false
|
|
5107 |
!
|
|
5108 |
|
|
5109 |
classVarMods
|
|
5110 |
"show an enterbox for classVar to search for"
|
|
5111 |
|
|
5112 |
self classVarRefsOrModsTitle:'class variable to browse modifications of:'
|
|
5113 |
mods:true
|
|
5114 |
!
|
|
5115 |
|
|
5116 |
allInstVarMods
|
|
5117 |
"show an enterbox for instVar to search for"
|
|
5118 |
|
|
5119 |
self allClassOrInstVarRefsTitle:'instance variable to browse modifications of:'
|
|
5120 |
access:#instVarNames
|
|
5121 |
mods:true
|
|
5122 |
!
|
|
5123 |
|
|
5124 |
allClassVarRefs
|
|
5125 |
"show an enterbox for classVar to search for"
|
|
5126 |
|
|
5127 |
self allClassOrInstVarRefsTitle:'class variable to browse references to:'
|
|
5128 |
access:#classVarNames
|
|
5129 |
mods:false
|
93
|
5130 |
!
|
|
5131 |
|
|
5132 |
varTypeInfo
|
|
5133 |
"show typical usage of a variable"
|
|
5134 |
|
|
5135 |
|name idx classes values value msg cut names instCount subInstCount box
|
|
5136 |
searchClass|
|
|
5137 |
|
|
5138 |
name := variableListView selectionValue.
|
|
5139 |
name isNil ifTrue:[^ self].
|
|
5140 |
|
|
5141 |
searchClass := actualClass whichClassDefinesInstVar:name.
|
|
5142 |
|
|
5143 |
idx := searchClass instVarOffsetOf:name.
|
|
5144 |
idx isNil ifTrue:[^ self].
|
|
5145 |
|
|
5146 |
classes := IdentitySet new.
|
|
5147 |
values := IdentitySet new.
|
|
5148 |
instCount := 0.
|
|
5149 |
subInstCount := 0.
|
|
5150 |
searchClass allSubInstancesDo:[:i |
|
|
5151 |
|val|
|
|
5152 |
|
|
5153 |
val := i instVarAt:idx.
|
|
5154 |
val notNil ifTrue:[values add:val].
|
|
5155 |
classes add:val class.
|
|
5156 |
(i isMemberOf:searchClass) ifTrue:[
|
|
5157 |
instCount := instCount + 1.
|
|
5158 |
] ifFalse:[
|
|
5159 |
subInstCount := subInstCount + 1
|
|
5160 |
]
|
|
5161 |
].
|
|
5162 |
(instCount == 0 and:[subInstCount == 0]) ifTrue:[
|
|
5163 |
self warn:'there are currently no instances of ' , currentClass name.
|
|
5164 |
^ self
|
|
5165 |
].
|
|
5166 |
|
|
5167 |
instCount ~~ 0 ifTrue:[
|
108
|
5168 |
msg := 'in (currently: ' , instCount printString,') instances '.
|
93
|
5169 |
subInstCount ~~ 0 ifTrue:[
|
|
5170 |
msg := msg , 'and '
|
|
5171 |
]
|
108
|
5172 |
] ifFalse:[
|
|
5173 |
msg := 'in '.
|
93
|
5174 |
].
|
|
5175 |
subInstCount ~~ 0 ifTrue:[
|
|
5176 |
msg := msg , '(currently: ' , subInstCount printString, ') derived instances '
|
|
5177 |
].
|
108
|
5178 |
msg := msg, 'of ' , searchClass name , ',\'.
|
93
|
5179 |
msg := msg , name , ' '.
|
|
5180 |
((values size == 1)
|
|
5181 |
or:[classes size == 1 and:[classes first == UndefinedObject]]) ifTrue:[
|
|
5182 |
values size == 1 ifTrue:[value := values first].
|
109
|
5183 |
(value isNumber or:[value isString]) ifTrue:[
|
93
|
5184 |
msg := msg , 'is always the same:\\ ' ,
|
|
5185 |
value class name , ' (' , value storeString , ')'.
|
|
5186 |
] ifFalse:[
|
|
5187 |
(value isNil or:[value == true or:[value == false]]) ifTrue:[
|
|
5188 |
msg := msg , 'is always:\\ ' ,
|
|
5189 |
value printString.
|
|
5190 |
] ifFalse:[
|
|
5191 |
msg := msg , 'is always the same:\\'.
|
|
5192 |
msg := msg , ' ' , value class name.
|
|
5193 |
value isLiteral ifTrue:[
|
|
5194 |
msg := msg , ' (' , value storeString , ')'
|
|
5195 |
]
|
|
5196 |
]
|
|
5197 |
]
|
|
5198 |
] ifFalse:[
|
|
5199 |
classes size == 1 ifTrue:[
|
|
5200 |
msg := msg , 'is always:\\'.
|
|
5201 |
msg := msg , ' ' , classes first name , '\'.
|
|
5202 |
] ifFalse:[
|
|
5203 |
msg := msg , 'is one of:\\'.
|
|
5204 |
classes := classes asOrderedCollection.
|
|
5205 |
classes size > 20 ifTrue:[
|
|
5206 |
classes := classes copyFrom:1 to:20.
|
|
5207 |
cut := true
|
|
5208 |
] ifFalse:[
|
|
5209 |
cut := false.
|
|
5210 |
].
|
|
5211 |
names := classes collect:[:cls |
|
|
5212 |
|nm|
|
|
5213 |
cls == UndefinedObject ifTrue:[
|
|
5214 |
'nil'
|
|
5215 |
] ifFalse:[
|
|
5216 |
cls == True ifTrue:[
|
|
5217 |
'true'
|
|
5218 |
] ifFalse:[
|
|
5219 |
cls == False ifTrue:[
|
|
5220 |
'false'
|
|
5221 |
] ifFalse:[
|
|
5222 |
cls name
|
|
5223 |
]
|
|
5224 |
]
|
|
5225 |
].
|
|
5226 |
].
|
|
5227 |
names sort.
|
|
5228 |
names do:[:nm |
|
|
5229 |
msg := msg , ' ' , nm , '\'.
|
|
5230 |
].
|
|
5231 |
]
|
|
5232 |
].
|
|
5233 |
|
|
5234 |
box := InfoBox title:msg withCRs.
|
|
5235 |
box label:'variable type information'.
|
|
5236 |
box showAtPointer
|
74
|
5237 |
! !
|
|
5238 |
|
|
5239 |
!BrowserView methodsFor:'class-method list menu'!
|
|
5240 |
|
|
5241 |
classMethodMenu
|
|
5242 |
|labels selectors|
|
|
5243 |
|
|
5244 |
labels := #(
|
|
5245 |
'fileOut'
|
|
5246 |
'fileOut all'
|
|
5247 |
'printOut'
|
|
5248 |
'-'
|
|
5249 |
'spawn'
|
|
5250 |
'spawn class'
|
|
5251 |
'spawn full protocol'
|
|
5252 |
'spawn hierarchy'
|
|
5253 |
'-'
|
|
5254 |
'senders ...'
|
|
5255 |
'implementors ...'
|
|
5256 |
'globals ...'
|
|
5257 |
"/ '-'
|
|
5258 |
"/ 'breakpoint'
|
|
5259 |
"/ 'trace'
|
|
5260 |
"/ 'trace sender'
|
92
|
5261 |
'-'
|
|
5262 |
'remove'
|
74
|
5263 |
).
|
|
5264 |
|
|
5265 |
selectors := #(
|
|
5266 |
methodFileOut
|
|
5267 |
classMethodFileOutAll
|
|
5268 |
methodPrintOut
|
|
5269 |
nil
|
|
5270 |
methodSpawn
|
|
5271 |
classSpawn
|
|
5272 |
classSpawnFullProtocol
|
|
5273 |
classSpawnHierarchy
|
|
5274 |
nil
|
|
5275 |
methodSenders
|
|
5276 |
methodImplementors
|
|
5277 |
methodGlobalReferends
|
|
5278 |
"/ nil
|
|
5279 |
"/ methodBreakPoint
|
|
5280 |
"/ methodTrace
|
|
5281 |
"/ methodTraceSender
|
92
|
5282 |
nil
|
|
5283 |
methodRemove
|
74
|
5284 |
).
|
|
5285 |
|
|
5286 |
^ PopUpMenu labels:(resources array:labels)
|
|
5287 |
selectors:selectors
|
|
5288 |
!
|
|
5289 |
|
|
5290 |
classMethodFileOutAll
|
|
5291 |
"fileout all methods into one source file"
|
|
5292 |
|
|
5293 |
|list classString selectorString cls mth outStream fileName append
|
|
5294 |
fileBox|
|
|
5295 |
|
|
5296 |
append := false.
|
|
5297 |
fileBox := FileSaveBox
|
|
5298 |
title:(resources string:'save methodss in:')
|
|
5299 |
okText:(resources string:'save')
|
|
5300 |
abortText:(resources string:'cancel')
|
|
5301 |
action:[:fName | fileName := fName].
|
|
5302 |
fileBox appendAction:[:fName | fileName := fName. append := true].
|
|
5303 |
fileBox initialText:'some_methods.st'.
|
|
5304 |
Project notNil ifTrue:[
|
|
5305 |
fileBox directory:Project currentProjectDirectory
|
|
5306 |
].
|
|
5307 |
fileBox showAtPointer.
|
|
5308 |
|
|
5309 |
fileName notNil ifTrue:[
|
|
5310 |
"
|
|
5311 |
if file exists, save original in a .sav file
|
|
5312 |
"
|
|
5313 |
fileName asFilename exists ifTrue:[
|
|
5314 |
fileName asFilename copyTo:(fileName , '.sav')
|
|
5315 |
].
|
|
5316 |
append ifTrue:[
|
|
5317 |
outStream := FileStream appendingOldFileNamed:fileName
|
|
5318 |
] ifFalse:[
|
|
5319 |
outStream := FileStream newFileNamed:fileName.
|
|
5320 |
].
|
|
5321 |
outStream isNil ifTrue:[
|
|
5322 |
^ self warn:'cannot create: %1' with:fileName
|
|
5323 |
].
|
|
5324 |
self withWaitCursorDo:[
|
|
5325 |
list := classMethodListView list.
|
|
5326 |
list do:[:line |
|
|
5327 |
self busyLabel:'writing: ' with:line.
|
|
5328 |
|
|
5329 |
classString := self classFromClassMethodString:line.
|
|
5330 |
selectorString := self selectorFromClassMethodString:line.
|
|
5331 |
|
|
5332 |
((classString ~= 'Metaclass') and:[classString endsWith:'class']) ifTrue:[
|
106
|
5333 |
classString := classString copyWithoutLast:5 "copyTo:(classString size - 5)".
|
74
|
5334 |
cls := (Smalltalk at:classString asSymbol).
|
|
5335 |
cls := cls class
|
|
5336 |
] ifFalse:[
|
|
5337 |
cls := (Smalltalk at:classString asSymbol).
|
|
5338 |
].
|
|
5339 |
|
|
5340 |
cls isNil ifTrue:[
|
|
5341 |
self warn:'oops class %1 is gone' with:classString
|
|
5342 |
] ifFalse:[
|
|
5343 |
mth := cls compiledMethodAt:(selectorString asSymbol).
|
|
5344 |
Class fileOutErrorSignal handle:[:ex |
|
|
5345 |
|box|
|
93
|
5346 |
box := YesNoBox
|
|
5347 |
title:('fileOut error: '
|
|
5348 |
, ex errorString
|
|
5349 |
, '\\continue anyway ?') withCRs
|
|
5350 |
yesText:'continue'
|
|
5351 |
noText:'abort'.
|
|
5352 |
box confirm ifTrue:[
|
74
|
5353 |
ex proceed
|
|
5354 |
].
|
|
5355 |
self normalLabel.
|
|
5356 |
^ self
|
|
5357 |
] do:[
|
|
5358 |
cls fileOutMethod:mth on:outStream.
|
|
5359 |
]
|
|
5360 |
]
|
|
5361 |
].
|
|
5362 |
outStream close.
|
|
5363 |
self normalLabel.
|
|
5364 |
]
|
|
5365 |
]
|
|
5366 |
! !
|
|
5367 |
|
|
5368 |
BrowserView initialize!
|