SmallSense__CompletionController.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 04 Mar 2015 06:01:34 +0000
changeset 445 783f2a4af9c2
parent 374 e65bd2bf892a
child 455 f1cd6e210528
permissions -rw-r--r--
Electric insert: do not insert again and again when insertion was deleted by pressing backspace When a snippet or completion is auto-inserted (i.e., "electric-insert") then subsequent backspace removes it and "electric-insertion" is disabled temporarily so the (apparently wrong) code is not inserted again. This will make it - hopefully - less annoying in cases unwanted stuff is inserted.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
252
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     1
"
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     2
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
374
e65bd2bf892a Updated copyright notice.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 285
diff changeset
     3
Copyright (C) 2013-2015 Jan Vrany
252
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     4
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     5
This library is free software; you can redistribute it and/or
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     6
modify it under the terms of the GNU Lesser General Public
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     7
License as published by the Free Software Foundation; either
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     8
version 2.1 of the License. 
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
     9
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    10
This library is distributed in the hope that it will be useful,
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    11
but WITHOUT ANY WARRANTY; without even the implied warranty of
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    13
Lesser General Public License for more details.
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    14
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    15
You should have received a copy of the GNU Lesser General Public
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    16
License along with this library; if not, write to the Free Software
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    18
"
249
8bc64027b189 Package renamed to stx:goodies/smallsense
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 245
diff changeset
    19
"{ Package: 'stx:goodies/smallsense' }"
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
"{ NameSpace: SmallSense }"
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
EditTextViewCompletionSupport subclass:#CompletionController
154
b96fbde91144 Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
    24
	instanceVariableNames:'support seqno completeIfUnambiguous'
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
	classVariableNames:''
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
	poolDictionaries:''
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
	category:'SmallSense-Core'
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
!
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
252
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    30
!CompletionController class methodsFor:'documentation'!
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    31
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    32
copyright
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    33
"
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    34
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
374
e65bd2bf892a Updated copyright notice.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 285
diff changeset
    35
Copyright (C) 2013-2015 Jan Vrany
252
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    36
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    37
This library is free software; you can redistribute it and/or
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    38
modify it under the terms of the GNU Lesser General Public
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    39
License as published by the Free Software Foundation; either
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    40
version 2.1 of the License. 
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    41
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    42
This library is distributed in the hope that it will be useful,
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    43
but WITHOUT ANY WARRANTY; without even the implied warranty of
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    44
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    45
Lesser General Public License for more details.
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    46
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    47
You should have received a copy of the GNU Lesser General Public
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    48
License along with this library; if not, write to the Free Software
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    49
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    50
"
feba6ee5c814 Added copyright notice and license information (LGPL2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
    51
! !
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    52
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    53
!CompletionController class methodsFor:'instance creation'!
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    54
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    55
new
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    56
    "return an initialized instance"
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    57
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    58
    ^ self basicNew initialize.
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    59
! !
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
    60
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
!CompletionController methodsFor:'accessing'!
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
218
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    63
completionEngine
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    64
    | engineClass |
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    65
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    66
    engineClass := self completionEngineClass.
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    67
    ^ engineClass notNil 
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    68
        ifTrue:[ engineClass new ]
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    69
        ifFalse:[ nil ].
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    70
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    71
    "Created: / 18-05-2014 / 11:58:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    72
!
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    73
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    74
environment
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    75
    ^ support notNil 
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    76
        ifTrue:[support environment]
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    77
        ifFalse:[Smalltalk].
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    78
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    79
    "Created: / 18-05-2014 / 11:53:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    80
!
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    81
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
support
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
    ^ support
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
!
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
support:anEditSupport
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
    support := anEditSupport.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
! !
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
218
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    90
!CompletionController methodsFor:'accessing-classes'!
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    91
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    92
completionEngineClass
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    93
    ^ support notNil 
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    94
        ifTrue:[ support completionEngineClass ]
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    95
        ifFalse:[ nil ].
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    96
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    97
    "Created: / 18-05-2014 / 11:55:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    98
! !
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
    99
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
!CompletionController methodsFor:'events'!
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
handleKeyPress:key x:x y:y
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   103
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   104
    key == #Control_L ifTrue:[
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
        completionView notNil ifTrue:[
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   106
            ^ false.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   107
        ].
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   108
    ].
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   109
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   110
    key == #CodeCompletion  ifTrue: [
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
        autoSelect := true.    
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
        self startCompletionProcess.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
        ^ true
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   114
    ].
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   115
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   116
    (key == #BackSpace or:[key == #BasicBackspace]) ifTrue:[
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   117
        | c |
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   118
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   119
        c := editView characterBeforeCursor.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   120
        (c notNil and:[c isAlphaNumeric]) ifTrue:[
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   121
             ^ false
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   122
        ].
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   123
    ].     
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   124
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
    completionView notNil ifTrue:[
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   127
        (key == #Return and:[completionView hasSelection]) ifTrue:[
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
            self complete.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   129
            ^ true.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   130
        ].
185
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   131
        key == #Tab ifTrue:[ 
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   132
            self handleKeyPressTab.  
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   133
            ^ true
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   134
        ].
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   135
        key isCharacter ifTrue:[
241
174331ea79a5 Oops, fix for previous commit: avoid duplicate characters inserted when completion is unambiguous.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 239
diff changeset
   136
            (self updateSelectionAfterKeyPress: key) ifTrue:[ 
174331ea79a5 Oops, fix for previous commit: avoid duplicate characters inserted when completion is unambiguous.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 239
diff changeset
   137
                ^ true
174331ea79a5 Oops, fix for previous commit: avoid duplicate characters inserted when completion is unambiguous.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 239
diff changeset
   138
            ].
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   139
        ].
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   140
    ].
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   141
    ^ super handleKeyPress:key x:x y:y
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   142
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   143
    "Created: / 27-09-2013 / 15:38:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
