DoWhatIMeanSupport.st
changeset 5637 c37992ea83d4
parent 5633 f888f84e67f7
child 5658 22ffe8e819d6
equal deleted inserted replaced
5636:b62d9b527098 5637:c37992ea83d4
  2936      selectorSoFar matchingSelectors
  2936      selectorSoFar matchingSelectors
  2937      selectors allExistingMethods nameBag namesByCount 
  2937      selectors allExistingMethods nameBag namesByCount 
  2938      allSelectors
  2938      allSelectors
  2939      selectorsForIsXXXTests selectorsSentInClass selectorsImplementedInSuper 
  2939      selectorsForIsXXXTests selectorsSentInClass selectorsImplementedInSuper 
  2940      editAction editActionForArg argNames selectorsForVars
  2940      editAction editActionForArg argNames selectorsForVars
  2941      selectorTypedSoFar addIfNotYetImplemented alreadyOK processMenu|
  2941      selectorTypedSoFar selectorTypedSoFarLC addIfNotYetImplemented alreadyOK processMenu|
  2942 
  2942 
  2943     allSelectors := Set new.
  2943     allSelectors := Set new.
  2944 
  2944 
  2945     "/ Transcript showCR:'m'.
  2945     "/ Transcript showCR:'m'.
  2946     crsrLine := codeView cursorLine.
  2946     crsrLine := codeView cursorLine.
  2947     crsrCol := codeView cursorCol.
  2947     crsrCol := codeView cursorCol.
  2948     crsrPos := codeView characterPositionOfCursor - 1.
  2948     crsrPos := codeView characterPositionOfCursor - 1.
  2949 
  2949 
  2950     selectorTypedSoFar := node selector.
  2950     selectorTypedSoFar := node selector.
       
  2951     selectorTypedSoFarLC := selectorTypedSoFar asLowercase.
       
  2952     
  2951     selectorTypedSoFar isUnarySelector ifTrue:[
  2953     selectorTypedSoFar isUnarySelector ifTrue:[
  2952         "/ user has just begun to edit a selector.
  2954         "/ user has just begun to edit a selector.
  2953         "/ often, a good completion are the names of instVars for which no corresponding getter/setter exists
  2955         "/ often, a good completion are the names of instVars for which no corresponding getter/setter exists
  2954         classOrNil notNil ifTrue:[
  2956         classOrNil notNil ifTrue:[
  2955             selectorsForVars := Set new.
  2957             selectorsForVars := Set new.
  2957             selectorsSentInClass := Set new.
  2959             selectorsSentInClass := Set new.
  2958             selectorsForIsXXXTests := Set new.
  2960             selectorsForIsXXXTests := Set new.
  2959             
  2961             
  2960             addIfNotYetImplemented :=
  2962             addIfNotYetImplemented :=
  2961                 [:list :sel |
  2963                 [:list :sel |
  2962                     sel ~= selectorTypedSoFar ifTrue:[    
  2964                 sel = 'max:' ifTrue:[self halt].
       
  2965                     (sel sameAs: selectorTypedSoFar) ifFalse:[    
  2963                         (allSelectors includes:sel) ifFalse:[
  2966                         (allSelectors includes:sel) ifFalse:[
  2964                             (classOrNil implements:sel asSymbol) ifFalse:[ 
  2967                             (classOrNil implements:sel asSymbol) ifFalse:[ 
  2965                                 list add:sel.
  2968                                 list add:sel.
  2966                                 allSelectors add:sel.
  2969                                 allSelectors add:sel.
  2967                             ].
  2970                             ].
  2978             classOrNil isMeta ifTrue:[
  2981             classOrNil isMeta ifTrue:[
  2979                 classOrNil theNonMetaclass classVarNames do:[:nm |
  2982                 classOrNil theNonMetaclass classVarNames do:[:nm |
  2980                     |nmSel|
  2983                     |nmSel|
  2981 
  2984 
  2982                     nmSel := nm asLowercaseFirst.
  2985                     nmSel := nm asLowercaseFirst.
  2983                     (nmSel startsWith:selectorTypedSoFar) ifTrue:[
  2986                     (nmSel startsWith:selectorTypedSoFarLC) ifTrue:[
  2984                         addIfNotYetImplemented value:selectorsForVars value:nmSel.
  2987                         addIfNotYetImplemented value:selectorsForVars value:nmSel.
  2985                         addIfNotYetImplemented value:selectorsForVars value:(nmSel,':').
  2988                         addIfNotYetImplemented value:selectorsForVars value:(nmSel,':').
  2986                     ]
  2989                     ]
  2987                 ].
  2990                 ].
  2988             ] ifFalse:[
  2991             ] ifFalse:[
  3120     ].  
  3123     ].  
  3121     alreadyOK := matchingSelectors includes:selectorTypedSoFar.
  3124     alreadyOK := matchingSelectors includes:selectorTypedSoFar.
  3122     matchingSelectors remove:selectorTypedSoFar ifAbsent:[].
  3125     matchingSelectors remove:selectorTypedSoFar ifAbsent:[].
  3123     
  3126     
  3124     selectors := Set new.
  3127     selectors := Set new.
  3125     selectors addAll:matchingSelectors.
       
  3126             
  3128             
  3127     selectorsForVars notNil ifTrue:[ selectors addAll:selectorsForVars ].
  3129     selectorsForVars notNil ifTrue:[ 
       
  3130         selectors addAll:selectorsForVars 
       
  3131     ].
  3128     selectorsSentInClass notNil ifTrue:[ selectors addAll:selectorsSentInClass ].
  3132     selectorsSentInClass notNil ifTrue:[ selectors addAll:selectorsSentInClass ].
  3129     selectorsImplementedInSuper notNil ifTrue:[ selectors addAll:selectorsImplementedInSuper ].
  3133     selectorsImplementedInSuper notNil ifTrue:[ selectors addAll:selectorsImplementedInSuper ].
  3130     selectorsForIsXXXTests notNil ifTrue:[ selectors addAll:selectorsForIsXXXTests ].
  3134     selectorsForIsXXXTests notNil ifTrue:[ selectors addAll:selectorsForIsXXXTests ].
  3131         
  3135         
       
  3136     (selectors count:[:sel | sel asLowercase startsWith:selectorTypedSoFarLC]) == 0 ifTrue:[
       
  3137         selectors addAll:matchingSelectors.
       
  3138     ].    
       
  3139 
  3132     selectors := selectors asOrderedCollection.
  3140     selectors := selectors asOrderedCollection.
  3133     selectors sort:[:a :b | a size < b size].
  3141     selectors sort:[:a :b | a size < b size].
       
  3142 
       
  3143     selectorsSentInClass notEmptyOrNil ifTrue:[
       
  3144         selectors := self 
       
  3145                         splitSelectorList:selectors 
       
  3146                         by:[:sel | selectorsSentInClass includes:sel].
       
  3147     ].
       
  3148     selectorsImplementedInSuper notEmptyOrNil ifTrue:[
       
  3149         selectors := self 
       
  3150                         splitSelectorList:selectors 
       
  3151                         by:[:sel | selectorsImplementedInSuper includes:sel].
       
  3152     ].
       
  3153 
       
  3154     selectors := self 
       
  3155                     splitSelectorList:selectors 
       
  3156                     by:[:sel | sel asLowercase startsWith:selectorTypedSoFarLC].
       
  3157 
  3134     selectorsForVars notEmptyOrNil ifTrue:[
  3158     selectorsForVars notEmptyOrNil ifTrue:[
  3135         selectors := self 
  3159         selectors := self 
  3136                         splitSelectorList:selectors 
  3160                         splitSelectorList:selectors 
  3137                         by:[:sel | selectorsForVars includes:sel].
  3161                         by:[:sel | selectorsForVars includes:sel].
  3138     ].
       
  3139     selectorsSentInClass notEmptyOrNil ifTrue:[
       
  3140         selectors := self 
       
  3141                         splitSelectorList:selectors 
       
  3142                         by:[:sel | selectorsSentInClass includes:sel].
       
  3143     ].
       
  3144     selectorsImplementedInSuper notEmptyOrNil ifTrue:[
       
  3145         selectors := self 
       
  3146                         splitSelectorList:selectors 
       
  3147                         by:[:sel | selectorsImplementedInSuper includes:sel].
       
  3148     ].
  3162     ].
  3149     selectorsForIsXXXTests notEmptyOrNil ifTrue:[
  3163     selectorsForIsXXXTests notEmptyOrNil ifTrue:[
  3150         selectors := self 
  3164         selectors := self 
  3151                         splitSelectorList:selectors 
  3165                         splitSelectorList:selectors 
  3152                         by:[:sel | selectorsForIsXXXTests includes:sel].
  3166                         by:[:sel | selectorsForIsXXXTests includes:sel].
  3236         value:'selector'.
  3250         value:'selector'.
  3237 
  3251 
  3238     "Modified: / 04-07-2006 / 18:48:26 / fm"
  3252     "Modified: / 04-07-2006 / 18:48:26 / fm"
  3239     "Created: / 10-11-2006 / 13:46:44 / cg"
  3253     "Created: / 10-11-2006 / 13:46:44 / cg"
  3240     "Modified: / 16-02-2010 / 10:13:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  3254     "Modified: / 16-02-2010 / 10:13:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  3241     "Modified: / 10-09-2017 / 14:51:26 / cg"
  3255     "Modified: / 19-11-2017 / 14:47:34 / cg"
  3242 !
  3256 !
  3243 
  3257 
  3244 codeCompletionForTempVariable:node into:actionBlock
  3258 codeCompletionForTempVariable:node into:actionBlock
  3245 !
  3259 !
  3246 
  3260