diff -r 2bdb9d15ed44 -r 90f7571df306 DoWhatIMeanSupport.st --- a/DoWhatIMeanSupport.st Wed Jul 24 12:00:49 2013 +0200 +++ b/DoWhatIMeanSupport.st Wed Jul 24 12:29:08 2013 +0200 @@ -1116,14 +1116,17 @@ crsrPos := codeView characterPositionOfCursor"-1". char := codeView characterAtCharacterPosition:crsrPos. + "/ Transcript show:crsrPos; show:' '; showCR:char. [crsrPos > 1 and:[char isSeparator or:['.' includes:char]]] whileTrue:[ crsrPos := crsrPos - 1. char := codeView characterAtCharacterPosition:crsrPos. ]. interval := codeView selectedInterval. + "/ Transcript show:'iv: '; showCR:interval. interval isEmpty ifTrue:[ - interval := crsrPos-1 to:crsrPos. + interval := crsrPos"-1" to:crsrPos. + "/ Transcript show:'iv2: '; showCR:interval. ]. source := codeView contentsAsString string. @@ -1138,9 +1141,11 @@ "/ that will also work for syntactic incorrect source code. classOrNil notNil ifTrue:[ node := self findNodeForInterval:interval in:source allowErrors:true mustBeMethod:true. + "/ Transcript show:'nd1: '; showCR:node. ]. node isNil ifTrue:[ node := self findNodeForInterval:interval in:source allowErrors:true mustBeMethod:false. + "/ Transcript show:'nd2: '; showCR:node. ]. "/ [node isNil] whileTrue:[ "/ "/ expand to the left ... @@ -1215,7 +1220,7 @@ LastChoices notNil ifTrue:[ lastChoice := LastChoices at:what ifAbsent:nil. lastChoice notNil ifTrue:[ - list := { lastChoice. nil } , (list copyWithout:lastChoice). + list := { lastChoice allBold } , (list copyWithout:lastChoice). ]. ]. choice := Tools::CodeCompletionMenu @@ -1226,7 +1231,7 @@ LastChoices := Dictionary new. ]. LastChoices at:what put:choice. - ^ choice + ^ choice string "Created: / 16-02-2010 / 10:09:57 / Jan Vrany " "Modified (format): / 08-07-2011 / 08:49:35 / cg" @@ -2525,7 +2530,9 @@ |nodes| allowErrors ifTrue:[ - firstIntersectingNode notNil ifTrue:[^ firstIntersectingNode]. + firstIntersectingNode notNil ifTrue:[ + ^ firstIntersectingNode + ]. nodesSoFar notNil ifTrue:[ nodes := nodesSoFar asOrderedCollection collect:[:nd | nd whichNodeIntersects:interval] @@ -2722,7 +2729,7 @@ lastChoice := LastChoices at:what ifAbsent:nil. lastChoice notNil ifTrue:[ (list includes: lastChoice) ifTrue:[ - list := {lastChoice. nil. } , (list copyWithout:lastChoice). + list := {lastChoice allBold } , (list copyWithout:lastChoice). ] ]. ]. @@ -2759,6 +2766,7 @@ title:(resources string:'Code completion'). choice isNil ifTrue:[^ nil]. ]. + choice := choice string. LastChoices isNil ifTrue:[ LastChoices := Dictionary new. @@ -2858,10 +2866,11 @@ newParts nSelParts oldLen newLen selectorParts findBest parentNode selectorInBest selector2InBest2 parser selectorsSentInCode split - varName rbTypes| + varName rbTypes rbType| RefactoryTyper notNil ifTrue:[ - "/ refactory package also provides a (very limited) typer + "/ refactory package also provides a (very limited) typer; + "/ ask it for its oppinion as well (temporary - will vanish, once we have a better typer) (node receiver isVariable) ifTrue:[ varName := node receiver name. tree := RBParser @@ -2873,9 +2882,20 @@ in: tree model: nil ignoredSelectors:(Array with:node selector). - - rbTypes size == 1 ifTrue:[ - bestSelectorsFromRB := Parser findBest:30 selectorsFor:node selector in:(rbTypes first) forCompletion:true. + rbTypes size > 0 ifTrue:[ + rbTypes size > 1 ifTrue:[ + rbTypes remove:ProtoObject ifAbsent:[]. + rbTypes remove:Autoload ifAbsent:[]. + rbTypes remove:ObsoleteObject ifAbsent:[]. + ]. + rbTypes size == 1 ifTrue:[ + rbType := rbTypes first. + ] ifFalse:[ + rbType := Class commonSuperclassOf:rbTypes + ]. + (rbType notNil and:[rbType ~= Object]) ifTrue:[ + bestSelectorsFromRB := Parser findBest:30 selectorsFor:node selector in:rbType forCompletion:true. + ]. ] ] ]. @@ -2917,7 +2937,17 @@ "/ srchClass2 := self lookupClassForMessage:parentNode inClass:classOrNil. selector2 := selector2,selector. bestSelectors2 := findBest value:parentNode value:selector2. - ]. + ] ifFalse:[ + "/ also, if nothing was found + (bestSelectors isEmpty + and:[ parentNode notNil + and:[ parentNode isMessage ]]) ifTrue:[ + "/ srchClass2 := self lookupClassForMessage:parentNode inClass:classOrNil. + "/ selector2 := selector2,selector. + bestSelectors := findBest value:parentNode value:selector. + ] + ]. + bestSelectors := (bestSelectorsFromRB ? #()) , bestSelectors. @@ -3088,6 +3118,21 @@ ]. codeView cursorToCharacterPosition:newCursorPosition. codeView cursorRight. "/ avoid going to the next line !! + ((best endsWith:':') and:[numArgs == 1]) ifTrue:[ + |impls| + + "/ see if it expects a block argument (heuristic) + best := best asSymbol. + impls := Smalltalk allImplementorsOf:best. + (impls contains:[:cls | + |argName| + + argName := ((cls compiledMethodAt:best) methodArgAndVarNames at:1) asLowercase. + (argName includesString:'block') or:[ (argName includesString:'action')]] + ) ifTrue:[ + codeView insertStringAtCursor:'[' + ]. + ]. codeView dontReplaceSelectionOnInput. ] info:'Completion'. @@ -3444,10 +3489,10 @@ !DoWhatIMeanSupport class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.107 2013-07-20 10:29:43 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.108 2013-07-24 10:29:08 cg Exp $' ! version_CVS - ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.107 2013-07-20 10:29:43 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.108 2013-07-24 10:29:08 cg Exp $' ! !