241
174331ea79a5 Oops, fix for previous commit: avoid duplicate characters inserted when completion is unambiguous.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 239
diff changeset
   144
    "Modified: / 18-06-2014 / 10:17:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
185
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   145
!
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   146
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   147
handleKeyPressTab
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   148
    "Tab has been pressed, try to complete longest common prefix"
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   149
221
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   150
    | first prefix matching longest minlen |
185
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   151
221
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   152
    first := completionView list first.
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   153
    prefix := self prefixAlreadyWritten.
185
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   154
    matching := OrderedCollection new.
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   155
    minlen := SmallInteger maxVal.
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   156
    completionView list do:[:po |
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   157
        | s |
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   158
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   159
        s := po stringToComplete.
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   160
        (s startsWith: prefix) ifTrue:[
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   161
            matching add: po -> s.
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   162
            minlen := minlen min: s size.
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   163
        ].
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   164
    ].
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   165
    matching isEmpty ifTrue:[
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   166
        completionView flash.
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   167
        ^self.
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   168
    ].
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   169
    matching size == 1 ifTrue:[
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   170
        self complete: matching first key.
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   171
    ].
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   172
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   173
    longest := String streamContents:[:s |
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   174
        | i |
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   175
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   176
        s nextPutAll: prefix.
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   177
        i := prefix size + 1.
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   178
        [ i <= minlen ] whileTrue:[
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   179
            | c |
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   180
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   181
            c := matching first value at: i.
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   182
            (matching allSatisfy:[:e|(e value at: i) == c]) ifTrue:[
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   183
                s nextPut:c.
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   184
                i := i + 1.
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   185
            ] ifFalse:[
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   186
                "/ terminate the loop    
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   187
                i := minlen + 2.
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   188
            ]
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   189
        ]
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   190
    ].
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   191
    longest size = prefix size ifTrue:[
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   192
        completionView flash.
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   193
        ^self.
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   194
    ].
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   195
    editView insertStringAtCursor:(longest copyFrom: prefix size + 1).
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   196
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   197
    "Created: / 31-03-2014 / 22:55:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
221
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   198
    "Modified: / 18-05-2014 / 13:55:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   199
!
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   200
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   201
postKeyPress:key
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   202
    seqno := seqno + 1.
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   203
    seqno == SmallInteger maxVal ifTrue:[
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   204
        seqno := 0.
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   205
    ].
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   206
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   207
    UserPreferences current immediateCodeCompletion ifFalse:[
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   208
        "/ only update, if already open
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   209
        completionView isNil ifTrue:[^ self].
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   210
    ].
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   211
198
a199868d1eab Do not close completion view when backspace is pressed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 192
diff changeset
   212
