#DOCUMENTATION by cg
class: MethodFinderWindow
added: #search2Levels
changed: #search
class: MethodFinderWindow class
changed:
#menu
#windowSpec
--- a/MethodFinderWindow.st Thu Jul 18 19:20:43 2019 +0200
+++ b/MethodFinderWindow.st Thu Jul 18 21:57:25 2019 +0200
@@ -181,7 +181,7 @@
^
#(FullSpec
name: windowSpec
- uuid: '5fb0c294-89f6-11e9-8df0-b8f6b1108e05'
+ uuid: '4698b584-a993-11e9-b8a4-b8f6b1108e05'
window:
(WindowSpec
label: 'MethodFinder'
@@ -508,21 +508,32 @@
useIndex: false
sequenceList: classOfResultHolder
)
- (CodeViewSpec
- name: 'CodeView'
- uuid: '5fb106dc-89f6-11e9-8df0-b8f6b1108e05'
- model: codeHolder
- hasHorizontalScrollBar: true
- hasVerticalScrollBar: true
- autoHideScrollBars: true
- hasKeyboardFocusInitially: false
- viewClassName: 'codeViewClass'
- postBuildCallback: sourceCodeWidgetCreated:
+ (ViewSpec
+ name: 'Box4'
+ uuid: '4698d744-a993-11e9-b8a4-b8f6b1108e05'
+ component:
+ (SpecCollection
+ collection: (
+ (CodeViewSpec
+ name: 'CodeView1'
+ layout: (LayoutFrame 0 0 0 0 0 1 0 1)
+ uuid: '5fb106dc-89f6-11e9-8df0-b8f6b1108e05'
+ model: codeHolder
+ hasHorizontalScrollBar: true
+ hasVerticalScrollBar: true
+ autoHideScrollBars: true
+ hasKeyboardFocusInitially: false
+ viewClassName: 'codeViewClass'
+ postBuildCallback: sourceCodeWidgetCreated:
+ )
+ )
+
+ )
)
)
)
- handles: (Any 0.23999999999999999 1.0)
+ handles: (Any 0.5 1.0)
)
)
@@ -932,6 +943,13 @@
label: '-'
)
(MenuItem
+ label: 'Show Me How it Works'
+ itemValue: showMeHowItWorks
+ )
+ (MenuItem
+ label: '-'
+ )
+ (MenuItem
activeHelpKey: aboutThisAppliaction
label: 'About MethodFinder...'
itemValue: openAboutThisApplication
@@ -1130,11 +1148,20 @@
load:anArray;
findMessage.
].
+
((resultArray at:1) includesSubString:'no single') ifTrue:[
- self warn:(resultArray at:1).
+ false ifTrue:[
+ (self confirm:(c'%1\nTry a more exhaustive search (may take long)?' bindWith:(resultArray at:1)))
+ ifTrue:[
+ self search2Levels.
+ ].
+ ] ifFalse:[
+ self warn:(resultArray at:1).
+ ].
^ self
].
- "the following then replaces data1 and data2 created by the method finder to the appropriate arguments"
+
+ "the following then replaces data1 and data2 created by the method finder to the appropriate arguments"
resultArray
keysAndValuesDo:[:key :value |
|newValue|
@@ -1167,7 +1194,75 @@
"Modified: / 26-09-2011 / 12:42:28 / cg"
"Modified: / 27-02-2018 / 11:37:58 / stefan"
- "Modified: / 08-06-2019 / 16:24:00 / Claus Gittinger"
+ "Modified: / 18-07-2019 / 21:57:12 / Claus Gittinger"
+!
+
+search2Levels
+ "Do an exhaustive search.
+ Given the original message,
+ try applying all unary messages first to the receiver,
+ then to each argument.
+ This takes O(N^2) time - so be prepared"
+
+ |tempReceiver tempAnswer tempArguments anArray resultArray receiverWithArgument mf|
+
+ tempArguments := self argumentEditorsContents.
+ tempReceiver := self receiverEditorContents.
+ tempAnswer := self messageAnswerEditorContents.
+
+ anArray := Array new:2.
+ receiverWithArgument := self mergeReceiver:(tempReceiver value)
+ withArgument:(tempArguments values).
+ anArray
+ at:1 put:receiverWithArgument;
+ at:2 put:tempAnswer value.
+ "an array now holds the following array #(#(receiver argument) answer) or #(#(receiver) answer).
+ which should be suitable input for the method finder."
+ self withCursor:Cursor execute do:[
+ mf := MethodFinder new.
+ resultArray := mf load:anArray; findMessage.
+ ].
+
+ ((resultArray at:1) includesSubString:'no single') ifTrue:[
+ (self confirm:(c'%1\nTry a more exhaustive search (may take long)?' bindWith:(resultArray at:1)))
+ ifTrue:[
+ self search2Levels.
+ ].
+ ^ self
+ ].
+
+ "the following then replaces data1 and data2 created by the method finder to the appropriate arguments"
+ resultArray
+ 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 := 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'.
+ ].
+ " newValue:= value copyReplaceString: 'data3' withString:(self messageAnswer key). "
+ newValue := newValue , ' --> ' , (tempAnswer key).
+ newValue replaceAll:Character cr with:Character space.
+ resultArray at:key put:newValue.
+ ].
+ self resultHolder value:resultArray.
+ resultSelectors := mf selectors.
+ receiver := tempReceiver
+
+ "Created: / 18-07-2019 / 21:22:47 / Claus Gittinger"
!
searchPatternMatchesInBackground