--- a/SmallSense__SmalltalkCompletionEngine.st Tue Apr 08 15:03:38 2014 +0200
+++ b/SmallSense__SmalltalkCompletionEngine.st Tue Apr 08 21:46:51 2014 +0200
@@ -234,6 +234,93 @@
"Modified: / 22-01-2014 / 19:48:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+addMethodsForType: type prefix: prefix stripOff: stripprefix
+
+ type isUnknownType ifFalse:[
+ self addMethodsForType:type stripOff: stripprefix.
+
+ "/ If the type is union of more than 6 types, then
+ "/ assume that the inferencer is likely wrong.
+ "/ then, if the prefix is at least 3 chars,
+ "/ also add methods with that prefix.
+
+ ((type classes size > 6) and:[ prefix > 2 ]) ifTrue:[
+ self addMethodsStartingWith:prefix stripOff: stripprefix
+ ].
+ ] ifTrue:[
+ self addMethodsStartingWith:prefix stripOff: stripprefix
+ ].
+
+ "Created: / 08-04-2014 / 21:04:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+addMethodsForType: type stripOff: stripprefix
+ | classes seen |
+
+ classes := type classes.
+ "/ Hack for Boolean: ifTrue:iFalse: etc are not defined
+ "/ in Boolean ?!!?
+ (classes size == 1 and:[classes anElement == Boolean ]) ifTrue:[
+ classes := Array with: True with: False.
+ ].
+ classes size == 1 ifTrue:[
+ classes anElement == JavaPackage class ifTrue:[
+ "/ Special hack for JAVA: for pattern `JAVA java lang reflect`
+ "/ complete all Java classes in that package
+ | node |
+
+ node := result context node.
+ node isUnaryMessage ifTrue:[
+ | package |
+ "/ Compute package prefix...
+
+ package := node selector.
+ node := node receiver.
+ [ node isUnaryMessage ] whileTrue:[
+ package := node selector , '/' , package.
+ node := node receiver.
+ ].
+ self addJavaClassesInPackage: package.
+ ^ self.
+ ]
+ ]
+ ].
+
+ seen := Set new.
+ classes do: [:each |
+ | class |
+
+ class := each.
+ [ class notNil and:[(seen includes: class) not]] whileTrue: [
+ seen add: class.
+ "/ Now, special care for Java classes, sigh...
+ (class isMetaclass and:[class theNonMetaclass isJavaClass]) ifTrue:[
+ class theNonMetaclass selectorsAndMethodsDo: [:selector :met |
+ met isStatic ifTrue:[
+ result add: (MethodPO
+ name: selector
+ class: met mclass).
+ ].
+ ].
+ ] ifFalse:[
+ class selectorsAndMethodsDo: [:selector :met |
+ met isSynthetic ifFalse:[
+ (stripprefix isNil or:[ selector size > stripprefix size and:[selector startsWith: stripprefix]]) ifTrue:[
+ result add: (MethodPO
+ name: selector
+ class: met mclass
+ stripOff: stripprefix).
+ ].
+ ]
+ ].
+ ].
+ class := class superclass.
+ ]
+ ].
+
+ "Created: / 08-04-2014 / 21:23:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
addPools
| class |
@@ -431,51 +518,47 @@
"Created: / 26-11-2011 / 17:07:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-completeIn:node
+completeIn:node
"return collection which can be afterNode"
node isVariableNode ifTrue:[
- node name first isUppercase ifTrue:[
- self addGlobalsStartingWith: node name.
- self addClassVariables.
- self addPools.
- self addPrivateClasses.
- ] ifFalse:[
- self addVariablesFor: node
- ].
- ^self.
+ self completeInVariableNode:node.
+ ^ self.
].
-
node isMessage ifTrue:[
- | type |
-
- type := node receiver inferedType.
- Debug ifTrue:[
- Transcript showCR: '--> completing messages for ' , type printString.
- ].
-
- type isUnknownType ifFalse:[
- self addMethodsForType: type.
- "/ If the type is union of more than 6 types, then
- "/ assume that the inferencer is likely wrong.
- "/ then, if the prefix is at least 3 chars,
- "/ also add methods with that prefix.
- ((type classes size > 6) and:[node selector size > 2]) ifTrue:[
- self addMethodsStartingWith: node selector.
- ].
- ] ifTrue:[
- self addMethodsStartingWith: node selector.
- ].
-
- ^self.
+ self completeInMessageNode:node.
+ ^ self
].
-
- self breakPoint: #jv.
+ self breakPoint:#jv.
"Created: / 07-03-2011 / 18:59:02 / Jakub <zelenja7@fel.cvut.cz>"
"Modified: / 08-04-2011 / 09:31:51 / Jakub <zelenja7@fel.cvut.cz>"
"Created: / 26-11-2011 / 17:07:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 22-01-2014 / 09:10:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 08-04-2014 / 20:52:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+completeInMessageNode:node
+ | parent |
+
+
+ self addMethodsForType: node receiver inferedType prefix: node selector stripOff: nil.
+ parent := node parent.
+ parent isMessage ifTrue:[
+ self addMethodsForType: parent receiver inferedType prefix: node selector stripOff: parent selector.
+ ].
+
+ "Modified (format): / 08-04-2014 / 21:16:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+completeInVariableNode:node
+ node name first isUppercase ifTrue:[
+ self addGlobalsStartingWith:node name.
+ self addClassVariables.
+ self addPools.
+ self addPrivateClasses.
+ ] ifFalse:[
+ self addVariablesFor:node
+ ]
! !
!SmalltalkCompletionEngine class methodsFor:'documentation'!