"/    (key == #BackSpace or:[key == #BasicBackspace]) ifTrue:[
a199868d1eab Do not close completion view when backspace is pressed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 192
diff changeset
   213
"/        self closeCompletionView.
a199868d1eab Do not close completion view when backspace is pressed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 192
diff changeset
   214
"/        ^ self
a199868d1eab Do not close completion view when backspace is pressed
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 192
diff changeset
   215
"/    ].
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   216
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   217
    key isCharacter ifTrue:[
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   218
        key isLetterOrDigit not ifTrue:[
221
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   219
            "/ Hack for Java - should be delegated to completion engine    
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   220
            (key == $. and:[support notNil and:[ support language isJavaLike ]]) ifTrue:[ 
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   221
                ^ self
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   222
            ].
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   223
            self closeCompletionView
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   224
        ] ifFalse:[
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   225
            | c |
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   226
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   227
            c := editView characterBeforeCursor.
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   228
            (c notNil and:[c isLetterOrDigit]) ifTrue:[
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   229
                c := editView characterUnderCursor.
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   230
                c isSeparator ifTrue:[
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   231
                    autoSelect := false.
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   232
                    self updateCompletionList.
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   233
                ].
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   234
            ]
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   235
        ].
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   236
        ^ self
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   237
    ].
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   238
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   239
    "Created: / 28-09-2013 / 00:21:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
221
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   240
    "Modified: / 18-05-2014 / 13:53:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   241
! !
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   242
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   243
!CompletionController methodsFor:'initialization'!
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   244
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   245
initialize
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   246
    "Invoked when a new instance is created."
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   247
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   248
    "/ please change as required (and remove this comment)
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   249
    "/ support := nil.
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   250
    seqno := 0.
154
b96fbde91144 Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   251
    completeIfUnambiguous := UserPreferences current smallSenseCompleteIfUnambiguous.
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   252
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   253
    "/ super initialize.   -- commented since inherited method does nothing
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   254
154
b96fbde91144 Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   255
    "Modified: / 18-01-2014 / 23:10:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   256
! !
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   257
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   258
!CompletionController methodsFor:'private'!
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   259
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   260
complete
185
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   261
    self complete: completionView selection.
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   262
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   263
    "Created: / 27-09-2013 / 15:38:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
185
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   264
    "Modified: / 31-03-2014 / 23:22:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   265
!
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   266
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   267
complete: item
274
2cfcd8eb9761 Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   268
    ^ self complete: item afterKeyPress: nil
185
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   269
75738108cc3f Support for Tab in code completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 178
diff changeset
   270
    "Created: / 31-03-2014 / 23:21:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
274
2cfcd8eb9761 Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   271
    "Modified: / 11-08-2014 / 14:53:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2cfcd8eb9761 Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   272
!
2cfcd8eb9761 Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   273
2cfcd8eb9761 Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   274
complete: item afterKeyPress: keyOrNil
285
a5640bc14376 Small fix or issue#10: do not flush key events upon completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 283
diff changeset
   275
     self closeCompletionView.
a5640bc14376 Small fix or issue#10: do not flush key events upon completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 283
diff changeset
   276
     item insert.
a5640bc14376 Small fix or issue#10: do not flush key events upon completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 283
diff changeset
   277
     keyOrNil notNil ifTrue:[  
a5640bc14376 Small fix or issue#10: do not flush key events upon completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 283
diff changeset
   278
         support keyPressIgnored.
a5640bc14376 Small fix or issue#10: do not flush key events upon completion.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 283
diff changeset
   279
     ].
274
2cfcd8eb9761 Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   280
2cfcd8eb9761 Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   281
    "Created: / 11-08-2014 / 14:53:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   282
