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'! |