SystemBrowser.st
changeset 17180 4ac997b21c39
parent 17056 20e4c1abbbcf
child 17218 95008a0da101
child 17328 e110bd817e78
equal deleted inserted replaced
17179:fb0d18f08e6b 17180:4ac997b21c39
  3532 
  3532 
  3533 browseImplementorsOf:aSelectorString in:aCollectionOfClasses ignoreCase:ignoreCase title:titleArg
  3533 browseImplementorsOf:aSelectorString in:aCollectionOfClasses ignoreCase:ignoreCase title:titleArg
  3534     "launch a browser for all implementors of aSelector in
  3534     "launch a browser for all implementors of aSelector in
  3535      the classes contained in aCollectionOfClasses and their metaclasses"
  3535      the classes contained in aCollectionOfClasses and their metaclasses"
  3536 
  3536 
  3537     |list list2 rs selWithColon title top20 allSelectors choice but globalClass global globalName|
  3537     |list list2 rs selWithColon title top20 allSelectors choice but globalClass global globalName lcSelector|
  3538 
  3538 
  3539     title := titleArg.
  3539     title := titleArg.
  3540     list := self 
  3540     list := self 
  3541                 findImplementors:aSelectorString 
  3541                 findImplementors:aSelectorString 
  3542                 in:aCollectionOfClasses 
  3542                 in:aCollectionOfClasses 
  3551             ].            
  3551             ].            
  3552         ].
  3552         ].
  3553         list2 size == 0 ifTrue:[
  3553         list2 size == 0 ifTrue:[
  3554             "/ self showNoneFound:title.
  3554             "/ self showNoneFound:title.
  3555             "/ ^ self
  3555             "/ ^ self
       
  3556             lcSelector := aSelectorString asLowercase.
       
  3557             
  3556             allSelectors := Set new.
  3558             allSelectors := Set new.
  3557             top20 := SortedCollection new.
  3559             top20 := SortedCollection new.
  3558             top20 sortBlock:[:a :b | (a spellAgainst:aSelectorString) > (b spellAgainst:aSelectorString)].
  3560             top20 
       
  3561                 sortBlock:[:a :b | 
       
  3562                     |isPrefixOfA isPrefixOfB aDist bDist|
       
  3563 
       
  3564                     isPrefixOfA := (a asLowercase startsWith:lcSelector).
       
  3565                     isPrefixOfB := (b asLowercase startsWith:lcSelector).
       
  3566                     (isPrefixOfA and:[isPrefixOfB not])
       
  3567                     or:[ 
       
  3568                         aDist := (a spellAgainst:aSelectorString).
       
  3569                         bDist := (b spellAgainst:aSelectorString).
       
  3570                         (isPrefixOfA and:[isPrefixOfB and:[aDist > bDist]])     
       
  3571                         or:[ isPrefixOfB not and:[ aDist > bDist ]]]
       
  3572                 ].
  3559             Smalltalk allMethodsWithSelectorDo:[:eachMethod :eachSelector |
  3573             Smalltalk allMethodsWithSelectorDo:[:eachMethod :eachSelector |
  3560                 ((eachSelector asLowercase startsWith:aSelectorString) or:[(eachSelector spellAgainst:aSelectorString) > 50]) ifTrue:[    
  3574                 ((eachSelector asLowercase startsWith:lcSelector) or:[(eachSelector spellAgainst:aSelectorString) > 50]) ifTrue:[    
  3561                     (allSelectors includes:eachSelector) ifFalse:[
  3575                     (allSelectors includes:eachSelector) ifFalse:[
  3562                         allSelectors add:eachSelector.
  3576                         allSelectors add:eachSelector.
  3563                         top20 add:eachSelector.
  3577                         top20 add:eachSelector.
  3564                         top20 size > 20 ifTrue:[ top20 removeLast. allSelectors := top20 asSet ].
  3578                         top20 size > 20 ifTrue:[ top20 removeLast. allSelectors := top20 asSet ].
  3565                     ]
  3579                     ]
  3566                 ]
  3580                 ]
  3567             ].
  3581             ].
  3568             top20 isEmpty ifTrue:[
  3582             top20 isEmpty ifTrue:[
  3569                 |lcSelector|
       
  3570 
       
  3571                 lcSelector := aSelectorString asLowercase.
       
  3572                 Smalltalk allMethodsWithSelectorDo:[:eachMethod :eachSelector |
  3583                 Smalltalk allMethodsWithSelectorDo:[:eachMethod :eachSelector |
  3573                     (eachSelector asLowercase spellAgainst:lcSelector) > 50 ifTrue:[    
  3584                     (eachSelector asLowercase spellAgainst:lcSelector) > 50 ifTrue:[    
  3574                         (allSelectors includes:eachSelector) ifFalse:[
  3585                         (allSelectors includes:eachSelector) ifFalse:[
  3575                             allSelectors add:eachSelector.
  3586                             allSelectors add:eachSelector.
  3576                             top20 add:eachSelector.
  3587                             top20 add:eachSelector.