DoWhatIMeanSupport.st
changeset 4592 ba8cb2c6ef61
parent 4591 5e2aa5f1ce21
child 4610 6e07eb8f8e8b
equal deleted inserted replaced
4591:5e2aa5f1ce21 4592:ba8cb2c6ef61
  1499 "/        self information:'No class'.
  1499 "/        self information:'No class'.
  1500 "/        ^ self.
  1500 "/        ^ self.
  1501 "/    ].
  1501 "/    ].
  1502 
  1502 
  1503     crsrPos := codeView characterPositionOfCursor.
  1503     crsrPos := codeView characterPositionOfCursor.
  1504     char := codeView characterAtCharacterPosition:crsrPos.
  1504     char := codeView characterAtCharacterPosition:(crsrPos-1 max:1).
  1505     [crsrPos > 1 and:[char isSeparator "or:['.' includes:char]"]] whileTrue:[
  1505     [crsrPos > 1 and:[char isSeparator "or:['.' includes:char]"]] whileTrue:[
  1506         crsrPos := crsrPos - 1.
  1506         crsrPos := crsrPos - 1.
  1507         char := codeView characterAtCharacterPosition:crsrPos.
  1507         char := codeView characterAtCharacterPosition:crsrPos.
  1508     ].
  1508     ].
  1509 
  1509 
  3843 
  3843 
  3844     "Created: / 28-08-2013 / 16:34:53 / cg"
  3844     "Created: / 28-08-2013 / 16:34:53 / cg"
  3845 !
  3845 !
  3846 
  3846 
  3847 withoutSelectorsUnlikelyFor:aClass from:selectorsArg forPartial:partialSelector
  3847 withoutSelectorsUnlikelyFor:aClass from:selectorsArg forPartial:partialSelector
       
  3848     "some heuristics;
       
  3849      as best selectors has been chosen by implemented methods for aClass,
       
  3850      some of them should be filtered (for example, at:/at:put:, which are
       
  3851      found in object, but only make sense for variable objects or those which do
       
  3852      implement at:put: themself.
       
  3853      I have currently no better idea than hardcoding stuff I found irritating..."
       
  3854 
  3848     |selectors noNilChecks noIsXXXChecks noNoXXXChecks|
  3855     |selectors noNilChecks noIsXXXChecks noNoXXXChecks|
  3849 
  3856 
  3850     aClass isNil ifTrue:[ ^ selectorsArg ].
  3857     aClass isNil ifTrue:[ ^ selectorsArg ].
  3851 
  3858 
  3852     noNilChecks := noIsXXXChecks := noNoXXXChecks := false.
  3859     noNilChecks := noIsXXXChecks := noNoXXXChecks := false.
  3853 
  3860 
  3854     selectors := (selectorsArg ? #()) asOrderedCollection.
  3861     selectors := (selectorsArg ? #()) asOrderedCollection.
  3855 
  3862 
  3856     self tracePoint:#cg message:aClass.
  3863     self tracePoint:#cg message:aClass.
  3857 
  3864 
  3858     "/ using True, but actually meaning Boolean here
  3865     "/ actually meaning booleans here
  3859     aClass == True ifTrue:[
  3866     (aClass == True or:[aClass == False]) ifTrue:[
  3860 	noNilChecks := true.
  3867         noNilChecks := true.
  3861 	(partialSelector startsWith:'is') ifFalse:[ noIsXXXChecks := true ].
  3868         (partialSelector startsWith:'is') ifFalse:[ noIsXXXChecks := true ].
  3862 	(partialSelector startsWith:'no') ifFalse:[ noNoXXXChecks := true ].
  3869         (partialSelector startsWith:'no') ifFalse:[ noNoXXXChecks := true ].
  3863     ].
  3870     ].
  3864 
  3871 
  3865     (aClass includesBehavior: ArithmeticValue) ifTrue:[ noNilChecks := true ].
  3872     (aClass includesBehavior: ArithmeticValue) ifTrue:[ noNilChecks := true ].
  3866     (aClass includesBehavior: Block) ifTrue:[ noNilChecks := noIsXXXChecks := noNoXXXChecks := true ].
  3873     (aClass includesBehavior: Block) ifTrue:[ noNilChecks := noIsXXXChecks := noNoXXXChecks := true ].
  3867 
  3874 
  3868     (aClass isMeta) ifTrue:[
  3875     (aClass isMeta) ifTrue:[
  3869 	noNilChecks := true.
  3876         noNilChecks := true.
  3870 	"/ remove messages which are only defined in Object and non-meta classes.
  3877         "/ remove messages which are only defined in Object and non-meta classes.
  3871 	selectors := selectors reject:
  3878         selectors := selectors reject:
  3872 	    [:sel |
  3879             [:sel |
  3873 		(Object implements:sel)
  3880                 (Object implements:sel)
  3874 		and:[ (Smalltalk allImplementorsOf:sel) conform:[:impl | impl isMeta not]]
  3881                 and:[ (Smalltalk allImplementorsOf:sel) conform:[:impl | impl isMeta not]]
  3875 	    ].
  3882             ].
       
  3883     ].
       
  3884 
       
  3885     aClass isVariable ifFalse:[
       
  3886         #( #'at:' #'at:put:' #'basicAt:' #'basicAt:put:' #size #basicSize ) do:[:indexAccessSelector |
       
  3887             (aClass whichClassIncludesSelector:indexAccessSelector) == Object ifTrue:[
       
  3888                 selectors := selectors copyWithout:indexAccessSelector.
       
  3889             ].
       
  3890         ].
  3876     ].
  3891     ].
  3877 
  3892 
  3878     noNilChecks ifTrue:[
  3893     noNilChecks ifTrue:[
  3879 	selectors removeAllFoundIn:#(
  3894         selectors removeAllFoundIn:#(
  3880 		    'isNil' 'notNil'
  3895                     'isNil' 'notNil'
  3881 		    'ifNil:' 'ifNotNil:' 'ifNil:ifNotNil:' 'ifNotNil:ifNil:' 'ifNotNilDo:'
  3896                     'ifNil:' 'ifNotNil:' 'ifNil:ifNotNil:' 'ifNotNil:ifNil:' 'ifNotNilDo:'
  3882 		    'ifEmpty:' 'ifNotEmpty:' 'ifNotEmptyDo:' 'ifEmpty:ifNotEmpty:'
  3897                     'ifEmpty:' 'ifNotEmpty:' 'ifNotEmptyDo:' 'ifEmpty:ifNotEmpty:'
  3883 		    'ifEmpty:ifNotEmptyDo:' 'ifNotEmptyDo:ifEmpty:' 'ifEmptyDo:ifNotEmpty:'
  3898                     'ifEmpty:ifNotEmptyDo:' 'ifNotEmptyDo:ifEmpty:' 'ifEmptyDo:ifNotEmpty:'
  3884 		  ).
  3899                   ).
  3885     ].
  3900     ].
  3886     noIsXXXChecks ifTrue:[
  3901     noIsXXXChecks ifTrue:[
  3887 	"/ get rid of all isXXX selectors
  3902         "/ get rid of all isXXX selectors
  3888 	selectors := selectors reject:[:sel | sel startsWith:'is'].
  3903         selectors := selectors reject:[:sel | sel startsWith:'is'].
  3889     ].
  3904     ].
  3890     noNoXXXChecks ifTrue:[
  3905     noNoXXXChecks ifTrue:[
  3891 	"/ get rid of all notXXX selectors
  3906         "/ get rid of all notXXX selectors
  3892 	selectors := selectors reject:[:sel | sel startsWith:'no'].
  3907         selectors := selectors reject:[:sel | sel startsWith:'no'].
  3893     ].
  3908     ].
  3894 
  3909 
  3895     "/ actually: directly implemented selectors are more likely, so move them to top
  3910     "/ actually: directly implemented selectors are more likely, so move them to top
  3896     selectors := (selectors select:[:sel | aClass implements:sel])
  3911     selectors := (selectors select:[:sel | aClass implements:sel])
  3897 		 ,
  3912                  ,
  3898 		 (selectors reject:[:sel | aClass implements:sel]).
  3913                  (selectors reject:[:sel | aClass implements:sel]).
  3899 
  3914 
  3900     ^ selectors
  3915     ^ selectors
  3901 ! !
  3916 ! !
  3902 
  3917 
  3903 !DoWhatIMeanSupport methodsFor:'code completion-helpers-old'!
  3918 !DoWhatIMeanSupport methodsFor:'code completion-helpers-old'!
  4645 ! !
  4660 ! !
  4646 
  4661 
  4647 !DoWhatIMeanSupport class methodsFor:'documentation'!
  4662 !DoWhatIMeanSupport class methodsFor:'documentation'!
  4648 
  4663 
  4649 version
  4664 version
  4650     ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.208 2014-05-31 10:38:32 cg Exp $'
  4665     ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.209 2014-06-01 11:05:28 cg Exp $'
  4651 !
  4666 !
  4652 
  4667 
  4653 version_CVS
  4668 version_CVS
  4654     ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.208 2014-05-31 10:38:32 cg Exp $'
  4669     ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.209 2014-06-01 11:05:28 cg Exp $'
  4655 ! !
  4670 ! !
  4656 
  4671