--- a/DoWhatIMeanSupport.st Fri Oct 10 17:14:06 2008 +0200
+++ b/DoWhatIMeanSupport.st Fri Oct 10 17:28:55 2008 +0200
@@ -453,7 +453,7 @@
allVariables allDistances best nodeVal
char start stop oldLen newLen oldVar
getDistanceComputeBlockWithWeight addWithFactorBlock names allTheBest bestAssoc
- globalFactor localFactor selectorOfMessageToNode tree implementors argIdx namesUsed|
+ globalFactor localFactor selectorOfMessageToNode tree implementors argIdx namesUsed kwPart|
nonMetaClass := cls theNonMetaclass.
@@ -516,10 +516,10 @@
factor := 1.
(each startsWith:nm) ifTrue:[
- factor := 4 * nm size.
+ factor := 6 * nm size.
] ifFalse:[
(each asLowercase startsWith:nm asLowercase) ifTrue:[
- factor := 3 * nm size.
+ factor := 4 * nm size.
].
].
dist := dist + (weight*factor).
@@ -537,10 +537,10 @@
].
nm isUppercaseFirst ifTrue:[
- globalFactor := 2.
+ globalFactor := 2. "/ favour globals
localFactor := 1.
] ifFalse:[
- globalFactor := 1.
+ globalFactor := 1. "/ favour locals
localFactor := 2.
].
@@ -560,10 +560,29 @@
ignoreCase:false.
"/ which argument is it
argIdx := node parent arguments indexOf:node.
- namesUsed := (implementors collect:[:eachImplementor |
- (eachImplementor parseTree arguments at:argIdx) name]) asSet.
+ namesUsed := (implementors
+ collect:[:eachImplementor |
+ |parseTree|
+ parseTree := eachImplementor parseTree.
+ (parseTree notNil and:[parseTree arguments size > 0])
+ ifFalse:nil
+ ifTrue:[ (parseTree arguments at:argIdx) name] ]
+ thenSelect:[:a | a notNil]) asSet.
+
+ addWithFactorBlock value:namesUsed value:(2 * localFactor).
- addWithFactorBlock value:namesUsed value:(1 * localFactor).
+ "/ also, look for the keyword before the argument,
+ "/ and see if there is such an instVar
+ "/ if so, add it with -Arg
+ node parent selector isKeyword ifTrue:[
+ kwPart := node parent selector keywords at:argIdx.
+ (cls allInstVarNames includes:(kwPart copyWithoutLast:1)) ifTrue:[
+ addWithFactorBlock
+ value:(cls allInstVarNames collect:[:nm| nm,'Arg'])
+ value:(1 * localFactor).
+ ].
+ ].
+
] ifFalse:[
"/ locals in the block/method
@@ -1672,5 +1691,5 @@
!DoWhatIMeanSupport class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.41 2008-10-10 15:14:06 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.42 2008-10-10 15:28:55 cg Exp $'
! !