# HG changeset patch # User Claus Gittinger # Date 1372180316 -7200 # Node ID 66a99ab06e196e33b37d26387ed5673864954805 # Parent 8298397571ebd1c0277dcb8127ce3d34f669022d class: MethodFinderWindow added: #openBrowserOnSenderOfSelectedResultItem diff -r 8298397571eb -r 66a99ab06e19 MethodFinderWindow.st --- a/MethodFinderWindow.st Tue Jun 25 12:42:03 2013 +0200 +++ b/MethodFinderWindow.st Tue Jun 25 19:11:56 2013 +0200 @@ -459,6 +459,11 @@ #(#Menu #( #(#MenuItem + #label: 'Browse Senders' + #translateLabel: true + #value: #openBrowserOnSenderOfSelectedResultItem + ) + #(#MenuItem #label: 'Browse Implementors' #translateLabel: true #value: #openBrowserOnSelectedResultItem @@ -586,36 +591,56 @@ "Modified: / 27-04-2012 / 15:05:53 / cg" ! -isExpression: aString - "Return true or false depending on if the subString includes certain characters" -(aString includesSubString:': ') ifTrue:[^true]. -(aString includesSubString:'+') ifTrue:[^true]. -(aString includesSubString:'-') ifTrue:[^true]. -(aString includesSubString:'*') ifTrue:[^true]. -(aString includesSubString:'/') ifTrue:[^true]. -(aString includesSubString:'>') ifTrue:[^true]. -(aString includesSubString:'<') ifTrue:[^true]. -(aString includesSubString:' new') ifTrue:[^true]. -(aString includesSubString:'[') & (aString includesSubString:']') & (aString includesSubString:'.') - ifTrue:[^false]. -(aString includesSubString:'.') ifTrue:[^true]. +isExpression:aString + "Return true or false depending on if the subString includes certain characters" + + (aString includesSubString:': ') ifTrue:[ + ^ true + ]. + (aString includes:$+) ifTrue:[ + ^ true + ]. + (aString includes:$-) ifTrue:[ + ^ true + ]. + (aString includes:$*) ifTrue:[ + ^ true + ]. + (aString includes:$/) ifTrue:[ + ^ true + ]. + (aString includes:$>) ifTrue:[ + ^ true + ]. + (aString includes:$<) ifTrue:[ + ^ true + ]. + (aString includesSubString:' new') ifTrue:[ + ^ true + ]. + (aString includes:$[) + & (aString includes:$]) + & (aString includes:$.) ifTrue:[ ^ false ]. - ^false + (aString includes:$.) ifTrue:[ + ^ true + ]. + ^ false ! messageAnswerEditorContents - "Return a cleaned up version of message answer taken from the messageAnswerEditor - as an association. The association has cleanedAnswerString as a key and the - compiledAnswer as value." - - | aCleanedAnswerString compiledAnswer | + "Return a cleaned up version of message answer taken from the messageAnswerEditor + as an association. The association has cleanedAnswerString as a key and the + compiledAnswer as value." + + |aCleanedAnswerString compiledAnswer| -aCleanedAnswerString:=self cleanInputs: (messageAnswerEditor contents). -compiledAnswer:=Compiler evaluate: aCleanedAnswerString. -((self isExpression:aCleanedAnswerString) or:[compiledAnswer isNil]) ifTrue:[ - aCleanedAnswerString:=compiledAnswer printString]. - -^aCleanedAnswerString->compiledAnswer. + aCleanedAnswerString := self cleanInputs:(messageAnswerEditor contents). + compiledAnswer := Compiler evaluate:aCleanedAnswerString. + ((self isExpression:aCleanedAnswerString) or:[ compiledAnswer isNil ]) ifTrue:[ + aCleanedAnswerString := compiledAnswer printString + ]. + ^ aCleanedAnswerString -> compiledAnswer. ! openBrowserOn:anArgument @@ -628,7 +653,7 @@ classAndSelector isNil ifTrue:[ ^ self ]. - UserPreferences current systemBrowserClass + UserPreferences systemBrowserClass openInClass:classAndSelector key selector:classAndSelector value @@ -670,83 +695,94 @@ "Created: / 21-09-2012 / 11:05:46 / cg" ! -receiverEditorContents - "Return a cleaned up version of receiver taken from the receiverEditor - as an association. The association has aCleanedRecieverString as a key and the - compiledReceiver as value." +openBrowserOnSenderOfSelectedResultItem + "on an item in the lower left list, + on all implementors of that message" + + |selIndex selector| - | aCleanedRecieverString compiledReceiver | + selIndex := self selectedImplementorsHolder value. + selIndex isNil ifTrue:[^ self]. + + selector := resultSelectors at:selIndex. + UserPreferences browserClass browseSendersOf:selector. +! -aCleanedRecieverString:=self cleanInputs: (receiverEditor contents). - -compiledReceiver:=Compiler evaluate: aCleanedRecieverString. +receiverEditorContents + "Return a cleaned up version of receiver taken from the receiverEditor + as an association. The association has aCleanedRecieverString as a key and the + compiledReceiver as value." + + |aCleanedRecieverString compiledReceiver| -((self isExpression:aCleanedRecieverString) or:[compiledReceiver isNil]) ifTrue:[ - aCleanedRecieverString:=compiledReceiver printString]. -^aCleanedRecieverString->compiledReceiver. + aCleanedRecieverString := self cleanInputs:(receiverEditor contents). + compiledReceiver := Compiler evaluate:aCleanedRecieverString. + ((self isExpression:aCleanedRecieverString) or:[ compiledReceiver isNil ]) ifTrue:[ + aCleanedRecieverString := compiledReceiver printString + ]. + ^ aCleanedRecieverString -> compiledReceiver. ! search -"Do a search based on the input in the various text editors. Return the receiver." -| tempReceiver tempAnswer tempArguments anArray resultArray receiverWithArgument mf| - -self resultHolder value: nil. "reset the result list" -self classOfResultHolder value: nil. "reset the implementorOf list" -self codeHolder value: nil. "reset the source" - -tempArguments:=self argumentEditorsContents. -tempReceiver :=self receiverEditorContents . -tempAnswer:= self messageAnswerEditorContents. - -"self cleanInputRec:tempReceiver arg:tempArguments ans:tempAnswer." - - -anArray:=Array new:2. "creates an array which is to be used as input for the method finder." - -receiverWithArgument:=self mergReciever: (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 #(#(reciever) answer). which should -be suitable input for the method finder." -self withCursor:Cursor execute do:[ - mf:= MethodFinder new. - resultArray:= mf load: anArray; findMessage. -]. + "Do a search based on the input in the various text editors. Return the receiver." + + |tempReceiver tempAnswer tempArguments anArray resultArray receiverWithArgument mf| -((resultArray at: 1 )includesSubString: 'no single') ifTrue:[ - self warn: (resultArray at: 1 ). - ^self - ]. -"the following then replaces data1 and data2 created by the method finder to the appropriate arguments" - -resultArray keysAndValuesDo:[:key :value | | newValue | - newValue:= value replString: 'data1' withString:(tempReceiver key). -(tempArguments size) >= 1 ifTrue:[ - newValue:= newValue replString: 'data2' withString:(tempArguments keyAt:1)]. - -(tempArguments size) > 1 ifTrue:[ - newValue:= newValue replString: 'data3' withString:(tempArguments keyAt:2).]. + self resultHolder value:nil. + self classOfResultHolder value:nil. + self codeHolder value:nil. + tempArguments := self argumentEditorsContents. + tempReceiver := self receiverEditorContents. + tempAnswer := self messageAnswerEditorContents. + "self cleanInputRec:tempReceiver arg:tempArguments ans:tempAnswer." + anArray := Array new:2. + receiverWithArgument := self mergReciever:(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 #(#(reciever) 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 warn:(resultArray at:1). + ^ self + ]. + "the following then replaces data1 and data2 created by the method finder to the appropriate arguments" + resultArray + keysAndValuesDo:[:key :value | + |newValue| -(tempArguments size) > 2 ifTrue:[ - newValue:= newValue replString: 'data4' withString:(tempArguments keyAt:3).]. - -(tempArguments size) > 3 ifTrue:[ self halt:'unimplemented'. ]. - - - " newValue:= value replString: '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. "used to find implementors so we do not have to " -receiver:=tempReceiver "search the string for the selector found. Stored as an ordered collection" + newValue := value replString:'data1' withString:(tempReceiver key). + (tempArguments size) >= 1 ifTrue:[ + newValue := newValue replString:'data2' + withString:(tempArguments keyAt:1) + ]. + (tempArguments size) > 1 ifTrue:[ + newValue := newValue replString:'data3' + withString:(tempArguments keyAt:2). + ]. + (tempArguments size) > 2 ifTrue:[ + newValue := newValue replString:'data4' + withString:(tempArguments keyAt:3). + ]. + (tempArguments size) > 3 ifTrue:[ + self halt:'unimplemented'. + ]. + " newValue:= value replString: '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 "Modified: / 26-09-2011 / 12:42:28 / cg" !