--- a/DoWhatIMeanSupport.st Wed Jun 07 17:24:50 2017 +0200
+++ b/DoWhatIMeanSupport.st Mon Jun 12 12:38:58 2017 +0200
@@ -3173,16 +3173,16 @@
char getDistanceComputeBlockWithWeight addWithFactorBlock allTheBest bestAssoc
globalFactor localFactor selectorOfMessageToNode implementors argIdx namesUsed kwPart editActions suggestions nameIsOK longerNames setOfNames otherArgNames
suggestionsWithInfo isLeftSideOfAssignment|
-
+
"/ Transcript show:'var in '; show:methodOrNil; show:' / '; showCR:classOrNil.
classOrNil notNil ifTrue:[
nonMetaClass := classOrNil theNonMetaclass.
].
-
+
nm := node name.
parent := node parent.
isLeftSideOfAssignment := false.
-
+
(parent notNil) ifTrue:[
(parent isMessage) ifTrue:[
node == parent receiver ifTrue:[
@@ -3191,16 +3191,16 @@
] ifFalse:[
(parent isAssignment) ifTrue:[
isLeftSideOfAssignment := (node == node parent variable).
- ].
- ].
- ].
-
+ ].
+ ].
+ ].
+
crsrPos := codeView characterPositionOfCursor.
-
+
"/ if we are behind the variable and a space has already been entered,
"/ the user is probably looking for a message selector.
"/ If the variable represents a global, present its instance creation messages
- char := codeView characterBeforeCursor.
+ char := codeView characterBeforeCursor.
(isLeftSideOfAssignment not and:[char == Character space]) ifTrue:[
nm knownAsSymbol ifTrue:[
@@ -3214,7 +3214,7 @@
selectors1 := OrderedSet new.
selectors2 := OrderedSet new.
- nodeVal class
+ nodeVal class
withAllSuperclassesDo:[:cls |
cls methodDictionary keysAndValuesDo:[:sel :mthd |
|cat|
@@ -3225,11 +3225,11 @@
"/ other category: look if it sends new, new: etc.
(mthd messagesSent includesAny:#(new new: basicNew basicNew:)) ifTrue:[
selectors2 add:sel
- ].
+ ].
]
]
].
-
+
selectors := selectors1 order sort , #('-') , selectors2 order sort.
editActions := selectors collect:[:word | self editActionToInsert:word].
actionBlock value:selectors value:editActions value:nil.
@@ -3249,7 +3249,7 @@
].
].
].
-
+
"/ this is pure voodoo magic (tries to make a good spelling weight,
"/ by weighting the number of startsWith characters into the spelling distance...)
getDistanceComputeBlockWithWeight :=
@@ -3264,15 +3264,15 @@
(each includesString:nm) ifTrue:[
(each startsWith:nm) ifTrue:[
factor := 6 * weight * nm size.
- ] ifFalse:[
+ ] ifFalse:[
(each endsWith:nm) ifTrue:[
factor := 5 * weight * nm size.
] ifFalse:[
nm size > 1 ifTrue:[
factor := 4 * weight * nm size
- ].
- ].
- ].
+ ].
+ ].
+ ].
] ifFalse:[
(each includesString:nm caseSensitive:false) ifTrue:[
(each asLowercase startsWith:nm asLowercase) ifTrue:[
@@ -3287,7 +3287,7 @@
]
]
]
- ].
+ ].
dist := dist + (weight*factor).
each -> (dist * weight)
@@ -3365,8 +3365,8 @@
].
].
tryClassNamesWith notNil ifTrue:[
- addWithFactorBlock
- value:(Smalltalk keys
+ addWithFactorBlock
+ value:(Smalltalk keys
collect:[:className | tryClassNamesWith,className]
thenSelect:[:name | name startsWith:nm])
value:(1.5 * localFactor)
@@ -3395,10 +3395,10 @@
ifTrue:[ otherArgNames addAll:(parseTree arguments collect:[:each | each name])] ].
addWithFactorBlock value:otherArgNames value:(1.5 * localFactor).
].
- addWithFactorBlock
- value:(codeView previousReplacements
+ addWithFactorBlock
+ value:(codeView previousReplacements
collect:[:p | p value asString]
- thenSelect:[:s | s isValidSmalltalkIdentifier])
+ thenSelect:[:s | s isValidSmalltalkIdentifier])
value:(1.3 * localFactor).
] ifFalse:[
"/ locals in the block/method
@@ -3437,11 +3437,11 @@
"/ (further down the code), add them also
tree variableNodesDo:[:var |
|name|
-
+
name := var name.
(name first isLowercase or:[isLeftSideOfAssignment not]) ifTrue:[
(setOfNames includes:name) ifFalse:[
- names add:name.
+ names add:name.
setOfNames add:name
]
]
@@ -3466,7 +3466,7 @@
selectorOfMessageToNode notNil ifTrue:[
|responders nonResponders|
- "/ responding to that messsage
+ "/ responding to that message
"/ self halt.
classOrNil notNil ifTrue:[
"/ private classes
@@ -3520,7 +3520,7 @@
addWithFactorBlock value:responders value:(1.5 * globalFactor).
addWithFactorBlock value:nonResponders value:(0.5 * 1.5 * globalFactor).
].
-
+
isLeftSideOfAssignment ifFalse:[ "/ no, we will not suggest assigning to pool vars
classOrNil notNil ifTrue:[
"/ pool variables
@@ -3541,19 +3541,19 @@
]
] ifFalse:[
classOrNil notNil ifTrue:[
- isLeftSideOfAssignment ifFalse:[
+ isLeftSideOfAssignment ifFalse:[
"/ private classes
addWithFactorBlock value:(nonMetaClass privateClasses collect:[:cls | cls nameWithoutPrefix])
value:(2.75 * globalFactor).
].
-
+
"/ class variables
addWithFactorBlock value:nonMetaClass classVarNames value:(3.0 * globalFactor).
nonMetaClass superclass notNil ifTrue:[
addWithFactorBlock value:nonMetaClass superclass allClassVarNames value:(2.5 * globalFactor).
].
- isLeftSideOfAssignment ifFalse:[
+ isLeftSideOfAssignment ifFalse:[
"/ namespace vars
classOrNil topNameSpace ~~ Smalltalk ifTrue:[
names := classOrNil topNameSpace keys.
@@ -3585,7 +3585,7 @@
].
].
- isLeftSideOfAssignment ifFalse:[
+ isLeftSideOfAssignment ifFalse:[
"/ globals
names := OrderedCollection new.
Smalltalk keysDo:[:k |
@@ -3595,7 +3595,7 @@
names add:k
]
].
-
+
"/ only consider all globals, if the first char of the completed name is uppercase;
"/ otherwise, only consider names with a caseInsensitve prefix match
nm first isUppercase ifFalse:[
@@ -3605,7 +3605,7 @@
].
].
- isLeftSideOfAssignment ifFalse:[
+ isLeftSideOfAssignment ifFalse:[
"/ pseudos - assuming that thisContext is seldom used.
"/ also assuming, that nil is short so its usually typed in.
addWithFactorBlock value:#('self') value:(2.5 * localFactor).
@@ -3666,7 +3666,7 @@
"/ "/ remove all those which are below some threshold or are a prefix
"/ 0.2 to:0.9 by:0.1 do:[:delta |
"/ |bestValue n|
-"/
+"/
"/ "/ if still too many, remove more and more
"/ allTheBest size > 50 ifTrue:[
"/ bestValue := bestAssoc value * delta.
@@ -3707,8 +3707,8 @@
].
].
- suggestionsWithInfo :=
- suggestions
+ suggestionsWithInfo :=
+ suggestions
collect:[:eachName |
|val kind valAndKind printString|
@@ -3743,12 +3743,13 @@
editActions := suggestions collect:[:word |
self editActionToReplaceNode:node by:word.
- ].
+ ].
actionBlock value:suggestionsWithInfo value:editActions value:nil.
"Created: / 10-11-2006 / 13:16:33 / cg"
"Modified: / 16-02-2010 / 10:13:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 05-05-2017 / 17:20:35 / cg"
+ "Modified (comment): / 12-06-2017 / 12:34:46 / mawalch"
!
editActionToInsert:aString
@@ -5279,9 +5280,9 @@
] ifFalse:[
(each asLowercase endsWith:nm asLowercase) ifTrue:[
factor := 2 * nm size.
- ]
- ]
- ]
+ ]
+ ]
+ ]
].
dist := dist + (weight*factor).
@@ -5379,7 +5380,7 @@
selectorOfMessageToNode notNil ifTrue:[
|names responders nonResponders|
- "/ responding to that messsage
+ "/ responding to that message
classOrNil notNil ifTrue:[
"/ private classes
@@ -5535,6 +5536,7 @@
"Created: / 10-11-2006 / 13:16:33 / cg"
"Modified: / 16-02-2010 / 10:13:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 28-08-2013 / 15:37:28 / cg"
+ "Modified (format): / 12-06-2017 / 12:37:31 / mawalch"
! !
!DoWhatIMeanSupport methodsFor:'helpers-naive type inference'!