-
Notifications
You must be signed in to change notification settings - Fork 768
/
Copy pathgeneral_completer_store.py
106 lines (78 loc) · 3.58 KB
/
general_completer_store.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Copyright (C) 2013-2018 ycmd contributors
#
# This file is part of ycmd.
#
# ycmd is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ycmd is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ycmd. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
# Not installing aliases from python-future; it's unreliable and slow.
from builtins import * # noqa
from ycmd.completers.completer import Completer
from ycmd.completers.all.identifier_completer import IdentifierCompleter
from ycmd.completers.general.filename_completer import FilenameCompleter
from ycmd.completers.general.ultisnips_completer import UltiSnipsCompleter
class GeneralCompleterStore( Completer ):
"""
Holds a list of completers that can be used in all filetypes.
It overrides all Completer API methods so that specific calls to
GeneralCompleterStore are passed to all general completers.
"""
def __init__( self, user_options ):
super( GeneralCompleterStore, self ).__init__( user_options )
self._identifier_completer = IdentifierCompleter( user_options )
self._filename_completer = FilenameCompleter( user_options )
self._ultisnips_completer = UltiSnipsCompleter( user_options )
self._non_filename_completers = [ self._identifier_completer ]
if user_options.get( 'use_ultisnips_completer', True ):
self._non_filename_completers.append( self._ultisnips_completer )
self._all_completers = [ self._identifier_completer,
self._filename_completer,
self._ultisnips_completer ]
def SupportedFiletypes( self ):
return set()
def GetIdentifierCompleter( self ):
return self._identifier_completer
def ComputeCandidates( self, request_data ):
start_column = request_data[ 'start_column' ]
candidates = self._filename_completer.ComputeCandidates( request_data )
if candidates:
return candidates
# The filename completer may have changed the start column. Reset it.
request_data[ 'start_column' ] = start_column
for completer in self._non_filename_completers:
candidates += completer.ComputeCandidates( request_data )
return candidates
def OnFileReadyToParse( self, request_data ):
for completer in self._all_completers:
completer.OnFileReadyToParse( request_data )
def OnBufferVisit( self, request_data ):
for completer in self._all_completers:
completer.OnBufferVisit( request_data )
def OnBufferUnload( self, request_data ):
for completer in self._all_completers:
completer.OnBufferUnload( request_data )
def OnInsertLeave( self, request_data ):
for completer in self._all_completers:
completer.OnInsertLeave( request_data )
def OnCurrentIdentifierFinished( self, request_data ):
for completer in self._all_completers:
completer.OnCurrentIdentifierFinished( request_data )
def GettingCompletions( self ):
for completer in self._all_completers:
completer.GettingCompletions()
def Shutdown( self ):
for completer in self._all_completers:
completer.Shutdown()