SmallSense__CompletionController.st
changeset 218 0f5b160ecb9d
parent 212 a2caebc602a7
child 221 5590362d7223
--- a/SmallSense__CompletionController.st	Sun May 18 10:24:28 2014 +0100
+++ b/SmallSense__CompletionController.st	Sun May 18 12:29:12 2014 +0100
@@ -20,6 +20,25 @@
 
 !CompletionController methodsFor:'accessing'!
 
+completionEngine
+    | engineClass |
+
+    engineClass := self completionEngineClass.
+    ^ engineClass notNil 
+        ifTrue:[ engineClass new ]
+        ifFalse:[ nil ].
+
+    "Created: / 18-05-2014 / 11:58:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+environment
+    ^ support notNil 
+        ifTrue:[support environment]
+        ifFalse:[Smalltalk].
+
+    "Created: / 18-05-2014 / 11:53:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 support
     ^ support
 !
@@ -28,6 +47,16 @@
     support := anEditSupport.
 ! !
 
+!CompletionController methodsFor:'accessing-classes'!
+
+completionEngineClass
+    ^ support notNil 
+        ifTrue:[ support completionEngineClass ]
+        ifFalse:[ nil ].
+
+    "Created: / 18-05-2014 / 11:55:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !CompletionController methodsFor:'events'!
 
 handleKeyPress:key x:x y:y
@@ -303,14 +332,36 @@
     "/ This also reduces CPU consumption by avoiding
     "/ useless computation
     Delay waitForMilliseconds: 200. 
-"/    self updateCompletions: support computeCompletion
-    completions := support computeCompletion.
+
+    completions := self computeCompletionsInContext.
     completions notEmptyOrNil ifTrue:[
         editView sensor pushUserEvent: #updateCompletions:sequence: for: self withArguments: (Array with: completions with: seqno)
     ].
 
     "Created: / 27-09-2013 / 13:12:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 03-10-2013 / 07:17:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 18-05-2014 / 11:50:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+computeCompletionsInContext
+    | context |
+
+    context := CompletionContext new.
+    context environment: self environment.
+    context support: support.
+    ^self computeCompletionsInContext: context.
+
+    "Created: / 18-05-2014 / 11:50:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+computeCompletionsInContext: aCompletionContext
+    | engine |
+
+    engine := self completionEngine.
+    ^engine notNil 
+        ifTrue:[ engine complete: aCompletionContext ]
+        ifFalse:[ nil ]
+
+    "Created: / 18-05-2014 / 11:53:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 openCompletionView