--- a/DoWhatIMeanSupport.st Fri May 13 06:50:19 2016 +0200
+++ b/DoWhatIMeanSupport.st Sun May 15 06:58:51 2016 +0200
@@ -1732,6 +1732,9 @@
"Created: / 10-11-2006 / 14:00:53 / cg"
!
+codeCompletionForBlockArgument:node into:actionBlock
+!
+
codeCompletionForLiteralSymbol:nodeOrNil element:tokenOrNil considerAll:considerAll into:actionBlock
"looking for all symbols is way too much and inprecise;
experiment: only present symbols which are used by the class,
@@ -1946,6 +1949,7 @@
nodeReceiver notNil ifTrue:[
classesOfReceiver := self classesOfNode:nodeReceiver.
].
+Transcript show:node; show:' -> '; showCR:classesOfReceiver.
( node isVariable and:[node name = 'self']) ifTrue:[self halt].
"/ if there is already space before the cursor, and the parent node is not a message,
@@ -2615,12 +2619,17 @@
!
codeCompletionForMessageTo:node into:actionBlock
- "find good suggestions for a message send to node, with no input yet"
+ "find good suggestions for a message send to node, with no input yet.
+ I.e. right after a receiver (w.o. any input yet)"
|knownClass suggestions selectorsImplementedInClass mostUseful editActions pos|
- (knownClass := self classOfNode:node) isNil ifTrue:[^ self].
-
+ (knownClass := self classOfNode:node) isNil ifTrue:[
+ self classOfNode:node.
+ ^ self
+ ].
+
+Transcript show:node; show:' -> '; showCR:knownClass.
selectorsImplementedInClass := Set new.
knownClass withAllSuperclassesDo:[:cls |
@@ -3068,6 +3077,9 @@
"Modified: / 01-06-2012 / 20:31:36 / cg"
!
+codeCompletionForTempVariable:node into:actionBlock
+!
+
codeCompletionForVariable:node into:actionBlock
|nonMetaClass crsrPos nm parent
allVariables allDistances variablesAlreadyAdded nodeVal
@@ -4325,7 +4337,7 @@
^ self.
].
].
- (source startsWith:'sel') ifTrue:[self halt].
+ "/ (source startsWith:'sel') ifTrue:[self halt].
nodeParent := node parent.
(node isVariable
@@ -4365,8 +4377,8 @@
and:[scope arguments last stop >= node stop]]].
].
].
- nodeIsInTemporaries ifTrue:[ ^ self ]. "/ no completion in a tempvar decl
- nodeIsInBlockArguments ifTrue:[ ^ self ]. "/ no completion in a tempvar decl
+ nodeIsInTemporaries ifTrue:[ self codeCompletionForTempVariable:node into:actionBlock. ^ self ].
+ nodeIsInBlockArguments ifTrue:[ self codeCompletionForBlockArgument:node into:actionBlock. ^ self ].
"/ for variable completion, cursor must be right after the node
codeView characterPositionOfCursor = (node stop + 1) ifTrue:[
@@ -4742,7 +4754,7 @@
!
addClassesOfExpression:expr inClass:classOrNil to:setOfTypes
- |cls exprVal varName varScope instVarClass sym|
+ |cls exprVal varName varScope instVarClass classVarClass poolVarClass sym|
expr isLiteral ifTrue:[
exprVal := expr value.
@@ -4792,11 +4804,39 @@
].
classOrNil notNil ifTrue:[
+ "/ inst var
instVarClass := classOrNil whichClassDefinesInstVar:varName.
instVarClass notNil ifTrue:[
setOfTypes addAll:(self classesOfInstVarNamed:varName inClass:instVarClass).
+ ^ setOfTypes
+ ].
+
+ "/ class vars
+ classVarClass := classOrNil theNonMetaclass whichClassDefinesClassVar:varName.
+ classVarClass notNil ifTrue:[
+ "/ see what is currently there
+ setOfTypes add:(classVarClass classVarAt:varName asSymbol) class.
+ ^ setOfTypes
+ ].
+ varName isUppercaseFirst ifTrue:[
+ "/ private class
+ varName knownAsSymbol ifTrue:[
+ cls := classOrNil theNonMetaclass privateClassesAt:varName asSymbol.
+ cls notNil ifTrue:[
+ setOfTypes add:(cls theMetaclass).
+ ^ setOfTypes
+ ].
+ ].
+ ].
+ "/ pool vars
+ poolVarClass := classOrNil theNonMetaclass whichPoolDefinesPoolVar:varName.
+ poolVarClass notNil ifTrue:[
+ "/ see what is currently there
+ setOfTypes add:(poolVarClass classVarAt:varName asSymbol) class.
+ ^ setOfTypes
].
].
+
varName isUppercaseFirst ifTrue:[
sym := varName asSymbolIfInterned.
sym notNil ifTrue:[
@@ -5147,24 +5187,47 @@
it is a good idea to know what the reveiver's value is.
Sigh - returns nil as value both if unknown AND if a real nil is there"
- |nodeVal con privateClass pool sym|
+ |nodeVal con classInstVarClass classVarClass privateClass pool sym nameSpace topNameSpace|
aVariableName isUppercaseFirst ifTrue:[
classOrNil notNil ifTrue:[
- (classOrNil theNonMetaclass classVarNames includes:aVariableName) ifTrue:[
- nodeVal := classOrNil theNonMetaclass classVarAt:aVariableName.
+ classOrNil isMeta ifTrue:[
+ "/ class instVars
+ (classInstVarClass := classOrNil whichClassDefinesInstVar:aVariableName) notNil ifTrue:[
+ nodeVal := classInstVarClass theNonMetaclass instVarNamed:aVariableName.
+ ^ { nodeVal . #classInstVariable }
+ ].
+ ].
+ "/ class vars
+ (classVarClass := classOrNil theNonMetaclass whichClassDefinesClassVar:aVariableName) notNil ifTrue:[
+ nodeVal := classVarClass classVarAt:aVariableName asSymbol.
^ { nodeVal . #classVariable }
- ].
+ ].
+
privateClass := classOrNil theNonMetaclass privateClasses detect:[:cls | cls nameWithoutPrefix = aVariableName] ifNone:nil.
privateClass notNil ifTrue:[
nodeVal := privateClass.
^ { nodeVal . #privateClass }
].
- pool := classOrNil theNonMetaclass sharedPools detect:[:pool | pool classVariableNames includes:aVariableName] ifNone:nil.
+ pool := classOrNil theNonMetaclass whichPoolDefinesPoolVar:aVariableName.
pool notNil ifTrue:[
nodeVal := pool classVarAt:aVariableName.
^ { nodeVal . #poolVariable }
].
+ ((nameSpace := classOrNil nameSpace) notNil and:[nameSpace ~~ Smalltalk]) ifTrue:[
+ nameSpace isNameSpace ifTrue:[
+ nodeVal := nameSpace at:aVariableName asSymbol.
+ ^ { nodeVal . #nameSpaceVariable }
+ ].
+ nodeVal := nameSpace privateClassNamed:aVariableName asSymbol.
+ ^ { nodeVal . #privateClass }
+ ].
+ ((topNameSpace := classOrNil topNameSpace) notNil
+ and:[topNameSpace ~~ nameSpace
+ and:[topNameSpace ~~ Smalltalk]]) ifTrue:[
+ nodeVal := topNameSpace at:aVariableName asSymbol.
+ ^ { nodeVal . #nameSpaceVariable }
+ ].
].
(sym := aVariableName asSymbolIfInterned) notNil ifTrue:[
nodeVal := Smalltalk at:sym.