SmallSense__SmalltalkCompletionEngine.st
changeset 132 7c23c51d2cfd
parent 131 ea84eea5a3c4
child 133 bd659b67811c
--- a/SmallSense__SmalltalkCompletionEngine.st	Wed Oct 16 15:44:43 2013 +0100
+++ b/SmallSense__SmalltalkCompletionEngine.st	Thu Oct 17 01:41:47 2013 +0100
@@ -186,39 +186,35 @@
         ]
     ].
 
-
     seen := Set new.
-    type 
-        classesDo: [:each | 
-            | class |
+    type  classesDo: [: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
-                                        description: nil
-                                        class: met mclass).
-                        ].
-                    ].
-                ] ifFalse:[
-                    class selectorsAndMethodsDo: [:selector :met | 
+        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
-                                    description: nil
                                     class: met mclass).
                     ].
                 ].
-                class := class superclass.
-            ]
-        ].
+            ] ifFalse:[
+                class selectorsAndMethodsDo: [:selector :met | 
+                    result add: (MethodPO 
+                                name: selector
+                                class: met mclass).
+                ].
+            ].
+            class := class superclass.
+        ]
+    ].
 
     "Created: / 26-11-2011 / 17:03:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 16-10-2013 / 15:40:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 17-10-2013 / 01:04:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 addPools
@@ -337,26 +333,28 @@
 completeAtLine:line column:col collector:coll 
     "find most possible codeCompletion object"
     
-    | position |
+    | context |
 
     collector := coll.
     (collector tree isNil or:[collector tree == #Error]) ifTrue:[ 
         ^ nil 
     ].
-    position := SmalltalkParseNodeFinder new 
+    context := SmalltalkParseNodeFinder new 
                     findNodeIn: collector source tree: collector tree 
                     line: line column: col.
-    result context: position.
+    context codeView: codeView.
+    context language: SmalltalkLanguage instance.
+    result context: context.
 
 
-    position isAfterNode ifTrue:[
-        self completeAfter:position node.
+    context isAfterNode ifTrue:[
+        self completeAfter:context node.
     ] ifFalse:[
-    position isInNode ifTrue:[
-        self completeIn:position node.
+    context isInNode ifTrue:[
+        self completeIn:context node.
     ] ifFalse:[
-    position isBeforeNode ifTrue:[
-        self completeBefore:position node.
+    context isBeforeNode ifTrue:[
+        self completeBefore:context node.
     ]]].
 
     result isEmpty ifTrue:[
@@ -367,7 +365,7 @@
     "Created: / 04-03-2011 / 13:01:14 / Jakub <zelenja7@fel.cvut.cz>"
     "Modified: / 08-04-2011 / 10:52:59 / Jakub <zelenja7@fel.cvut.cz>"
     "Created: / 26-11-2011 / 17:05:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 03-10-2013 / 17:59:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 17-10-2013 / 00:34:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 completeBefore:node
@@ -399,9 +397,16 @@
 
         type := node receiver inferedType.
         type isUnknownType ifFalse:[
-            self addMethodsForType: type
+            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 addMethodsStartingWith: node selector.
         ].
 
         ^self.
@@ -412,7 +417,7 @@
     "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: / 06-08-2013 / 12:28:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 16-10-2013 / 15:53:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !SmalltalkCompletionEngine class methodsFor:'documentation'!