SmallSense__CompletionController.st
changeset 218 0f5b160ecb9d
parent 212 a2caebc602a7
child 221 5590362d7223
equal deleted inserted replaced
217:6ff466b83ff9 218:0f5b160ecb9d
    18     ^ self basicNew initialize.
    18     ^ self basicNew initialize.
    19 ! !
    19 ! !
    20 
    20 
    21 !CompletionController methodsFor:'accessing'!
    21 !CompletionController methodsFor:'accessing'!
    22 
    22 
       
    23 completionEngine
       
    24     | engineClass |
       
    25 
       
    26     engineClass := self completionEngineClass.
       
    27     ^ engineClass notNil 
       
    28         ifTrue:[ engineClass new ]
       
    29         ifFalse:[ nil ].
       
    30 
       
    31     "Created: / 18-05-2014 / 11:58:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    32 !
       
    33 
       
    34 environment
       
    35     ^ support notNil 
       
    36         ifTrue:[support environment]
       
    37         ifFalse:[Smalltalk].
       
    38 
       
    39     "Created: / 18-05-2014 / 11:53:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    40 !
       
    41 
    23 support
    42 support
    24     ^ support
    43     ^ support
    25 !
    44 !
    26 
    45 
    27 support:anEditSupport
    46 support:anEditSupport
    28     support := anEditSupport.
    47     support := anEditSupport.
       
    48 ! !
       
    49 
       
    50 !CompletionController methodsFor:'accessing-classes'!
       
    51 
       
    52 completionEngineClass
       
    53     ^ support notNil 
       
    54         ifTrue:[ support completionEngineClass ]
       
    55         ifFalse:[ nil ].
       
    56 
       
    57     "Created: / 18-05-2014 / 11:55:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    29 ! !
    58 ! !
    30 
    59 
    31 !CompletionController methodsFor:'events'!
    60 !CompletionController methodsFor:'events'!
    32 
    61 
    33 handleKeyPress:key x:x y:y
    62 handleKeyPress:key x:x y:y
   301 
   330 
   302     "/ Wait a while to give user chance finish typing.
   331     "/ Wait a while to give user chance finish typing.
   303     "/ This also reduces CPU consumption by avoiding
   332     "/ This also reduces CPU consumption by avoiding
   304     "/ useless computation
   333     "/ useless computation
   305     Delay waitForMilliseconds: 200. 
   334     Delay waitForMilliseconds: 200. 
   306 "/    self updateCompletions: support computeCompletion
   335 
   307     completions := support computeCompletion.
   336     completions := self computeCompletionsInContext.
   308     completions notEmptyOrNil ifTrue:[
   337     completions notEmptyOrNil ifTrue:[
   309         editView sensor pushUserEvent: #updateCompletions:sequence: for: self withArguments: (Array with: completions with: seqno)
   338         editView sensor pushUserEvent: #updateCompletions:sequence: for: self withArguments: (Array with: completions with: seqno)
   310     ].
   339     ].
   311 
   340 
   312     "Created: / 27-09-2013 / 13:12:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   341     "Created: / 27-09-2013 / 13:12:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   313     "Modified: / 03-10-2013 / 07:17:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   342     "Modified: / 18-05-2014 / 11:50:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   343 !
       
   344 
       
   345 computeCompletionsInContext
       
   346     | context |
       
   347 
       
   348     context := CompletionContext new.
       
   349     context environment: self environment.
       
   350     context support: support.
       
   351     ^self computeCompletionsInContext: context.
       
   352 
       
   353     "Created: / 18-05-2014 / 11:50:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   354 !
       
   355 
       
   356 computeCompletionsInContext: aCompletionContext
       
   357     | engine |
       
   358 
       
   359     engine := self completionEngine.
       
   360     ^engine notNil 
       
   361         ifTrue:[ engine complete: aCompletionContext ]
       
   362         ifFalse:[ nil ]
       
   363 
       
   364     "Created: / 18-05-2014 / 11:53:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   314 !
   365 !
   315 
   366 
   316 openCompletionView
   367 openCompletionView
   317     self openCompletionView: #()
   368     self openCompletionView: #()
   318 
   369