# HG changeset patch # User Claus Gittinger # Date 1401620728 -7200 # Node ID ba8cb2c6ef61b81791b3e657bda18009ec7a2913 # Parent 5e2aa5f1ce218ed0ff9dca35c162bef8a181f474 class: DoWhatIMeanSupport changed: #codeCompletionForSmalltalkMethod:orClass:context:codeView:into: #withoutSelectorsUnlikelyFor:from:forPartial: diff -r 5e2aa5f1ce21 -r ba8cb2c6ef61 DoWhatIMeanSupport.st --- a/DoWhatIMeanSupport.st Sat May 31 12:38:32 2014 +0200 +++ b/DoWhatIMeanSupport.st Sun Jun 01 13:05:28 2014 +0200 @@ -1501,7 +1501,7 @@ "/ ]. crsrPos := codeView characterPositionOfCursor. - char := codeView characterAtCharacterPosition:crsrPos. + char := codeView characterAtCharacterPosition:(crsrPos-1 max:1). [crsrPos > 1 and:[char isSeparator "or:['.' includes:char]"]] whileTrue:[ crsrPos := crsrPos - 1. char := codeView characterAtCharacterPosition:crsrPos. @@ -3845,6 +3845,13 @@ ! withoutSelectorsUnlikelyFor:aClass from:selectorsArg forPartial:partialSelector + "some heuristics; + as best selectors has been chosen by implemented methods for aClass, + some of them should be filtered (for example, at:/at:put:, which are + found in object, but only make sense for variable objects or those which do + implement at:put: themself. + I have currently no better idea than hardcoding stuff I found irritating..." + |selectors noNilChecks noIsXXXChecks noNoXXXChecks| aClass isNil ifTrue:[ ^ selectorsArg ]. @@ -3855,47 +3862,55 @@ self tracePoint:#cg message:aClass. - "/ using True, but actually meaning Boolean here - aClass == True ifTrue:[ - noNilChecks := true. - (partialSelector startsWith:'is') ifFalse:[ noIsXXXChecks := true ]. - (partialSelector startsWith:'no') ifFalse:[ noNoXXXChecks := true ]. + "/ actually meaning booleans here + (aClass == True or:[aClass == False]) ifTrue:[ + noNilChecks := true. + (partialSelector startsWith:'is') ifFalse:[ noIsXXXChecks := true ]. + (partialSelector startsWith:'no') ifFalse:[ noNoXXXChecks := true ]. ]. (aClass includesBehavior: ArithmeticValue) ifTrue:[ noNilChecks := true ]. (aClass includesBehavior: Block) ifTrue:[ noNilChecks := noIsXXXChecks := noNoXXXChecks := true ]. (aClass isMeta) ifTrue:[ - noNilChecks := true. - "/ remove messages which are only defined in Object and non-meta classes. - selectors := selectors reject: - [:sel | - (Object implements:sel) - and:[ (Smalltalk allImplementorsOf:sel) conform:[:impl | impl isMeta not]] - ]. + noNilChecks := true. + "/ remove messages which are only defined in Object and non-meta classes. + selectors := selectors reject: + [:sel | + (Object implements:sel) + and:[ (Smalltalk allImplementorsOf:sel) conform:[:impl | impl isMeta not]] + ]. + ]. + + aClass isVariable ifFalse:[ + #( #'at:' #'at:put:' #'basicAt:' #'basicAt:put:' #size #basicSize ) do:[:indexAccessSelector | + (aClass whichClassIncludesSelector:indexAccessSelector) == Object ifTrue:[ + selectors := selectors copyWithout:indexAccessSelector. + ]. + ]. ]. noNilChecks ifTrue:[ - selectors removeAllFoundIn:#( - 'isNil' 'notNil' - 'ifNil:' 'ifNotNil:' 'ifNil:ifNotNil:' 'ifNotNil:ifNil:' 'ifNotNilDo:' - 'ifEmpty:' 'ifNotEmpty:' 'ifNotEmptyDo:' 'ifEmpty:ifNotEmpty:' - 'ifEmpty:ifNotEmptyDo:' 'ifNotEmptyDo:ifEmpty:' 'ifEmptyDo:ifNotEmpty:' - ). + selectors removeAllFoundIn:#( + 'isNil' 'notNil' + 'ifNil:' 'ifNotNil:' 'ifNil:ifNotNil:' 'ifNotNil:ifNil:' 'ifNotNilDo:' + 'ifEmpty:' 'ifNotEmpty:' 'ifNotEmptyDo:' 'ifEmpty:ifNotEmpty:' + 'ifEmpty:ifNotEmptyDo:' 'ifNotEmptyDo:ifEmpty:' 'ifEmptyDo:ifNotEmpty:' + ). ]. noIsXXXChecks ifTrue:[ - "/ get rid of all isXXX selectors - selectors := selectors reject:[:sel | sel startsWith:'is']. + "/ get rid of all isXXX selectors + selectors := selectors reject:[:sel | sel startsWith:'is']. ]. noNoXXXChecks ifTrue:[ - "/ get rid of all notXXX selectors - selectors := selectors reject:[:sel | sel startsWith:'no']. + "/ get rid of all notXXX selectors + selectors := selectors reject:[:sel | sel startsWith:'no']. ]. "/ actually: directly implemented selectors are more likely, so move them to top selectors := (selectors select:[:sel | aClass implements:sel]) - , - (selectors reject:[:sel | aClass implements:sel]). + , + (selectors reject:[:sel | aClass implements:sel]). ^ selectors ! ! @@ -4647,10 +4662,10 @@ !DoWhatIMeanSupport class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.208 2014-05-31 10:38:32 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.209 2014-06-01 11:05:28 cg Exp $' ! version_CVS - ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.208 2014-05-31 10:38:32 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.209 2014-06-01 11:05:28 cg Exp $' ! !