--- a/DoWhatIMeanSupport.st Wed Jun 11 11:30:05 2014 +0200
+++ b/DoWhatIMeanSupport.st Wed Jun 11 19:24:04 2014 +0200
@@ -2578,165 +2578,166 @@
crsrPos := codeView characterPositionOfCursor - 1.
node selector isUnarySelector ifTrue:[
- "/ user has just begun to edit a selector.
- "/ often, a good completion are the names of instVars for which no corresponding getter/setter exists
- classOrNil notNil ifTrue:[
- selectorsForVars := OrderedCollection new.
- classOrNil instVarNames do:[:nm |
- (nm startsWith:node selector) ifTrue:[
- (classOrNil implements:nm asSymbol) ifFalse:[ selectorsForVars add:nm].
- (classOrNil implements:nm asMutator) ifFalse:[ selectorsForVars add:(nm,':')].
- ]
- ].
- classOrNil isMeta ifTrue:[
- classOrNil theNonMetaclass classVarNames do:[:nm |
- |nmSel|
-
- nmSel := nm asLowercaseFirst.
- (nmSel startsWith:node selector) ifTrue:[
- (classOrNil implements:nmSel asSymbol) ifFalse:[ selectorsForVars add:nmSel].
- (classOrNil implements:nmSel asMutator) ifFalse:[ selectorsForVars add:(nmSel,':')].
- ]
- ].
- ] ifFalse:[
- "/ isXXX ?
- (('is',classOrNil nameWithoutPrefix) startsWith:node selector ) ifTrue:[
- selectors0 add:('is',classOrNil nameWithoutPrefix).
- ].
- ].
- ].
+ "/ user has just begun to edit a selector.
+ "/ often, a good completion are the names of instVars for which no corresponding getter/setter exists
+ classOrNil notNil ifTrue:[
+ selectorsForVars := OrderedCollection new.
+ classOrNil instVarNames do:[:nm |
+ (nm startsWith:node selector) ifTrue:[
+ (classOrNil implements:nm asSymbol) ifFalse:[ selectorsForVars add:nm].
+ (classOrNil implements:nm asMutator) ifFalse:[ selectorsForVars add:(nm,':')].
+ ]
+ ].
+ classOrNil isMeta ifTrue:[
+ classOrNil theNonMetaclass classVarNames do:[:nm |
+ |nmSel|
+
+ nmSel := nm asLowercaseFirst.
+ (nmSel startsWith:node selector) ifTrue:[
+ (classOrNil implements:nmSel asSymbol) ifFalse:[ selectorsForVars add:nmSel].
+ (classOrNil implements:nmSel asMutator) ifFalse:[ selectorsForVars add:(nmSel,':')].
+ ]
+ ].
+ ] ifFalse:[
+ "/ isXXX ?
+ (('is',classOrNil nameWithoutPrefix) startsWith:node selector ) ifTrue:[
+ selectors0 add:('is',classOrNil nameWithoutPrefix).
+ ].
+ ].
+ ].
].
selectorSoFar := ''.
node selectorParts doWithIndex:[:partToken :argNr|
- |part|
-
- part := partToken value.
- selectorSoFar := selectorSoFar , part.
-
- (crsrPos >= partToken start
- and:[crsrPos <= partToken stop]) ifTrue:[
- (classOrNil notNil and:[classOrNil isMeta]) ifTrue:[
- matchingSelectors := Smalltalk allClasses
- inject:(Set new)
- into:[:theSet :eachClass |
- |md|
-
- md := eachClass theMetaclass methodDictionary.
- theSet addAll:(md keys select:[:sel |sel startsWith:selectorSoFar]).
- theSet.
- ].
- "/ dont forget the stuff in the class-line
- Metaclass withAllSuperclassesDo:[:cls |
- matchingSelectors addAll:(cls methodDictionary keys select:[:sel |sel startsWith:selectorSoFar]).
- ].
- ] ifFalse:[
- matchingSelectors := Smalltalk allClasses
- inject:(Set new)
- into:[:theSet :eachClass |
- |md|
-
- md := eachClass theNonMetaclass methodDictionary.
- theSet addAll:(md keys select:[:sel |sel startsWith:selectorSoFar]).
- theSet.
- ].
- ].
-
- selectors addAll:matchingSelectors.
- selectorsForVars notNil ifTrue:[ selectors addAll:selectorsForVars ].
-
- selectors := selectors sort:[:a :b | a size < b size].
- selectors size > 100 ifTrue:[
- selectors := selectors copyTo:100.
- ].
-
-
- "/ if there is only one, and user has already entered it, he might want to complete the argument-name
- (selectors size == 1
- and:[selectors first = selectorSoFar]) ifTrue:[
- selectorSoFar numArgs == 0 ifTrue:[ ^ self ].
-
- allExistingMethods := (Smalltalk allImplementorsOf:selectorSoFar asSymbol)
- collect:[:cls | cls compiledMethodAt:selectorSoFar asSymbol].
- nameBag := Bag new.
- allExistingMethods do:[:eachMethod | nameBag addAll:(eachMethod methodArgNames ? #())].
- namesByCount := nameBag valuesAndCounts sort:[:a :b | a value < b value].
- "/ take the one which occurs most often
- "/ best := self askUserForCompletion:'argument' for:codeView at: node start from:(namesByCount collect:[:a | a key]).
- argNames := (namesByCount collect:[:a | a key]).
- editAction :=
- [:chosenIndex |
- |chosenName|
-
- chosenName := argNames at:chosenIndex.
- codeView
- undoableDo:[
- (crsrPos+1) >= codeView contents size ifTrue:[
- codeView paste:best.
- codeView cursorToCharacterPosition:(crsrPos + chosenName size - 1).
- ] ifFalse:[
- codeView cursorToCharacterPosition:crsrPos.
- codeView cursorRight.
- codeView insertStringAtCursor:chosenName.
- codeView selectFromCharacterPosition:crsrPos+1 to:crsrPos+1+chosenName size-1.
- codeView dontReplaceSelectionOnInput
- ].
- ]
- info:'completion'.
- ].
- actionBlock
- value:argNames
- value:editAction
- value:'argument'.
-
- ^ self.
-
- ].
-
- "the ones implemented in superclasses are shown first"
- classOrNil notNil ifTrue:[
- selectors1 := selectors select:[:sel | classOrNil respondsTo:sel]. "/ in super
- selectors2 := selectors reject:[:sel | selectors1 includes:sel ]. "/ not in super
- ] ifFalse:[
- selectors1 := selectors
- ].
-
- distances := selectors1 collect:[:each | each spellAgainst:selectorSoFar].
- distances sortWith:selectors1.
- selectors1 reverse.
- selectors := selectors1.
-
- selectors2 notEmptyOrNil ifTrue:[
- distances := selectors2 collect:[:each | each spellAgainst:selectorSoFar].
- distances sortWith:selectors2.
- selectors2 reverse.
- selectors1 := selectors1 collect:[:sel | sel allBold].
- selectors := selectors1,selectors2.
- ].
- selectors0 notEmptyOrNil ifTrue:[
- selectors := selectors0,selectors.
- ].
-
- editAction :=
- [:selectedCompletionIndex |
-
- best := selectors at:selectedCompletionIndex.
- rest := best copyFrom:selectorSoFar size + 1.
- codeView
- undoableDo:[
- codeView insertString:rest atLine:crsrLine col:crsrCol.
- ]
- info:'Completion'.
- codeView cursorToCharacterPosition:(crsrPos+1 + rest size - 1).
- codeView cursorRight. "/ kludge to make it visible
- ].
-
- "/ best := self askUserForCompletion:'selector' for:codeView at:(node start) from:selectors.
- actionBlock
- value:selectors
- value:editAction
- value:'selector'.
- ].
+ |part|
+
+ part := partToken value.
+ selectorSoFar := selectorSoFar , part.
+
+ (crsrPos >= partToken start
+ and:[crsrPos <= partToken stop]) ifTrue:[
+ (classOrNil notNil and:[classOrNil isMeta]) ifTrue:[
+ matchingSelectors := Smalltalk allClasses
+ inject:(Set new)
+ into:[:theSet :eachClass |
+ |md|
+
+ md := eachClass theMetaclass methodDictionary.
+ theSet addAll:(md keys select:[:sel |sel startsWith:selectorSoFar]).
+ theSet.
+ ].
+ "/ dont forget the stuff in the class-line
+ Metaclass withAllSuperclassesDo:[:cls |
+ matchingSelectors addAll:(cls methodDictionary keys select:[:sel |sel startsWith:selectorSoFar]).
+ ].
+ ] ifFalse:[
+ matchingSelectors := Smalltalk allClasses
+ inject:(Set new)
+ into:[:theSet :eachClass |
+ |md|
+
+ md := eachClass theNonMetaclass methodDictionary.
+ theSet addAll:(md keys select:[:sel |sel startsWith:selectorSoFar]).
+ theSet.
+ ].
+ ].
+
+ selectors addAll:matchingSelectors.
+ selectorsForVars notNil ifTrue:[ selectors addAll:selectorsForVars ].
+
+ selectors := selectors sort:[:a :b | a size < b size].
+ selectors size > 100 ifTrue:[
+ selectors := selectors copyTo:100.
+ ].
+
+
+ "/ if there is only one, and user has already entered it,
+ "/ he might want to complete the argument-name
+ (selectors size == 1
+ and:[selectors first = selectorSoFar]) ifTrue:[
+ selectorSoFar numArgs == 0 ifTrue:[ ^ self ].
+
+ allExistingMethods := (Smalltalk allImplementorsOf:selectorSoFar asSymbol)
+ collect:[:cls | cls compiledMethodAt:selectorSoFar asSymbol].
+ nameBag := Bag new.
+ allExistingMethods do:[:eachMethod | nameBag addAll:(eachMethod methodArgNames ? #())].
+ namesByCount := nameBag valuesAndCounts sort:[:a :b | a value < b value].
+ "/ take the one which occurs most often
+ "/ best := self askUserForCompletion:'argument' for:codeView at: node start from:(namesByCount collect:[:a | a key]).
+ argNames := (namesByCount collect:[:a | a key]).
+ editAction :=
+ [:chosenIndex |
+ |chosenName|
+
+ chosenName := argNames at:chosenIndex.
+ codeView
+ undoableDo:[
+ (crsrPos+1) >= codeView contents size ifTrue:[
+ codeView paste:chosenName.
+ codeView cursorToCharacterPosition:(crsrPos + chosenName size - 1).
+ ] ifFalse:[
+ codeView cursorToCharacterPosition:crsrPos.
+ codeView cursorRight.
+ codeView insertStringAtCursor:chosenName.
+ codeView selectFromCharacterPosition:crsrPos+1 to:crsrPos+1+chosenName size-1.
+ codeView dontReplaceSelectionOnInput
+ ].
+ ]
+ info:'completion'.
+ ].
+ actionBlock
+ value:argNames
+ value:editAction
+ value:'argument'.
+
+ ^ self.
+
+ ].
+
+ "the ones implemented in superclasses are shown first"
+ classOrNil notNil ifTrue:[
+ selectors1 := selectors select:[:sel | classOrNil respondsTo:sel]. "/ in super
+ selectors2 := selectors reject:[:sel | selectors1 includes:sel ]. "/ not in super
+ ] ifFalse:[
+ selectors1 := selectors
+ ].
+
+ distances := selectors1 collect:[:each | each spellAgainst:selectorSoFar].
+ distances sortWith:selectors1.
+ selectors1 reverse.
+ selectors := selectors1.
+
+ selectors2 notEmptyOrNil ifTrue:[
+ distances := selectors2 collect:[:each | each spellAgainst:selectorSoFar].
+ distances sortWith:selectors2.
+ selectors2 reverse.
+ selectors1 := selectors1 collect:[:sel | sel allBold].
+ selectors := selectors1,selectors2.
+ ].
+ selectors0 notEmptyOrNil ifTrue:[
+ selectors := selectors0,selectors.
+ ].
+
+ editAction :=
+ [:selectedCompletionIndex |
+
+ best := selectors at:selectedCompletionIndex.
+ rest := best copyFrom:selectorSoFar size + 1.
+ codeView
+ undoableDo:[
+ codeView insertString:rest atLine:crsrLine col:crsrCol.
+ ]
+ info:'Completion'.
+ codeView cursorToCharacterPosition:(crsrPos+1 + rest size - 1).
+ codeView cursorRight. "/ kludge to make it visible
+ ].
+
+ "/ best := self askUserForCompletion:'selector' for:codeView at:(node start) from:selectors.
+ actionBlock
+ value:selectors
+ value:editAction
+ value:'selector'.
+ ].
].
"Modified: / 04-07-2006 / 18:48:26 / fm"
@@ -4692,10 +4693,10 @@
!DoWhatIMeanSupport class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.211 2014-06-10 11:54:39 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.212 2014-06-11 17:24:04 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.211 2014-06-10 11:54:39 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.212 2014-06-11 17:24:04 cg Exp $'
! !