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