#REFACTORING by exept
class: MethodFinderWindow
changed:
#search
#search2Levels
--- a/MethodFinderWindow.st Thu Nov 07 17:43:28 2019 +0100
+++ b/MethodFinderWindow.st Fri Nov 08 09:06:39 2019 +0100
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
Copyright (C) Original Authors (Kaehler, Scott Wallace and Dan Ingalls)
Copyright (C) 2001 eXept Software AG
@@ -1080,12 +1078,14 @@
search
"Do a search based on the input in the various text editors. Return the receiver."
- |tempReceiver tempAnswer tempArguments anArray resultArrayOrErrorString receiverWithArgument mf|
+ |tempReceiver tempAnswer tempArguments numArgs
+ anArray resultArrayOrErrorString receiverWithArgument mf|
self resultHolder value:nil.
self classOfResultListHolder value:nil.
self codeHolder value:nil.
tempArguments := self argumentEditorsContents.
+ numArgs := tempArguments size.
tempReceiver := self receiverEditorContents.
tempAnswer := self messageAnswerEditorContents.
@@ -1117,32 +1117,34 @@
].
"the following then replaces data1 and data2 created by the method finder to the appropriate arguments"
- resultArrayOrErrorString
- keysAndValuesDo:[:key :value |
- |newValue|
+ resultArrayOrErrorString keysAndValuesDo:[:key :value |
+ |newValue|
- newValue := value copyReplaceString:'data1'
- withString:(tempReceiver value storeString). "/ was: "tempReceiver key"
- (tempArguments size) >= 1 ifTrue:[
- newValue := newValue copyReplaceString:'data2'
- withString:(tempArguments valueAt:1) storeString "/ was "keyAt:1"
- ].
- (tempArguments size) > 1 ifTrue:[
+ newValue := value copyReplaceString:'data1'
+ withString:(tempReceiver value storeString). "/ was: "tempReceiver key"
+
+ numArgs > 0 ifTrue:[
+ newValue := newValue copyReplaceString:'data2'
+ withString:(tempArguments valueAt:1) storeString. "/ was "keyAt:1"
+ numArgs > 1 ifTrue:[
newValue := newValue copyReplaceString:'data3'
withString:(tempArguments valueAt:2) storeString. "/ was "keyAt:2"
- ].
- (tempArguments size) > 2 ifTrue:[
- newValue := newValue copyReplaceString:'data4'
- withString:(tempArguments valueAt:3) storeString. "/ was: keyAt:3
+
+ numArgs > 2 ifTrue:[
+ newValue := newValue copyReplaceString:'data4'
+ withString:(tempArguments valueAt:3) storeString. "/ was: keyAt:3
+
+ numArgs > 3 ifTrue:[
+ self halt:'unimplemented'.
+ ].
+ ].
].
- (tempArguments size) > 3 ifTrue:[
- self halt:'unimplemented'.
- ].
- " newValue:= value copyReplaceString: 'data3' withString:(self messageAnswer key). "
- newValue := newValue , ' --> ' , (tempAnswer key).
- newValue replaceAll:Character cr with:Character space.
- resultArrayOrErrorString at:key put:newValue.
].
+ " newValue:= value copyReplaceString: 'data3' withString:(self messageAnswer key). "
+ newValue := newValue , ' --> ' , (tempAnswer key).
+ newValue replaceAll:Character cr with:Character space.
+ resultArrayOrErrorString at:key put:newValue.
+ ].
self resultHolder value:resultArrayOrErrorString.
resultSelectors := mf selectors.
receiver := tempReceiver
@@ -1157,11 +1159,13 @@
Given the original message,
try applying all unary messages first to the receiver,
then to each argument.
- This takes O(N²) time - so be prepared"
+ This takes O(N²) time - so be prepared"
- |tempReceiver tempAnswer tempArguments anArray resultArray receiverWithArgument mf|
+ |tempReceiver tempAnswer tempArguments numArgs
+ anArray resultArray receiverWithArgument mf|
tempArguments := self argumentEditorsContents.
+ numArgs := tempArguments size.
tempReceiver := self receiverEditorContents.
tempAnswer := self messageAnswerEditorContents.
@@ -1194,20 +1198,23 @@
newValue := value copyReplaceString:'data1'
withString:(tempReceiver value storeString). "/ was: "tempReceiver key"
- (tempArguments size) >= 1 ifTrue:[
+ numArgs > 0 ifTrue:[
newValue := newValue copyReplaceString:'data2'
- withString:(tempArguments valueAt:1) storeString "/ was "keyAt:1"
- ].
- (tempArguments size) > 1 ifTrue:[
- newValue := newValue copyReplaceString:'data3'
- withString:(tempArguments valueAt:2) storeString. "/ was "keyAt:2"
- ].
- (tempArguments size) > 2 ifTrue:[
- newValue := newValue copyReplaceString:'data4'
- withString:(tempArguments valueAt:3) storeString. "/ was: keyAt:3
- ].
- (tempArguments size) > 3 ifTrue:[
- self halt:'unimplemented'.
+ withString:(tempArguments valueAt:1) storeString. "/ was "keyAt:1"
+
+ numArgs > 1 ifTrue:[
+ newValue := newValue copyReplaceString:'data3'
+ withString:(tempArguments valueAt:2) storeString. "/ was "keyAt:2"
+
+ numArgs > 2 ifTrue:[
+ newValue := newValue copyReplaceString:'data4'
+ withString:(tempArguments valueAt:3) storeString. "/ was: keyAt:3
+
+ numArgs > 3 ifTrue:[
+ self halt:'unimplemented'.
+ ].
+ ]
+ ]
].
" newValue:= value copyReplaceString: 'data3' withString:(self messageAnswer key). "
newValue := newValue , ' --> ' , (tempAnswer key).