!
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   283
221
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   284
prefixAlreadyWritten
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   285
    | list first |
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   286
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   287
    completionView notNil ifTrue:[ 
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   288
        list := completionView list.
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   289
        list notEmptyOrNil ifTrue:[ 
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   290
            first := list first.
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   291
            (completionView list allSatisfy:[:e | e class == first class ]) ifTrue:[ 
245
172822a63cff Fix in CompletionController>>prefixAlreadyWritten - let the first PO answer the prefix written...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 241
diff changeset
   292
                ^ first stringAlreadyWritten 
221
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   293
            ]
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   294
        ]
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   295
    ].
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   296
    ^ support wordBeforeCursor string .
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   297
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   298
    "Created: / 18-05-2014 / 13:55:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
245
172822a63cff Fix in CompletionController>>prefixAlreadyWritten - let the first PO answer the prefix written...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 241
diff changeset
   299
    "Modified: / 24-06-2014 / 11:40:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
221
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   300
!
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   301
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   302
stopCompletionProcess
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   303
    "kill any background completion process"
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   304
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   305
    editView sensor flushUserEventsFor: self.     
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   306
    super stopCompletionProcess
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   307
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   308
    "Created: / 02-10-2013 / 15:09:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   309
    "Modified: / 03-10-2013 / 11:03:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   310
!
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   311
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   312
updateCompletionList
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   313
    "called for keypress events"
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   314
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   315
    completionView isNil ifTrue:[
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   316
        super updateCompletionList
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   317
    ] ifFalse:[
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   318
         self updateSelection.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   319
    ].
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   320
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   321
    "Created: / 27-09-2013 / 15:58:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   322
    "Modified: / 28-09-2013 / 00:15:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   323
!
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   324
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   325
updateSelection
239
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   326
    "Updates selection in completion view based on currently typed partial 
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   327
     text. Return true if the complection window should be closed or false
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   328
     if it shall be kept open. "
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   329
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   330
    ^ self updateSelectionAfterKeyPress: nil
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   331
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   332
    "Created: / 27-09-2013 / 16:16:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   333
    "Modified (comment): / 17-06-2014 / 07:24:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   334
!
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   335
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   336
updateSelectionAfterKeyPress: keyOrNil
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   337
    "Updates selection in completion view based on currently typed partial 
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   338
     text. Return true if the complection window should be closed or false
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   339
     if it shall be kept open.
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   340
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   341
     If `keyOrNil` is not nil, then it's a key press that triggered the update
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   342
     which HAS NOT YET been processed by a `editView`.
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   343
     "
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   344
192
f27ce6dac101 Initial support for completing selector parts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   345
    | list prefix matcher1 matches1 matcher2 matches2 |
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   346
189
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   347
    list := completionView list.
192
f27ce6dac101 Initial support for completing selector parts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   348
    matcher1 := CompletionEngine exactMatcher.
f27ce6dac101 Initial support for completing selector parts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   349
    matcher2 := CompletionEngine inexactMatcher.
221
5590362d7223 Anchor completion patterns to cursor position for more accurate match.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 218
diff changeset
   350
    prefix := self prefixAlreadyWritten.
239
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   351
    keyOrNil isCharacter ifTrue:[ 
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   352
        prefix := prefix , keyOrNil
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   353
    ].
192
f27ce6dac101 Initial support for completing selector parts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   354
    matches1 := list select:[:po | matcher1 value: prefix value: po stringToComplete ].
