Tools__MethodList.st
changeset 16063 bce10645c75d
parent 16029 ea99c06473a2
child 16066 471853fc1521
child 16069 3b6e91bd072c
equal deleted inserted replaced
16062:17352a9e9eaa 16063:bce10645c75d
   718     |indices methods reverseMap
   718     |indices methods reverseMap
   719      selectedMethodsHolder selectedMethods selectedMethodNameIndicesHolder|
   719      selectedMethodsHolder selectedMethods selectedMethodNameIndicesHolder|
   720 
   720 
   721     methods := methodList ? #().
   721     methods := methodList ? #().
   722     methods size == 0 ifTrue:[
   722     methods size == 0 ifTrue:[
   723 	"/ this may happen during early startup,
   723         "/ this may happen during early startup,
   724 	"/ when invoked with a preset methodSelection,
   724         "/ when invoked with a preset methodSelection,
   725 	"/ and the methodGenerator has not yet been setup
   725         "/ and the methodGenerator has not yet been setup
   726 	"/ to not clobber the selection, defer the update
   726         "/ to not clobber the selection, defer the update
   727 	"/ until the methodList arrives ...
   727         "/ until the methodList arrives ...
   728 	^ self
   728         ^ self
   729     ].
   729     ].
   730 
   730 
   731     selectedMethodsHolder := self selectedMethods.
   731     selectedMethodsHolder := self selectedMethods.
   732     selectedMethods := selectedMethodsHolder value.
   732     selectedMethods := selectedMethodsHolder value.
   733 
   733 
   734     "/ check if all is selected (likely)
   734     "/ check if all is selected (likely)
   735     ((selectedMethods size == methodList size)
   735     ((selectedMethods size == methodList size)
   736     and:[selectedMethods = methodList]) ifTrue:[
   736     and:[selectedMethods = methodList]) ifTrue:[
   737 	indices := (1 to:selectedMethods size)
   737         indices := (1 to:selectedMethods size)
   738     ] ifFalse:[
   738     ] ifFalse:[
   739 	selectedMethods size > 100 ifTrue:[
   739         selectedMethods size > 100 ifTrue:[
   740 	    "/ check if all is selected (likely)
   740             "/ check if all is selected (likely)
   741 	    ((selectedMethods size == methodList size)
   741             ((selectedMethods size == methodList size)
   742 	    and:[selectedMethods = methodList]) ifTrue:[
   742             and:[selectedMethods = methodList]) ifTrue:[
   743 		indices := (1 to:selectedMethods size)
   743                 indices := (1 to:selectedMethods size)
   744 	    ] ifFalse:[
   744             ] ifFalse:[
   745 		"/ for big collections, generate a reverse map
   745                 "/ for big collections, generate a reverse map
   746 		reverseMap := IdentityDictionary new.
   746                 reverseMap := IdentityDictionary new.
   747 		methods keysAndValuesDo:[:idx :mthd | reverseMap at:mthd put:idx].
   747                 methods keysAndValuesDo:[:idx :mthd | reverseMap at:mthd put:idx].
   748 		indices := selectedMethods collect:[:eachSelectedMethod |
   748                 indices := selectedMethods 
   749 		    reverseMap at:eachSelectedMethod ifAbsent:0
   749                                 collect:[:eachSelectedMethod |
   750 		]
   750                                     reverseMap at:eachSelectedMethod ifAbsent:0]
   751 	    ]
   751                                 thenSelect:[:idx | idx ~~ 0]
   752 	] ifFalse:[
   752             ]
   753 	    indices := (selectedMethods ? #()) collect:[:eachSelectedMethod |
   753         ] ifFalse:[
   754 		methods identityIndexOf:eachSelectedMethod.
   754             indices := (selectedMethods ? #()) 
   755 	    ]
   755                             collect:[:eachSelectedMethod |
   756 	].
   756                                 methods identityIndexOf:eachSelectedMethod]
   757 	indices := indices select:[:idx | idx ~= 0].
   757                             thenSelect:[:idx | idx ~~ 0]
       
   758         ].
   758     ].
   759     ].
   759 
   760 
   760     selectedMethodNameIndicesHolder := self selectedMethodNameIndices.
   761     selectedMethodNameIndicesHolder := self selectedMethodNameIndices.
   761     selectedMethodNameIndicesHolder value ~= indices ifTrue:[
   762     selectedMethodNameIndicesHolder value ~= indices ifTrue:[
   762 	selectedMethodNameIndicesHolder value:indices.
   763         selectedMethodNameIndicesHolder value:indices.
   763     ]
   764     ]
   764 !
   765 !
   765 
   766 
   766 selectionChanged
   767 selectionChanged
   767     |methods|
   768     |methods|