1522
|
1 |
"{ Package: 'stx:libtool2' }"
|
|
2 |
|
|
3 |
ApplicationModel subclass:#MethodFinderWindow
|
|
4 |
instanceVariableNames:'argumentsEditor messageAnswerEditor receiverEditor receiver
|
|
5 |
resultSelectors arg2BoxVisible arg1BoxVisible arg4BoxVisible
|
|
6 |
arg3BoxVisible argCountHolder argCountList argument1Editor
|
|
7 |
argument2Editor argument3Editor argument4Editor resultSelected
|
|
8 |
lookAtResultEditor'
|
|
9 |
classVariableNames:''
|
|
10 |
poolDictionaries:''
|
1525
|
11 |
category:'MethodFinder'
|
1522
|
12 |
!
|
|
13 |
|
1530
|
14 |
!MethodFinderWindow class methodsFor:'documentation'!
|
|
15 |
|
|
16 |
documentation
|
|
17 |
"
|
|
18 |
ported from Squeak and GUI enhanced by James
|
|
19 |
"
|
|
20 |
! !
|
1522
|
21 |
|
|
22 |
!MethodFinderWindow class methodsFor:'interface specs'!
|
|
23 |
|
|
24 |
windowSpec
|
|
25 |
"This resource specification was automatically generated
|
|
26 |
by the UIPainter of ST/X."
|
|
27 |
|
|
28 |
"Do not manually edit this!! If it is corrupted,
|
|
29 |
the UIPainter may not be able to read the specification."
|
|
30 |
|
|
31 |
"
|
|
32 |
UIPainter new openOnClass:MethodFinderWindow andSelector:#windowSpec
|
|
33 |
MethodFinderWindow new openInterface:#windowSpec
|
|
34 |
MethodFinderWindow open
|
|
35 |
"
|
|
36 |
|
|
37 |
<resource: #canvas>
|
|
38 |
|
|
39 |
^
|
|
40 |
#(#FullSpec
|
|
41 |
#name: #windowSpec
|
|
42 |
#window:
|
|
43 |
#(#WindowSpec
|
|
44 |
#label: 'MethodFinder'
|
|
45 |
#name: 'MethodFinder'
|
1525
|
46 |
#min: #(#Point nil nil)
|
|
47 |
#max: #(#Point nil nil)
|
1530
|
48 |
#bounds: #(#Rectangle 13 23 563 423)
|
1525
|
49 |
#menu: #menu
|
|
50 |
#forceRecursiveBackground: false
|
1522
|
51 |
)
|
|
52 |
#component:
|
|
53 |
#(#SpecCollection
|
|
54 |
#collection: #(
|
1525
|
55 |
#(#ViewSpec
|
1530
|
56 |
#name: 'Box6'
|
|
57 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
|
|
58 |
#level: 1
|
1522
|
59 |
#component:
|
|
60 |
#(#SpecCollection
|
|
61 |
#collection: #(
|
1530
|
62 |
#(#SequenceViewSpec
|
|
63 |
#name: 'List1'
|
|
64 |
#layout: #(#LayoutFrame 0 0 0 0.5 0 0.65 0 1)
|
|
65 |
#hasHorizontalScrollBar: true
|
|
66 |
#hasVerticalScrollBar: true
|
|
67 |
#autoHideScrollBars: true
|
|
68 |
#valueChangeSelector: #updateImplementorsOf:
|
1525
|
69 |
#useIndex: true
|
1530
|
70 |
#sequenceList: #resultHolder
|
1525
|
71 |
)
|
1530
|
72 |
#(#SequenceViewSpec
|
|
73 |
#name: 'List2'
|
|
74 |
#layout: #(#LayoutFrame 0 0.65 0 0 0 1 0 1)
|
|
75 |
#model: #selectedClassOfResultHolder
|
|
76 |
#menu: #implementorListMenu
|
|
77 |
#hasHorizontalScrollBar: true
|
|
78 |
#hasVerticalScrollBar: true
|
|
79 |
#autoHideScrollBars: true
|
|
80 |
#doubleClickSelector: #openBrowserOn:
|
|
81 |
#useIndex: false
|
|
82 |
#sequenceList: #classOfResultHolder
|
1525
|
83 |
)
|
1530
|
84 |
#(#ViewSpec
|
|
85 |
#name: 'Box4'
|
|
86 |
#layout: #(#LayoutFrame 0 0 0 0 0 0.65 -25 0.5)
|
1522
|
87 |
#component:
|
|
88 |
#(#SpecCollection
|
|
89 |
#collection: #(
|
1530
|
90 |
#(#LabelSpec
|
|
91 |
#label: 'Receiver'
|
|
92 |
#name: 'ReceiverLabel'
|
|
93 |
#layout: #(#LayoutFrame -4 0.0162791 0 0 -4 0.293023 24 0)
|
|
94 |
#translateLabel: true
|
|
95 |
#adjust: #left
|
1525
|
96 |
)
|
1530
|
97 |
#(#ComboListSpec
|
|
98 |
#name: 'allowedArgments'
|
|
99 |
#layout: #(#LayoutFrame 0 0.339535 1 0 0 0.653488 23 0)
|
|
100 |
#model: #argCountHolder
|
|
101 |
#comboList: #argCountList
|
|
102 |
#useIndex: true
|
|
103 |
)
|
|
104 |
#(#LabelSpec
|
|
105 |
#label: 'MessageAnswer'
|
|
106 |
#name: 'MessageAnswerLabel'
|
|
107 |
#layout: #(#LayoutFrame 0 0.6693 0 0 0 0.99023 24 0)
|
|
108 |
#translateLabel: true
|
|
109 |
#adjust: #left
|
|
110 |
)
|
|
111 |
#(#HorizontalPanelViewSpec
|
|
112 |
#name: 'HorizontalPanel1'
|
|
113 |
#layout: #(#LayoutFrame 0 0 25 0 0 1 0 1)
|
1525
|
114 |
#horizontalLayout: #fit
|
|
115 |
#verticalLayout: #fit
|
|
116 |
#horizontalSpace: 3
|
|
117 |
#verticalSpace: 3
|
1522
|
118 |
#component:
|
|
119 |
#(#SpecCollection
|
|
120 |
#collection: #(
|
1530
|
121 |
#(#WorkspaceSpec
|
|
122 |
#name: 'ReceiverEditor'
|
|
123 |
#tabable: true
|
|
124 |
#hasHorizontalScrollBar: true
|
|
125 |
#hasVerticalScrollBar: true
|
|
126 |
#miniScrollerHorizontal: true
|
|
127 |
#miniScrollerVertical: true
|
|
128 |
#autoHideScrollBars: true
|
|
129 |
#extent: #(#Point 116 149)
|
|
130 |
#postBuildCallback: #receiverWidgetCreated:
|
|
131 |
)
|
|
132 |
#(#VerticalPanelViewSpec
|
|
133 |
#name: 'VerticalPanel1'
|
|
134 |
#horizontalLayout: #fit
|
|
135 |
#verticalLayout: #fit
|
|
136 |
#horizontalSpace: 3
|
|
137 |
#verticalSpace: 3
|
1525
|
138 |
#component:
|
|
139 |
#(#SpecCollection
|
|
140 |
#collection: #(
|
1530
|
141 |
#(#ViewSpec
|
|
142 |
#name: 'Box1'
|
|
143 |
#visibilityChannel: #arg1BoxVisible
|
|
144 |
#component:
|
|
145 |
#(#SpecCollection
|
|
146 |
#collection: #(
|
|
147 |
#(#WorkspaceSpec
|
|
148 |
#name: 'Arg1Editor'
|
|
149 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
|
|
150 |
#tabable: true
|
|
151 |
#hasHorizontalScrollBar: true
|
|
152 |
#hasVerticalScrollBar: true
|
|
153 |
#miniScrollerHorizontal: true
|
|
154 |
#miniScrollerVertical: true
|
|
155 |
#autoHideScrollBars: true
|
|
156 |
#postBuildCallback: #argument1WidgetCreated:
|
|
157 |
)
|
|
158 |
)
|
|
159 |
|
|
160 |
)
|
|
161 |
#extent: #(#Point 117 48)
|
|
162 |
)
|
|
163 |
#(#ViewSpec
|
|
164 |
#name: 'Box2'
|
|
165 |
#visibilityChannel: #arg2BoxVisible
|
|
166 |
#component:
|
|
167 |
#(#SpecCollection
|
|
168 |
#collection: #(
|
|
169 |
#(#WorkspaceSpec
|
|
170 |
#name: 'TextEditor5'
|
|
171 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
|
|
172 |
#tabable: true
|
|
173 |
#hasHorizontalScrollBar: true
|
|
174 |
#hasVerticalScrollBar: true
|
|
175 |
#miniScrollerHorizontal: true
|
|
176 |
#miniScrollerVertical: true
|
|
177 |
#autoHideScrollBars: true
|
|
178 |
#postBuildCallback: #argument2WidgetCreated:
|
|
179 |
)
|
|
180 |
)
|
|
181 |
|
|
182 |
)
|
|
183 |
#extent: #(#Point 117 47)
|
|
184 |
)
|
|
185 |
#(#ViewSpec
|
|
186 |
#name: 'Box3'
|
|
187 |
#visibilityChannel: #arg3BoxVisible
|
|
188 |
#component:
|
|
189 |
#(#SpecCollection
|
|
190 |
#collection: #(
|
|
191 |
#(#WorkspaceSpec
|
|
192 |
#name: 'TextEditor6'
|
|
193 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
|
|
194 |
#tabable: true
|
|
195 |
#hasHorizontalScrollBar: true
|
|
196 |
#hasVerticalScrollBar: true
|
|
197 |
#miniScrollerHorizontal: true
|
|
198 |
#miniScrollerVertical: true
|
|
199 |
#autoHideScrollBars: true
|
|
200 |
#postBuildCallback: #argument3WidgetCreated:
|
|
201 |
)
|
|
202 |
)
|
|
203 |
|
|
204 |
)
|
|
205 |
#extent: #(#Point 117 48)
|
1525
|
206 |
)
|
|
207 |
)
|
|
208 |
|
|
209 |
)
|
1530
|
210 |
#extent: #(#Point 117 149)
|
1525
|
211 |
)
|
1530
|
212 |
#(#WorkspaceSpec
|
|
213 |
#name: 'AnswerEditor'
|
|
214 |
#tabable: true
|
|
215 |
#hasHorizontalScrollBar: true
|
|
216 |
#hasVerticalScrollBar: true
|
|
217 |
#miniScrollerHorizontal: true
|
|
218 |
#miniScrollerVertical: true
|
|
219 |
#autoHideScrollBars: true
|
|
220 |
#extent: #(#Point 117 149)
|
|
221 |
#postBuildCallback: #messageAnswerWidgetCreated:
|
1522
|
222 |
)
|
|
223 |
)
|
|
224 |
|
|
225 |
)
|
|
226 |
)
|
1530
|
227 |
)
|
|
228 |
|
|
229 |
)
|
|
230 |
)
|
|
231 |
#(#ViewSpec
|
|
232 |
#name: 'Box5'
|
|
233 |
#layout: #(#LayoutFrame 53 0.224737 -23 0.5 0 0.65 0 0.5)
|
|
234 |
#component:
|
|
235 |
#(#SpecCollection
|
|
236 |
#collection: #(
|
|
237 |
#(#ActionButtonSpec
|
|
238 |
#label: 'Clear'
|
|
239 |
#name: 'Button2'
|
|
240 |
#layout: #(#LayoutFrame 0 0 0 0 -5 0.5 0 1)
|
|
241 |
#translateLabel: true
|
|
242 |
#model: #clear
|
|
243 |
)
|
|
244 |
#(#ActionButtonSpec
|
|
245 |
#label: 'Search'
|
|
246 |
#name: 'Button1'
|
|
247 |
#layout: #(#LayoutFrame 5 0.5 0 0 0 1 0 1)
|
|
248 |
#translateLabel: true
|
1525
|
249 |
#tabable: true
|
1530
|
250 |
#model: #search
|
1522
|
251 |
)
|
|
252 |
)
|
|
253 |
|
|
254 |
)
|
|
255 |
)
|
|
256 |
)
|
|
257 |
|
|
258 |
)
|
|
259 |
)
|
|
260 |
)
|
|
261 |
|
|
262 |
)
|
|
263 |
)
|
1530
|
264 |
|
|
265 |
"Modified: / 9.11.2001 / 08:45:48 / cg"
|
1522
|
266 |
! !
|
|
267 |
|
1525
|
268 |
!MethodFinderWindow class methodsFor:'menu specs'!
|
|
269 |
|
1529
|
270 |
implementorListMenu
|
|
271 |
"This resource specification was automatically generated
|
|
272 |
by the MenuEditor of ST/X."
|
|
273 |
|
|
274 |
"Do not manually edit this!! If it is corrupted,
|
|
275 |
the MenuEditor may not be able to read the specification."
|
|
276 |
|
|
277 |
"
|
|
278 |
MenuEditor new openOnClass:MethodFinderWindow andSelector:#implementorListMenu
|
|
279 |
(Menu new fromLiteralArrayEncoding:(MethodFinderWindow implementorListMenu)) startUp
|
|
280 |
"
|
|
281 |
|
|
282 |
<resource: #menu>
|
|
283 |
|
|
284 |
^
|
|
285 |
#(#Menu
|
|
286 |
#(
|
|
287 |
#(#MenuItem
|
|
288 |
#label: 'Browse'
|
|
289 |
#translateLabel: true
|
|
290 |
#value: #openBrowserOnSelectedItem
|
|
291 |
)
|
|
292 |
)
|
|
293 |
nil
|
|
294 |
nil
|
|
295 |
)
|
|
296 |
!
|
|
297 |
|
1525
|
298 |
menu
|
|
299 |
"This resource specification was automatically generated
|
|
300 |
by the MenuEditor of ST/X."
|
|
301 |
|
|
302 |
"Do not manually edit this!! If it is corrupted,
|
|
303 |
the MenuEditor may not be able to read the specification."
|
|
304 |
|
|
305 |
"
|
|
306 |
MenuEditor new openOnClass:MethodFinderWindow andSelector:#menu
|
|
307 |
(Menu new fromLiteralArrayEncoding:(MethodFinderWindow menu)) startUp
|
|
308 |
"
|
|
309 |
|
|
310 |
<resource: #menu>
|
|
311 |
|
|
312 |
^
|
|
313 |
#(#Menu
|
|
314 |
#(
|
|
315 |
#(#MenuItem
|
|
316 |
#label: '&File'
|
|
317 |
#activeHelpKey: #file
|
|
318 |
#submenu:
|
|
319 |
#(#Menu
|
|
320 |
#(
|
|
321 |
#(#MenuItem
|
|
322 |
#label: 'Exit'
|
|
323 |
#value: #closeRequest
|
|
324 |
#activeHelpKey: #fileExit
|
|
325 |
)
|
|
326 |
)
|
|
327 |
nil
|
|
328 |
nil
|
|
329 |
)
|
|
330 |
)
|
|
331 |
#(#MenuItem
|
|
332 |
#label: 'Help'
|
|
333 |
#startGroup: #right
|
|
334 |
#submenu:
|
|
335 |
#(#Menu
|
|
336 |
#(
|
|
337 |
#(#MenuItem
|
|
338 |
#label: 'Documentation'
|
|
339 |
#value: #openHTMLDocumentation
|
|
340 |
#activeHelpKey: #helpTutorial
|
|
341 |
)
|
|
342 |
#(#MenuItem
|
|
343 |
#label: 'About MenuEditor...'
|
|
344 |
#value: #openAboutThisApplication
|
|
345 |
#activeHelpKey: #aboutThisAppliaction
|
|
346 |
)
|
|
347 |
)
|
|
348 |
nil
|
|
349 |
nil
|
|
350 |
)
|
|
351 |
)
|
|
352 |
)
|
|
353 |
nil
|
|
354 |
nil
|
|
355 |
)
|
|
356 |
! !
|
|
357 |
|
1522
|
358 |
!MethodFinderWindow methodsFor:'accessing'!
|
|
359 |
|
|
360 |
receiver
|
1525
|
361 |
"Return a copy of the value of the instance variable 'receiver' "
|
1522
|
362 |
|
|
363 |
^ receiver copy
|
|
364 |
! !
|
|
365 |
|
|
366 |
!MethodFinderWindow methodsFor:'actions'!
|
|
367 |
|
|
368 |
argumentEditorsContents
|
1525
|
369 |
|
|
370 |
"Determine how many text editors of the arguments are used and store the result
|
|
371 |
as argCounter. The result being the minimum between how many editors have
|
|
372 |
expressions in and how many are displayed.
|
|
373 |
|
|
374 |
Add each argument string (key)and the evaluated version (value) to an Ordered Dictionary
|
|
375 |
from each of the text editors.
|
|
376 |
|
|
377 |
Return the OrderedDictionary with the expressions from all the text editors. "
|
|
378 |
|
1522
|
379 |
| tempArguments argCounter tempArgument1Editor tempArgument2Editor tempArgument3Editor tempArgument4Editor
|
|
380 |
associationKey associationValue|
|
|
381 |
|
|
382 |
argCounter:=0.
|
|
383 |
|
|
384 |
tempArgument1Editor:= (self cleanInputs: argument1Editor contents).
|
|
385 |
tempArgument2Editor:= (self cleanInputs: argument2Editor contents).
|
|
386 |
tempArgument3Editor:= (self cleanInputs: argument3Editor contents).
|
|
387 |
|
|
388 |
tempArgument1Editor = '' ifFalse:[argCounter:=argCounter +1].
|
|
389 |
tempArgument2Editor = '' ifFalse:[argCounter:=argCounter +1].
|
|
390 |
tempArgument3Editor = '' ifFalse:[argCounter:=argCounter +1].
|
|
391 |
|
|
392 |
|
|
393 |
argCounter:= (argCounter min: (self argCountHolder value -1)).
|
|
394 |
tempArguments:= OrderedDictionary new:argCounter.
|
|
395 |
|
|
396 |
(argCounter value >= 1)
|
|
397 |
ifTrue:[associationValue:= (Compiler evaluate: tempArgument1Editor).
|
|
398 |
((self isExpression:tempArgument1Editor) or:[ associationValue isNil]) ifTrue:[ "looks if an expression is typed in"
|
|
399 |
associationKey:=associationValue printString]
|
|
400 |
ifFalse:[
|
|
401 |
associationKey:=tempArgument1Editor].
|
|
402 |
|
|
403 |
tempArguments add: associationKey-> associationValue.
|
|
404 |
].
|
|
405 |
(argCounter value >= 2)
|
|
406 |
ifTrue:[ associationValue:= (Compiler evaluate: tempArgument2Editor).
|
|
407 |
(((self isExpression:tempArgument2Editor) or:[ associationValue isNil])) ifTrue:[ "looks if an expression is typed in"
|
|
408 |
associationKey:=associationValue printString]
|
|
409 |
ifFalse:[
|
|
410 |
associationKey:=tempArgument2Editor].
|
|
411 |
|
|
412 |
tempArguments add: associationKey-> associationValue].
|
|
413 |
|
|
414 |
(argCounter value >= 3)
|
|
415 |
ifTrue:[ associationValue:= (Compiler evaluate: tempArgument3Editor).
|
|
416 |
((self isExpression:tempArgument3Editor) or:[ associationValue isNil]) ifTrue:[ "looks if an expression is typed in"
|
|
417 |
associationKey:=associationValue printString]
|
|
418 |
ifFalse:[
|
|
419 |
associationKey:=tempArgument3Editor].
|
|
420 |
|
|
421 |
tempArguments add: associationKey-> associationValue].
|
|
422 |
|
|
423 |
|
|
424 |
^tempArguments
|
|
425 |
!
|
|
426 |
|
|
427 |
clear
|
1525
|
428 |
"Reset the contents of all the outputs. Return the receiver."
|
1522
|
429 |
|
|
430 |
receiverEditor contents:nil.
|
|
431 |
argument1Editor contents:nil.
|
|
432 |
argument2Editor contents:nil.
|
|
433 |
argument3Editor contents:nil.
|
|
434 |
messageAnswerEditor contents:nil.
|
|
435 |
self resultHolder value:nil.
|
1525
|
436 |
self classOfResultHolder value: nil.
|
1522
|
437 |
!
|
|
438 |
|
|
439 |
isExpression: aString
|
1525
|
440 |
"Return true or false depending on if the subString includes certain characters"
|
1522
|
441 |
(aString includesSubString:': ') ifTrue:[^true].
|
|
442 |
(aString includesSubString:'+') ifTrue:[^true].
|
|
443 |
(aString includesSubString:'-') ifTrue:[^true].
|
|
444 |
(aString includesSubString:'*') ifTrue:[^true].
|
|
445 |
(aString includesSubString:'/') ifTrue:[^true].
|
|
446 |
(aString includesSubString:'>') ifTrue:[^true].
|
|
447 |
(aString includesSubString:'<') ifTrue:[^true].
|
|
448 |
(aString includesSubString:' new') ifTrue:[^true].
|
|
449 |
(aString includesSubString:'[') & (aString includesSubString:']') & (aString includesSubString:'.')
|
|
450 |
ifTrue:[^false].
|
|
451 |
(aString includesSubString:'.') ifTrue:[^true].
|
|
452 |
|
|
453 |
^false
|
|
454 |
!
|
|
455 |
|
|
456 |
messageAnswerEditorContents
|
1525
|
457 |
"Return a cleaned up version of message answer taken from the messageAnswerEditor
|
|
458 |
as an association. The association has cleanedAnswerString as a key and the
|
|
459 |
compiledAnswer as value."
|
1522
|
460 |
|
|
461 |
| aCleanedAnswerString compiledAnswer |
|
|
462 |
|
|
463 |
aCleanedAnswerString:=self cleanInputs: (messageAnswerEditor contents).
|
|
464 |
|
|
465 |
compiledAnswer:=Compiler evaluate: aCleanedAnswerString.
|
|
466 |
((self isExpression:aCleanedAnswerString) or:[compiledAnswer isNil]) ifTrue:[
|
|
467 |
aCleanedAnswerString:=compiledAnswer printString].
|
|
468 |
|
|
469 |
^aCleanedAnswerString->compiledAnswer.
|
|
470 |
!
|
|
471 |
|
|
472 |
openBrowserOn:anArgument
|
|
473 |
"Opens browser on theArgument of a specific class. anArgument being a string with the
|
1525
|
474 |
Class and the selector upon which the browser is to be opened. Return the receiver."
|
1522
|
475 |
|
|
476 |
|aClass aSelector x theArgument|
|
|
477 |
|
|
478 |
anArgument isNil ifTrue:[
|
1525
|
479 |
^ self
|
1522
|
480 |
].
|
|
481 |
(anArgument at:1) == $* ifTrue:[
|
1525
|
482 |
theArgument := anArgument copyFrom:2
|
1522
|
483 |
] ifFalse:[
|
1525
|
484 |
theArgument := anArgument
|
1522
|
485 |
].
|
|
486 |
aClass := theArgument copyUpTo:(Character space).
|
|
487 |
x := aClass size + 2.
|
|
488 |
aSelector := theArgument copyFrom:x.
|
|
489 |
aClass := Smalltalk classNamed:aClass.
|
1525
|
490 |
SystemBrowser openInClass:(aClass) selector:(aSelector asSymbol)
|
|
491 |
|
|
492 |
"
|
|
493 |
MethodFinderWindow new openBrowserOn: '*SmallInteger +'
|
|
494 |
MethodFinderWindow new openBrowserOn: 'String ,'
|
|
495 |
MethodFinderWindow new openBrowserOn: 'Number detentBy:atMultiplesOf:snap:'
|
|
496 |
|
|
497 |
|
|
498 |
"
|
1522
|
499 |
!
|
|
500 |
|
1529
|
501 |
openBrowserOnSelectedItem
|
|
502 |
|sel|
|
|
503 |
|
|
504 |
sel := self selectedClassOfResultHolder value.
|
|
505 |
sel isNil ifTrue:[^ self].
|
|
506 |
self openBrowserOn:sel
|
|
507 |
!
|
|
508 |
|
1522
|
509 |
receiverEditorContents
|
1525
|
510 |
"Return a cleaned up version of receiver taken from the receiverEditor
|
|
511 |
as an association. The association has aCleanedRecieverString as a key and the
|
|
512 |
compiledReceiver as value."
|
|
513 |
|
1522
|
514 |
| aCleanedRecieverString compiledReceiver |
|
|
515 |
|
|
516 |
aCleanedRecieverString:=self cleanInputs: (receiverEditor contents).
|
|
517 |
|
|
518 |
compiledReceiver:=Compiler evaluate: aCleanedRecieverString.
|
|
519 |
|
|
520 |
((self isExpression:aCleanedRecieverString) or:[compiledReceiver isNil]) ifTrue:[
|
|
521 |
aCleanedRecieverString:=compiledReceiver printString].
|
|
522 |
^aCleanedRecieverString->compiledReceiver.
|
|
523 |
!
|
|
524 |
|
|
525 |
search
|
1525
|
526 |
"Do a search based on the input in the various text editors. Return the receiver."
|
1522
|
527 |
| tempReceiver tempAnswer tempArguments anArray resultArray receiverWithArgument mf|
|
|
528 |
self resultHolder value: nil. "reset the result list"
|
|
529 |
self classOfResultHolder value: nil. "reset the implementorOf list"
|
|
530 |
|
|
531 |
tempArguments:=self argumentEditorsContents.
|
|
532 |
tempReceiver :=self receiverEditorContents .
|
|
533 |
tempAnswer:= self messageAnswerEditorContents.
|
|
534 |
|
|
535 |
"self cleanInputRec:tempReceiver arg:tempArguments ans:tempAnswer."
|
|
536 |
|
|
537 |
|
|
538 |
anArray:=Array new:2. "creates an array which is to be used as input for the method finder."
|
|
539 |
|
|
540 |
receiverWithArgument:=self mergReciever: (tempReceiver value) WithArgument: (tempArguments values).
|
|
541 |
|
|
542 |
anArray at:1 put:receiverWithArgument;
|
|
543 |
at:2 put: tempAnswer value.
|
|
544 |
|
|
545 |
"an array now holds the following array #(#(receiver argument) answer) or #(#(reciever) answer). which should
|
|
546 |
be suitable input for the method finder."
|
|
547 |
mf:= MethodFinder new.
|
|
548 |
resultArray:= mf load: anArray; findMessage.
|
|
549 |
|
|
550 |
((resultArray at: 1 )includesSubString: 'no single') ifTrue:[
|
|
551 |
self warn: (resultArray at: 1 ).
|
|
552 |
^self
|
|
553 |
].
|
|
554 |
|
|
555 |
"the following then replaces data1 and data2 created by the method finder to the appropriate arguments"
|
|
556 |
resultArray keysAndValuesDo:[:key :value | | newValue |
|
|
557 |
newValue:= value replString: 'data1' withString:(tempReceiver key).
|
|
558 |
(tempArguments size) >= 1 ifTrue:[
|
|
559 |
newValue:= newValue replString: 'data2' withString:(tempArguments keyAt:1)].
|
|
560 |
|
|
561 |
(tempArguments size) > 1 ifTrue:[
|
|
562 |
newValue:= newValue replString: 'data3' withString:(tempArguments keyAt:2).].
|
|
563 |
|
|
564 |
(tempArguments size) > 2 ifTrue:[
|
|
565 |
newValue:= newValue replString: 'data4' withString:(tempArguments keyAt:3).].
|
|
566 |
|
|
567 |
|
|
568 |
" newValue:= value replString: 'data3' withString:(self messageAnswer key). "
|
|
569 |
|
|
570 |
newValue:=newValue, ' --> ', (tempAnswer key).
|
|
571 |
|
|
572 |
resultArray at: key put: newValue.
|
|
573 |
|
|
574 |
].
|
|
575 |
|
|
576 |
self resultHolder value: resultArray.
|
|
577 |
resultSelectors:= mf selectors. "used to find implementors so we do not have to "
|
|
578 |
receiver:=tempReceiver "search the string for the selector found. Stored as an ordered collection"
|
|
579 |
!
|
|
580 |
|
|
581 |
updateImplementorsOf:anInteger
|
1525
|
582 |
"Request the implementors of the selected argument provided by aNumber.
|
|
583 |
Return the receiver. "
|
1522
|
584 |
|methods classList aNumber|
|
|
585 |
|
1525
|
586 |
|
1522
|
587 |
(anInteger isNil) ifTrue:[^self].
|
|
588 |
anInteger isNil ifTrue:[aNumber:=1]
|
|
589 |
ifFalse:[aNumber:=anInteger].
|
1525
|
590 |
methods:=SystemBrowser findImplementorsOf: (resultSelectors at:aNumber) in:Smalltalk allClasses ignoreCase:false.
|
|
591 |
classList:=methods asOrderedCollection collect:[:m | m mclass name , ' ' , m selector].
|
1522
|
592 |
|
|
593 |
classList:=(self markMatchingClasses:(resultSelectors at:aNumber) classesWithSelector:classList).
|
|
594 |
|
|
595 |
self classOfResultHolder value: classList.
|
|
596 |
! !
|
|
597 |
|
|
598 |
!MethodFinderWindow methodsFor:'aspects'!
|
|
599 |
|
|
600 |
arg1BoxVisible
|
1525
|
601 |
"Determines if the box should be visble or not. Return true or false"
|
1522
|
602 |
arg1BoxVisible isNil ifTrue:[
|
|
603 |
arg1BoxVisible := BlockValue
|
|
604 |
with:[:vh | vh value >= 2 ]
|
|
605 |
argument:(self argCountHolder)
|
|
606 |
].
|
|
607 |
^ arg1BoxVisible.
|
|
608 |
!
|
|
609 |
|
|
610 |
arg2BoxVisible
|
1525
|
611 |
"Determines if the box should be visble or not. Return true or false"
|
1522
|
612 |
arg2BoxVisible isNil ifTrue:[
|
|
613 |
arg2BoxVisible := BlockValue
|
|
614 |
with:[:vh | vh value >= 3 ]
|
|
615 |
argument:(self argCountHolder)
|
|
616 |
].
|
|
617 |
^ arg2BoxVisible.
|
|
618 |
!
|
|
619 |
|
|
620 |
arg3BoxVisible
|
1525
|
621 |
"Determines if the box should be visble or not. Return true or false"
|
1522
|
622 |
arg3BoxVisible isNil ifTrue:[
|
|
623 |
arg3BoxVisible := BlockValue
|
|
624 |
with:[:vh | vh value >= 4 ]
|
|
625 |
argument:(self argCountHolder)
|
|
626 |
].
|
|
627 |
^ arg3BoxVisible.
|
|
628 |
!
|
|
629 |
|
|
630 |
arg4BoxVisible
|
1525
|
631 |
"Determines if the box should be visble or not. Return true or false"
|
1522
|
632 |
arg4BoxVisible isNil ifTrue:[
|
|
633 |
arg4BoxVisible := BlockValue
|
|
634 |
with:[:vh | vh value >= 5 ]
|
|
635 |
argument:(self argCountHolder)
|
|
636 |
].
|
|
637 |
^ arg4BoxVisible.
|
|
638 |
!
|
|
639 |
|
|
640 |
argCountHolder
|
1525
|
641 |
"Return the value of argCounterHolder which is initialized at 2."
|
1522
|
642 |
argCountHolder isNil ifTrue:[
|
|
643 |
argCountHolder := 2 asValue.
|
|
644 |
].
|
|
645 |
^ argCountHolder.
|
|
646 |
!
|
|
647 |
|
|
648 |
argCountList
|
1525
|
649 |
"Return the argCountList"
|
1522
|
650 |
argCountList isNil ifTrue:[
|
|
651 |
argCountList := #('0 arguments' '1 argument' '2 arguments' '3 arguments') asValue
|
|
652 |
].
|
|
653 |
^ argCountList.
|
|
654 |
!
|
|
655 |
|
|
656 |
classOfResultHolder
|
1525
|
657 |
"Return a valueHolder which contains a collection with the names of the
|
|
658 |
implementors of a specific message. "
|
1522
|
659 |
|
|
660 |
|holder|
|
|
661 |
(holder := builder bindingAt:#classOfResultHolder) isNil ifTrue:[
|
1525
|
662 |
holder := ValueHolder new.
|
|
663 |
builder aspectAt:#classOfResultHolder put:holder
|
1522
|
664 |
].
|
|
665 |
^ holder
|
|
666 |
!
|
|
667 |
|
|
668 |
resultHolder
|
1525
|
669 |
"Return a value holder which contains the results of a search as a collection."
|
1522
|
670 |
|
|
671 |
|holder|
|
|
672 |
(holder := builder bindingAt:#resultHolder) isNil ifTrue:[
|
1525
|
673 |
holder := ValueHolder new.
|
|
674 |
builder aspectAt:#resultHolder put:holder.
|
1522
|
675 |
].
|
|
676 |
^ holder.
|
1529
|
677 |
!
|
|
678 |
|
|
679 |
selectedClassOfResultHolder
|
|
680 |
"Return a valueHolder which contains the index of the selected result class
|
|
681 |
(right list)"
|
|
682 |
|
|
683 |
|holder|
|
|
684 |
(holder := builder bindingAt:#selectedClassOfResultHolder) isNil ifTrue:[
|
|
685 |
holder := ValueHolder new.
|
|
686 |
builder aspectAt:#selectedClassOfResultHolder put:holder
|
|
687 |
].
|
|
688 |
^ holder
|
1522
|
689 |
! !
|
|
690 |
|
|
691 |
!MethodFinderWindow methodsFor:'callBacks'!
|
|
692 |
|
|
693 |
argument1WidgetCreated: aWidget
|
1525
|
694 |
"Store the widget as an instance variable. Return the receiver"
|
|
695 |
|
|
696 |
|
1522
|
697 |
argument1Editor := aWidget scrolledView.
|
|
698 |
!
|
|
699 |
|
|
700 |
argument2WidgetCreated: aWidget
|
1525
|
701 |
"Store the widget as an instance variable. Return the receiver"
|
|
702 |
|
1522
|
703 |
|
|
704 |
argument2Editor := aWidget scrolledView.
|
|
705 |
!
|
|
706 |
|
|
707 |
argument3WidgetCreated: aWidget
|
1525
|
708 |
"Store the widget as an instance variable. Return the receiver"
|
|
709 |
|
1522
|
710 |
|
|
711 |
argument3Editor := aWidget scrolledView.
|
|
712 |
!
|
|
713 |
|
1525
|
714 |
messageAnswerWidgetCreated: aWidget
|
|
715 |
"Store the widget as an instance variable. Return the receiver"
|
1522
|
716 |
|
1525
|
717 |
messageAnswerEditor := aWidget scrolledView.
|
1522
|
718 |
!
|
|
719 |
|
1525
|
720 |
openHTMLDocumentation
|
|
721 |
HTMLDocumentView openFullOnDocumentationFile:'tools/misc/TOP.html#METHODFINDER'
|
1522
|
722 |
!
|
|
723 |
|
|
724 |
receiverWidgetCreated: aWidget
|
1525
|
725 |
"Store the widget as an instance variable. Return the receiver"
|
1522
|
726 |
|
|
727 |
receiverEditor := aWidget scrolledView.
|
|
728 |
! !
|
|
729 |
|
|
730 |
!MethodFinderWindow methodsFor:'controlInput'!
|
|
731 |
|
|
732 |
cleanInputs: aDirtyString
|
1525
|
733 |
"Find and remove common mistakes made by the user. Return the
|
|
734 |
'aStringToBeCleaned' variable"
|
1522
|
735 |
| aStringToBeCleaned rs position|
|
|
736 |
|
|
737 |
aStringToBeCleaned:=aDirtyString.
|
|
738 |
|
|
739 |
(aStringToBeCleaned endsWith:(Character cr)) ifTrue:[
|
|
740 |
aStringToBeCleaned:=aStringToBeCleaned copyFrom:1 to: (aStringToBeCleaned size -1).].
|
|
741 |
aStringToBeCleaned:= aStringToBeCleaned withoutSeparators.
|
|
742 |
|
|
743 |
|
|
744 |
rs:=ReadStream on: aStringToBeCleaned.
|
|
745 |
[rs upToAll: '#true'. rs atEnd] whileFalse: [
|
|
746 |
position:= rs position.
|
|
747 |
aStringToBeCleaned:=aStringToBeCleaned copyReplaceFrom: position to: position with: ''. "remove #"
|
|
748 |
rs:=ReadStream on: aStringToBeCleaned.
|
|
749 |
].
|
|
750 |
|
|
751 |
rs:=ReadStream on: aStringToBeCleaned.
|
|
752 |
[rs upToAll: '#false'. rs atEnd] whileFalse: [
|
|
753 |
position:= rs position.
|
|
754 |
aStringToBeCleaned:=aStringToBeCleaned copyReplaceFrom: position to: position with: ''. "remove #"
|
|
755 |
rs:=ReadStream on: aStringToBeCleaned.
|
|
756 |
rs:=ReadStream on: aStringToBeCleaned. ].
|
|
757 |
|
|
758 |
[rs upToAll: '#nil'. rs atEnd] whileFalse: [
|
|
759 |
position:= rs position.
|
|
760 |
aStringToBeCleaned:=aStringToBeCleaned copyReplaceFrom: position to: position with: ''. "remove #"
|
|
761 |
rs:=ReadStream on: aStringToBeCleaned. ].
|
|
762 |
^aStringToBeCleaned
|
|
763 |
!
|
|
764 |
|
1525
|
765 |
markMatchingClasses: aSelector classesWithSelector:anOrderedCollection
|
|
766 |
" Matches the class of the receiver with all the elements in anOrderedCollection
|
|
767 |
(which are classes with selectors). If a match is found it is marked with an asterisk.
|
|
768 |
The classes are then sorted so the the asterisk appears first. Return the
|
|
769 |
markedClassList."
|
1522
|
770 |
|
1525
|
771 |
| unmarkedClassList firstPartOfSelector markedClassList|
|
1522
|
772 |
|
1525
|
773 |
unmarkedClassList:=anOrderedCollection copy.
|
1522
|
774 |
|
1525
|
775 |
unmarkedClassList do:
|
|
776 |
[:classAndMethod | | class |
|
|
777 |
class:=Compiler evaluate:
|
|
778 |
((ReadStream on: classAndMethod) upToAll: aSelector).
|
|
779 |
(receiver value class == class) ifTrue:
|
|
780 |
[unmarkedClassList add: '*', classAndMethod.
|
|
781 |
unmarkedClassList remove: classAndMethod]].
|
1522
|
782 |
|
|
783 |
unmarkedClassList sort:[:a :b | |rawA rawB|
|
1525
|
784 |
rawA := (a startsWith:'*') ifTrue:[a copyFrom:2] ifFalse:[a].
|
|
785 |
rawB := (b startsWith:'*') ifTrue:[b copyFrom:2] ifFalse:[b].
|
|
786 |
rawA > rawB. ].
|
|
787 |
markedClassList:= unmarkedClassList.
|
|
788 |
|
|
789 |
^markedClassList
|
1522
|
790 |
!
|
|
791 |
|
|
792 |
mergReciever: aReceiver WithArgument: arguments
|
|
793 |
|
1525
|
794 |
"Puts the receiver and arguments into an array so it can be of a suitable input for the
|
|
795 |
MethodFinder. Return an array."
|
|
796 |
|
1522
|
797 |
| tempReceiver tempArguments receiverWithArgument|
|
|
798 |
|
|
799 |
tempReceiver:= aReceiver.
|
|
800 |
tempArguments := arguments.
|
|
801 |
|
|
802 |
(tempArguments isEmpty or:[(tempArguments) isNil])
|
|
803 |
ifTrue:[ receiverWithArgument:=Array new:1."no argument"
|
|
804 |
receiverWithArgument at:1 put: tempReceiver.
|
|
805 |
]
|
|
806 |
ifFalse:[
|
|
807 |
(tempArguments size = 1)
|
|
808 |
ifTrue:[ receiverWithArgument:=Array new:2.
|
|
809 |
receiverWithArgument at:1 put: tempReceiver.
|
|
810 |
receiverWithArgument at:2 put: (tempArguments at:1)
|
|
811 |
]. "a receiver with an argument"
|
|
812 |
|
|
813 |
(tempArguments size = 2)
|
|
814 |
ifTrue:[ receiverWithArgument:=Array new:3.
|
|
815 |
receiverWithArgument at:1 put: tempReceiver.
|
|
816 |
(receiverWithArgument at:2 put: (tempArguments at:1)).
|
|
817 |
(receiverWithArgument at:3 put: (tempArguments at:2))
|
|
818 |
]. "a receiver with an argument"
|
|
819 |
(tempArguments size = 3)
|
|
820 |
ifTrue:[ receiverWithArgument:=Array new:4.
|
|
821 |
receiverWithArgument at:1 put: tempReceiver.
|
|
822 |
(receiverWithArgument at:2 put: (tempArguments at:1)).
|
|
823 |
(receiverWithArgument at:3 put: (tempArguments at:2)).
|
|
824 |
(receiverWithArgument at:4 put: (tempArguments at:3)).
|
|
825 |
|
|
826 |
]. "a receiver with an argument"
|
|
827 |
|
|
828 |
].
|
|
829 |
^receiverWithArgument
|
|
830 |
! !
|
|
831 |
|
|
832 |
!MethodFinderWindow class methodsFor:'documentation'!
|
|
833 |
|
|
834 |
version
|
|
835 |
^ '$Header$'
|
|
836 |
! !
|