189
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   355
    matches1 notEmptyOrNil ifTrue:[
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   356
        matches1 size == 1 ifTrue:[
445
783f2a4af9c2 Electric insert: do not insert again and again when insertion was deleted by pressing backspace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
   357
            | selection completeElectric |
274
2cfcd8eb9761 Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   358
2cfcd8eb9761 Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   359
            selection := matches1 anElement.
445
783f2a4af9c2 Electric insert: do not insert again and again when insertion was deleted by pressing backspace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
   360
            completeElectric := completeIfUnambiguous and:[ support electricInsertSuppressed not ].
783f2a4af9c2 Electric insert: do not insert again and again when insertion was deleted by pressing backspace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
   361
            (completeElectric and: [(editView sensor hasKeyEventFor:editView) not]) ifTrue:[
274
2cfcd8eb9761 Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   362
                self complete: selection afterKeyPress: keyOrNil.
189
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   363
                ^ true
274
2cfcd8eb9761 Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   364
            ] ifFalse:[ 
2cfcd8eb9761 Fixes for issue #10: Extra characters inserted when typing too fast and complete-if-ambiguous is on
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 252
diff changeset
   365
                completionView selection: selection
189
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   366
            ].
154
b96fbde91144 Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   367
        ] ifFalse:[
b96fbde91144 Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   368
            | selection |
b96fbde91144 Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   369
189
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   370
            selection := matches1 inject: matches1 anElement into:[:mostrelevant :each |
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   371
                each relevance > mostrelevant relevance 
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   372
                    ifTrue:[each]
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   373
                    ifFalse:[mostrelevant]
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   374
            ].
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   375
            completionView selection: selection.
192
f27ce6dac101 Initial support for completing selector parts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   376
        ].
f27ce6dac101 Initial support for completing selector parts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   377
        ^ false
189
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   378
    ].
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   379
192
f27ce6dac101 Initial support for completing selector parts.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   380
    matches2 := completionView list select:[:po | matcher2 value: prefix value: po stringToComplete ].
189
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   381
    matches2 notEmptyOrNil ifTrue:[
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   382
        matches2 size == 1 ifTrue:[
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   383
            completionView selection:  matches2 anElement.
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   384
        ] ifFalse:[
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   385
            | selection |
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   386
8c32268000c5 Yet another fix in completion view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 188
diff changeset
   387
            selection := matches2 inject: matches2 anElement into:[:mostrelevant :each |
154
b96fbde91144 Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   388
                each relevance > mostrelevant relevance 
b96fbde91144 Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   389
                    ifTrue:[each]
b96fbde91144 Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   390
                    ifFalse:[mostrelevant]
b96fbde91144 Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   391
            ].
b96fbde91144 Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   392
            completionView selection: selection.
b96fbde91144 Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   393
        ]
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   394
    ] ifFalse:[
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   395
        completionView selection: nil.
153
b04d591c8788 Added relevance value to completion item. Pre-select the most relevant item in complection view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 143
diff changeset
   396
    ].
154
b96fbde91144 Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   397
    ^ false.
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   398
239
e1b7b5f0f4b7 Bug fix in completion (#updateSelection).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 221
diff changeset
   399
    "Created: / 17-06-2014 / 07:19:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
445
783f2a4af9c2 Electric insert: do not insert again and again when insertion was deleted by pressing backspace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
   400
    "Modified: / 03-03-2015 / 17:15:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   401
! !
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   402
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   403
!CompletionController methodsFor:'private-API'!
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   404
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   405
closeCompletionView
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   406
    |v|
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   407
123
1b949542c4b2 Improvements for completion of Java classes/methods in Smalltalk code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 118
diff changeset
   408
    self stopCompletionProcess.
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   409
    (v := completionView) notNil ifTrue:[
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   410
        completionView := nil.
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   411
        "/ let it close itself - avoids synchronization problems
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   412
        v sensor
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   413
            pushUserEvent:#value
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   414
            for:[ v topView destroy ].
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   415
    ].
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   416
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   417
    "Created: / 02-10-2013 / 13:57:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
123
1b949542c4b2 Improvements for completion of Java classes/methods in Smalltalk code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 118
diff changeset
   418
    "Modified: / 04-10-2013 / 21:14:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   419
!
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   420
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   421
computeCompletions
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   422
    "Actually compute the completions and update the completion view."  
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   423
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   424
    | completions |
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   425
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   426
    editView sensor flushUserEventsFor: self.
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   427
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   428
    "/ Wait a while to give user chance finish typing.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   429
    "/ This also reduces CPU consumption by avoiding
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   430
    "/ useless computation
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   431
    Delay waitForMilliseconds: 200. 
218
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   432
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   433
    completions := self computeCompletionsInContext.
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   434
    completions notEmptyOrNil ifTrue:[
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   435
        editView sensor pushUserEvent: #updateCompletions:sequence: for: self withArguments: (Array with: completions with: seqno)
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   436
    ].
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   437
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   438
    "Created: / 27-09-2013 / 13:12:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
218
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   439
    "Modified: / 18-05-2014 / 11:50:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   440
!
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   441
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   442
computeCompletionsInContext
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   443
    | context |
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   444
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   445
    context := CompletionContext new.
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   446
    context environment: self environment.
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   447
    context support: support.
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   448
    ^self computeCompletionsInContext: context.
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   449
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   450
    "Created: / 18-05-2014 / 11:50:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   451
!
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   452
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   453
computeCompletionsInContext: aCompletionContext
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   454
    | engine |
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   455
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   456
    engine := self completionEngine.
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   457
    ^engine notNil 
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   458
        ifTrue:[ engine complete: aCompletionContext ]
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   459
        ifFalse:[ nil ]
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   460
0f5b160ecb9d Let the CompletionController itself to instantiate completion engine.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 212
diff changeset
   461
    "Created: / 18-05-2014 / 11:53:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   462
!
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   463
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   464
openCompletionView
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   465
    self openCompletionView: #()
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   466
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   467
    "Created: / 27-09-2013 / 16:17:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   468
!
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   469
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   470
openCompletionView: list
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   471
    "Makes sure the completion view is opened and with given `list`."
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   472
    
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   473
    | movePos topView x y  windowExtent screenExtent |
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   474
    "/ move the window
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   475
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   476
    list isEmpty ifTrue:[ ^ self ].
153
b04d591c8788 Added relevance value to completion item. Pre-select the most relevant item in complection view.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 143
diff changeset
   477
    list = #( 'Busy...' ) ifTrue:[ ^ self ].  
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   478
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   479
    x := (editView xOfCol:editView cursorCol  inVisibleLine:editView cursorLine)
212
a2caebc602a7 Fixes and improvements for Java/Groovy completion (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 205
diff changeset
   480
            - 16"icon" - (editView widthOfString:  "support wordBeforeCursor"list first stringAlreadyWritten) - 5"magic constant".
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   481
    y := editView yOfCursor + editView font maxHeight + 3.
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   482
    movePos := (editView originRelativeTo: nil) + (x @ y).
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   483
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   484
    completionView isNil ifTrue:[
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   485
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   486
        completionView := CompletionView new.
178
f98d96568600 Fix for issue #8: allow for selecting completion using mouse and doubleclick.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 176
diff changeset
   487
        completionView completionController: self.  
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   488
        completionView list:list.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   489
        completionView font: editView font.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   490
        topView := completionView.
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   491
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   492
        windowExtent := completionView extent copy.
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   493
        screenExtent := Screen current monitorBoundsAt: movePos.
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   494
        (screenExtent height) < (movePos y + windowExtent y) ifTrue:[
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   495
            movePos y: (movePos y - windowExtent y - editView font maxHeight - 5).
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   496
        ].
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   497
        topView origin:movePos.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   498
"/        topView resizeToFit.
154
b96fbde91144 Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   499
        self updateSelection ifFalse:[
b96fbde91144 Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   500
            topView open.
b96fbde91144 Support for auto-completion of unambigous items (such as instvars)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   501
        ].
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   502
    ] ifFalse:[
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   503
        completionView list:list.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   504
        self updateSelection.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   505
"/        topView := completionView topView.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   506
"/        topView ~~ completionView ifTrue:[
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   507
"/            topView origin:movePos.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   508
"/            topView resizeToFit.
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   509
"/        ]
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   510
    ].
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   511
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   512
    "Created: / 27-09-2013 / 14:01:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
212
a2caebc602a7 Fixes and improvements for Java/Groovy completion (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 205
diff changeset
   513
    "Modified: / 15-05-2014 / 11:30:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   514
!
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   515
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   516
updateCompletions: completionResult sequence: sequence
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   517
    seqno == sequence ifTrue:[
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   518
        self openCompletionView: completionResult 
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   519
    ].
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   520
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   521
    "Created: / 03-10-2013 / 07:14:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   522
    "Modified: / 03-10-2013 / 11:02:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
117
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   523
! !
441529422c2f Completion support refactored to make it more pluggable/extendable.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   524
118
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   525
!CompletionController class methodsFor:'documentation'!
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   526
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   527
version_HG
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   528
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   529
    ^ '$Changeset: <not expanded> $'
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   530
! !
88e6fd734a11 Some more fixes in complete-as-you-type support...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 117
diff changeset
   531