2016-04-24 09:22:52 -04:00
|
|
|
# encoding: utf-8
|
|
|
|
#
|
2018-05-14 08:18:18 -04:00
|
|
|
# Copyright (C) 2016-2018 YouCompleteMe contributors
|
2016-04-24 09:22:52 -04:00
|
|
|
#
|
|
|
|
# This file is part of YouCompleteMe.
|
|
|
|
#
|
|
|
|
# YouCompleteMe 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.
|
|
|
|
#
|
|
|
|
# YouCompleteMe 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 YouCompleteMe. 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
|
2017-03-09 09:57:27 -05:00
|
|
|
# Not installing aliases from python-future; it's unreliable and slow.
|
2016-04-24 09:22:52 -04:00
|
|
|
from builtins import * # noqa
|
|
|
|
|
2017-09-24 07:02:08 -04:00
|
|
|
from hamcrest import assert_that, contains, empty, has_entries
|
2016-04-24 09:22:52 -04:00
|
|
|
|
2017-09-24 07:02:08 -04:00
|
|
|
from ycm.tests.test_utils import ( MockVimBuffers, MockVimModule, ToBytesOnPY2,
|
|
|
|
VimBuffer )
|
2016-04-24 09:22:52 -04:00
|
|
|
MockVimModule()
|
|
|
|
|
2017-07-07 07:59:57 -04:00
|
|
|
from ycm import vimsupport
|
2016-10-11 16:54:00 -04:00
|
|
|
from ycm.tests import YouCompleteMeInstance
|
2016-04-24 09:22:52 -04:00
|
|
|
|
2017-11-06 17:51:16 -05:00
|
|
|
FILETYPE = 'ycmtest'
|
|
|
|
TRIGGERS = {
|
|
|
|
'ycmtest': [ '.' ]
|
|
|
|
}
|
2016-04-24 09:22:52 -04:00
|
|
|
|
2017-11-06 17:51:16 -05:00
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 1,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2016-10-11 16:54:00 -04:00
|
|
|
def OmniCompleter_GetCompletions_Cache_List_test( ycm ):
|
2017-07-03 11:59:20 -04:00
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 5
|
|
|
|
return [ 'a', 'b', 'cdef' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'test.' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-03 11:59:20 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 5 ) ):
|
2017-07-03 11:59:20 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': ToBytesOnPY2( [ 'a', 'b', 'cdef' ] ),
|
|
|
|
'completion_start_column': 6
|
|
|
|
} )
|
|
|
|
)
|
2016-04-24 09:22:52 -04:00
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 1,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2016-10-11 16:54:00 -04:00
|
|
|
def OmniCompleter_GetCompletions_Cache_ListFilter_test( ycm ):
|
2017-07-03 11:59:20 -04:00
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 5
|
|
|
|
return [ 'a', 'b', 'cdef' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'test.t' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-03 11:59:20 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 6 ) ):
|
2017-07-03 11:59:20 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': empty(),
|
|
|
|
'completion_start_column': 6
|
|
|
|
} )
|
|
|
|
)
|
2016-04-24 09:22:52 -04:00
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 0,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2016-10-11 16:54:00 -04:00
|
|
|
def OmniCompleter_GetCompletions_NoCache_List_test( ycm ):
|
2017-07-03 11:59:20 -04:00
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 5
|
|
|
|
return [ 'a', 'b', 'cdef' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'test.' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-03 11:59:20 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 5 ) ):
|
2017-07-03 11:59:20 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': ToBytesOnPY2( [ 'a', 'b', 'cdef' ] ),
|
|
|
|
'completion_start_column': 6
|
|
|
|
} )
|
|
|
|
)
|
2016-04-24 09:22:52 -04:00
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 0,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2016-10-11 16:54:00 -04:00
|
|
|
def OmniCompleter_GetCompletions_NoCache_ListFilter_test( ycm ):
|
2017-07-03 11:59:20 -04:00
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 5
|
|
|
|
return [ 'a', 'b', 'cdef' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'test.t' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-03 11:59:20 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 6 ) ):
|
2017-07-03 11:59:20 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
# Actual result is that the results are not filtered, as we expect the
|
|
|
|
# omnifunc or vim itself to do this filtering.
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': ToBytesOnPY2( [ 'a', 'b', 'cdef' ] ),
|
|
|
|
'completion_start_column': 6
|
|
|
|
} )
|
|
|
|
)
|
2016-04-24 09:22:52 -04:00
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 0,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2017-07-03 11:59:20 -04:00
|
|
|
def OmniCompleter_GetCompletions_NoCache_UseFindStart_test( ycm ):
|
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 0
|
|
|
|
return [ 'a', 'b', 'cdef' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'test.t' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-03 11:59:20 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 6 ) ):
|
2017-07-03 11:59:20 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
# Actual result is that the results are not filtered, as we expect the
|
|
|
|
# omnifunc or vim itself to do this filtering.
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': ToBytesOnPY2( [ 'a', 'b', 'cdef' ] ),
|
|
|
|
'completion_start_column': 1
|
|
|
|
} )
|
|
|
|
)
|
2016-04-24 09:22:52 -04:00
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 1,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2017-07-03 11:59:20 -04:00
|
|
|
def OmniCompleter_GetCompletions_Cache_UseFindStart_test( ycm ):
|
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 0
|
|
|
|
return [ 'a', 'b', 'cdef' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'test.t' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-03 11:59:20 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 6 ) ):
|
2017-07-03 11:59:20 -04:00
|
|
|
ycm.SendCompletionRequest()
|
2017-07-02 19:55:03 -04:00
|
|
|
# There are no results because the query 'test.t' doesn't match any
|
2017-07-03 11:59:20 -04:00
|
|
|
# candidate (and cache_omnifunc=1, so we FilterAndSortCandidates).
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': empty(),
|
|
|
|
'completion_start_column': 1
|
|
|
|
} )
|
|
|
|
)
|
2017-07-02 19:55:03 -04:00
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 1,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2016-10-11 16:54:00 -04:00
|
|
|
def OmniCompleter_GetCompletions_Cache_Object_test( ycm ):
|
2017-07-03 11:59:20 -04:00
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 5
|
|
|
|
return { 'words': [ 'a', 'b', 'CDtEF' ] }
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'test.t' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-03 11:59:20 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 6 ) ):
|
2017-07-03 11:59:20 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': [ 'CDtEF' ],
|
|
|
|
'completion_start_column': 6
|
|
|
|
} )
|
|
|
|
)
|
2016-10-11 16:54:00 -04:00
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 1,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2016-10-11 16:54:00 -04:00
|
|
|
def OmniCompleter_GetCompletions_Cache_ObjectList_test( ycm ):
|
2017-07-03 11:59:20 -04:00
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 5
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
'word': 'a',
|
|
|
|
'abbr': 'ABBR',
|
|
|
|
'menu': 'MENU',
|
|
|
|
'info': 'INFO',
|
|
|
|
'kind': 'K'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'word': 'test',
|
|
|
|
'abbr': 'ABBRTEST',
|
|
|
|
'menu': 'MENUTEST',
|
|
|
|
'info': 'INFOTEST',
|
|
|
|
'kind': 'T'
|
|
|
|
}
|
|
|
|
]
|
2016-10-11 16:54:00 -04:00
|
|
|
|
2017-07-03 11:59:20 -04:00
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'test.tt' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-03 11:59:20 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 7 ) ):
|
2017-07-03 11:59:20 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': contains( {
|
|
|
|
'word': 'test',
|
|
|
|
'abbr': 'ABBRTEST',
|
|
|
|
'menu': 'MENUTEST',
|
|
|
|
'info': 'INFOTEST',
|
|
|
|
'kind': 'T'
|
|
|
|
} ),
|
|
|
|
'completion_start_column': 6
|
|
|
|
} )
|
|
|
|
)
|
2016-10-11 16:54:00 -04:00
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 0,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2016-10-11 16:54:00 -04:00
|
|
|
def OmniCompleter_GetCompletions_NoCache_ObjectList_test( ycm ):
|
2017-07-03 11:59:20 -04:00
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 5
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
'word': 'a',
|
|
|
|
'abbr': 'ABBR',
|
|
|
|
'menu': 'MENU',
|
|
|
|
'info': 'INFO',
|
|
|
|
'kind': 'K'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'word': 'test',
|
|
|
|
'abbr': 'ABBRTEST',
|
|
|
|
'menu': 'MENUTEST',
|
|
|
|
'info': 'INFOTEST',
|
|
|
|
'kind': 'T'
|
|
|
|
}
|
|
|
|
]
|
2016-04-24 09:22:52 -04:00
|
|
|
|
2017-07-03 11:59:20 -04:00
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'test.tt' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-03 11:59:20 -04:00
|
|
|
omnifunc = Omnifunc )
|
2016-04-24 09:22:52 -04:00
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 7 ) ):
|
2017-07-03 11:59:20 -04:00
|
|
|
ycm.SendCompletionRequest()
|
2016-10-11 16:54:00 -04:00
|
|
|
# We don't filter the result - we expect the omnifunc to do that
|
2017-07-03 11:59:20 -04:00
|
|
|
# based on the query we supplied (Note: that means no fuzzy matching!).
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': ToBytesOnPY2( [ {
|
|
|
|
'word': 'a',
|
|
|
|
'abbr': 'ABBR',
|
|
|
|
'menu': 'MENU',
|
|
|
|
'info': 'INFO',
|
|
|
|
'kind': 'K'
|
|
|
|
}, {
|
|
|
|
'word': 'test',
|
|
|
|
'abbr': 'ABBRTEST',
|
|
|
|
'menu': 'MENUTEST',
|
|
|
|
'info': 'INFOTEST',
|
|
|
|
'kind': 'T'
|
|
|
|
} ] ),
|
|
|
|
'completion_start_column': 6
|
|
|
|
} )
|
|
|
|
)
|
2016-04-24 09:22:52 -04:00
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 1,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2016-10-11 16:54:00 -04:00
|
|
|
def OmniCompleter_GetCompletions_Cache_ObjectListObject_test( ycm ):
|
2017-07-03 11:59:20 -04:00
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 5
|
|
|
|
return { 'words': [
|
2016-04-24 09:22:52 -04:00
|
|
|
{
|
2017-07-03 11:59:20 -04:00
|
|
|
'word': 'a',
|
|
|
|
'abbr': 'ABBR',
|
|
|
|
'menu': 'MENU',
|
|
|
|
'info': 'INFO',
|
|
|
|
'kind': 'K'
|
2016-04-24 09:22:52 -04:00
|
|
|
},
|
|
|
|
{
|
2017-07-03 11:59:20 -04:00
|
|
|
'word': 'test',
|
|
|
|
'abbr': 'ABBRTEST',
|
|
|
|
'menu': 'MENUTEST',
|
|
|
|
'info': 'INFOTEST',
|
|
|
|
'kind': 'T'
|
2016-04-24 09:22:52 -04:00
|
|
|
}
|
2017-07-03 11:59:20 -04:00
|
|
|
] }
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'test.tt' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-03 11:59:20 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 7 ) ):
|
2017-07-03 11:59:20 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': ToBytesOnPY2( [ {
|
|
|
|
'word': 'test',
|
|
|
|
'abbr': 'ABBRTEST',
|
|
|
|
'menu': 'MENUTEST',
|
|
|
|
'info': 'INFOTEST',
|
|
|
|
'kind': 'T'
|
|
|
|
} ] ),
|
|
|
|
'completion_start_column': 6
|
|
|
|
} )
|
|
|
|
)
|
2016-04-24 09:22:52 -04:00
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 0,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2016-10-11 16:54:00 -04:00
|
|
|
def OmniCompleter_GetCompletions_NoCache_ObjectListObject_test( ycm ):
|
2017-07-03 11:59:20 -04:00
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 5
|
|
|
|
return { 'words': [
|
2016-04-24 09:22:52 -04:00
|
|
|
{
|
2017-07-03 11:59:20 -04:00
|
|
|
'word': 'a',
|
|
|
|
'abbr': 'ABBR',
|
|
|
|
'menu': 'MENU',
|
|
|
|
'info': 'INFO',
|
|
|
|
'kind': 'K'
|
2016-04-24 09:22:52 -04:00
|
|
|
},
|
|
|
|
{
|
2017-07-03 11:59:20 -04:00
|
|
|
'word': 'test',
|
|
|
|
'abbr': 'ABBRTEST',
|
|
|
|
'menu': 'MENUTEST',
|
|
|
|
'info': 'INFOTEST',
|
|
|
|
'kind': 'T'
|
2016-04-24 09:22:52 -04:00
|
|
|
}
|
2017-07-03 11:59:20 -04:00
|
|
|
] }
|
2016-04-24 09:22:52 -04:00
|
|
|
|
2017-07-03 11:59:20 -04:00
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'test.tt' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-03 11:59:20 -04:00
|
|
|
omnifunc = Omnifunc )
|
2016-04-24 09:22:52 -04:00
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 7 ) ):
|
2017-07-03 11:59:20 -04:00
|
|
|
ycm.SendCompletionRequest()
|
2016-10-11 16:54:00 -04:00
|
|
|
# No FilterAndSortCandidates for cache_omnifunc=0 (we expect the omnifunc
|
|
|
|
# to do the filtering?)
|
2017-07-03 11:59:20 -04:00
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': ToBytesOnPY2( [ {
|
|
|
|
'word': 'a',
|
|
|
|
'abbr': 'ABBR',
|
|
|
|
'menu': 'MENU',
|
|
|
|
'info': 'INFO',
|
|
|
|
'kind': 'K'
|
|
|
|
}, {
|
|
|
|
'word': 'test',
|
|
|
|
'abbr': 'ABBRTEST',
|
|
|
|
'menu': 'MENUTEST',
|
|
|
|
'info': 'INFOTEST',
|
|
|
|
'kind': 'T'
|
|
|
|
} ] ),
|
|
|
|
'completion_start_column': 6
|
|
|
|
} )
|
|
|
|
)
|
2016-04-24 09:22:52 -04:00
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 1,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2016-10-11 16:54:00 -04:00
|
|
|
def OmniCompleter_GetCompletions_Cache_List_Unicode_test( ycm ):
|
2017-07-03 11:59:20 -04:00
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 12
|
|
|
|
return [ '†est', 'å_unicode_identifier', 'πππππππ yummy πie' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ '†åsty_π.' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-03 11:59:20 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 12 ) ):
|
2017-07-03 11:59:20 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
2017-09-24 07:02:08 -04:00
|
|
|
'completions': [ 'å_unicode_identifier',
|
|
|
|
'πππππππ yummy πie',
|
|
|
|
'†est' ],
|
2017-07-03 11:59:20 -04:00
|
|
|
'completion_start_column': 13
|
|
|
|
} )
|
|
|
|
)
|
2016-04-24 09:22:52 -04:00
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 0,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2016-10-11 16:54:00 -04:00
|
|
|
def OmniCompleter_GetCompletions_NoCache_List_Unicode_test( ycm ):
|
2017-07-03 11:59:20 -04:00
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 12
|
|
|
|
return [ '†est', 'å_unicode_identifier', 'πππππππ yummy πie' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ '†åsty_π.' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-03 11:59:20 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 12 ) ):
|
2017-07-03 11:59:20 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': ToBytesOnPY2( [ '†est',
|
|
|
|
'å_unicode_identifier',
|
|
|
|
'πππππππ yummy πie' ] ),
|
|
|
|
'completion_start_column': 13
|
|
|
|
} )
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 1,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2016-10-11 16:54:00 -04:00
|
|
|
def OmniCompleter_GetCompletions_Cache_List_Filter_Unicode_test( ycm ):
|
2017-07-03 11:59:20 -04:00
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 12
|
|
|
|
return [ '†est', 'å_unicode_identifier', 'πππππππ yummy πie' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ '†åsty_π.ππ' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-03 11:59:20 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 17 ) ):
|
2017-07-03 11:59:20 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
2017-09-24 07:02:08 -04:00
|
|
|
'completions': [ 'πππππππ yummy πie' ],
|
2017-07-03 11:59:20 -04:00
|
|
|
'completion_start_column': 13
|
|
|
|
} )
|
|
|
|
)
|
2016-04-24 09:22:52 -04:00
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 0,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2016-10-11 16:54:00 -04:00
|
|
|
def OmniCompleter_GetCompletions_NoCache_List_Filter_Unicode_test( ycm ):
|
2017-07-03 11:59:20 -04:00
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 12
|
|
|
|
return [ 'πππππππ yummy πie' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ '†åsty_π.ππ' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-03 11:59:20 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 17 ) ):
|
2017-07-03 11:59:20 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': ToBytesOnPY2( [ 'πππππππ yummy πie' ] ),
|
|
|
|
'completion_start_column': 13
|
|
|
|
} )
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 1,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2016-10-11 16:54:00 -04:00
|
|
|
def OmniCompleter_GetCompletions_Cache_ObjectList_Unicode_test( ycm ):
|
2017-07-03 11:59:20 -04:00
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 12
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
'word': 'ålpha∫et',
|
|
|
|
'abbr': 'å∫∫®',
|
|
|
|
'menu': 'µ´~¨á',
|
|
|
|
'info': '^~fo',
|
|
|
|
'kind': '˚'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'word': 'π†´ß†π',
|
|
|
|
'abbr': 'ÅııÂʉÍÊ',
|
|
|
|
'menu': '˜‰ˆËʉÍÊ',
|
|
|
|
'info': 'ȈÏØʉÍÊ',
|
|
|
|
'kind': 'Ê'
|
|
|
|
}
|
|
|
|
]
|
2016-04-24 09:22:52 -04:00
|
|
|
|
2017-07-03 11:59:20 -04:00
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ '†åsty_π.ππ' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-03 11:59:20 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 17 ) ):
|
2017-07-03 11:59:20 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
2017-09-24 07:02:08 -04:00
|
|
|
'completions': [ {
|
2017-07-03 11:59:20 -04:00
|
|
|
'word': 'π†´ß†π',
|
|
|
|
'abbr': 'ÅııÂʉÍÊ',
|
|
|
|
'menu': '˜‰ˆËʉÍÊ',
|
|
|
|
'info': 'ȈÏØʉÍÊ',
|
|
|
|
'kind': 'Ê'
|
2017-09-24 07:02:08 -04:00
|
|
|
} ],
|
2017-07-03 11:59:20 -04:00
|
|
|
'completion_start_column': 13
|
|
|
|
} )
|
|
|
|
)
|
2016-04-24 09:22:52 -04:00
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 1,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2016-10-11 16:54:00 -04:00
|
|
|
def OmniCompleter_GetCompletions_Cache_ObjectListObject_Unicode_test( ycm ):
|
2017-07-03 11:59:20 -04:00
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 12
|
|
|
|
return {
|
|
|
|
'words': [
|
|
|
|
{
|
|
|
|
'word': 'ålpha∫et',
|
|
|
|
'abbr': 'å∫∫®',
|
|
|
|
'menu': 'µ´~¨á',
|
|
|
|
'info': '^~fo',
|
|
|
|
'kind': '˚'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'word': 'π†´ß†π',
|
|
|
|
'abbr': 'ÅııÂʉÍÊ',
|
|
|
|
'menu': '˜‰ˆËʉÍÊ',
|
|
|
|
'info': 'ȈÏØʉÍÊ',
|
|
|
|
'kind': 'Ê'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'word': 'test',
|
|
|
|
'abbr': 'ÅııÂʉÍÊ',
|
|
|
|
'menu': '˜‰ˆËʉÍÊ',
|
|
|
|
'info': 'ȈÏØʉÍÊ',
|
|
|
|
'kind': 'Ê'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2016-04-24 09:22:52 -04:00
|
|
|
|
2017-07-03 11:59:20 -04:00
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ '†åsty_π.t' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-03 11:59:20 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 13 ) ):
|
2017-07-03 11:59:20 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': contains( {
|
|
|
|
'word': 'test',
|
|
|
|
'abbr': 'ÅııÂʉÍÊ',
|
|
|
|
'menu': '˜‰ˆËʉÍÊ',
|
|
|
|
'info': 'ȈÏØʉÍÊ',
|
|
|
|
'kind': 'Ê'
|
2017-09-24 07:02:08 -04:00
|
|
|
}, {
|
|
|
|
'word': 'ålpha∫et',
|
|
|
|
'abbr': 'å∫∫®',
|
|
|
|
'menu': 'µ´~¨á',
|
|
|
|
'info': '^~fo',
|
|
|
|
'kind': '˚'
|
2017-07-03 11:59:20 -04:00
|
|
|
} ),
|
|
|
|
'completion_start_column': 13
|
|
|
|
} )
|
|
|
|
)
|
2017-07-07 07:59:57 -04:00
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 1,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2017-07-07 07:59:57 -04:00
|
|
|
def OmniCompleter_GetCompletions_RestoreCursorPositionAfterOmnifuncCall_test(
|
|
|
|
ycm ):
|
|
|
|
|
|
|
|
# This omnifunc moves the cursor to the test definition like
|
|
|
|
# ccomplete#Complete would.
|
|
|
|
def Omnifunc( findstart, base ):
|
2018-08-13 11:34:04 -04:00
|
|
|
vimsupport.SetCurrentLineAndColumn( 0, 0 )
|
2017-07-07 07:59:57 -04:00
|
|
|
if findstart:
|
|
|
|
return 5
|
|
|
|
return [ 'length' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'String test',
|
|
|
|
'',
|
|
|
|
'test.' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-07 07:59:57 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 3, 5 ) ):
|
2017-07-07 07:59:57 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
assert_that(
|
|
|
|
vimsupport.CurrentLineAndColumn(),
|
|
|
|
contains( 2, 5 )
|
|
|
|
)
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': ToBytesOnPY2( [ 'length' ] ),
|
|
|
|
'completion_start_column': 6
|
|
|
|
} )
|
|
|
|
)
|
2017-07-07 08:11:45 -04:00
|
|
|
|
|
|
|
|
2018-08-09 08:42:12 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 1,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
|
|
|
def OmniCompleter_GetCompletions_MoveCursorPositionAtStartColumn_test( ycm ):
|
|
|
|
# This omnifunc relies on the cursor being moved at the start column when
|
|
|
|
# called the second time like LanguageClient#complete from the
|
|
|
|
# LanguageClient-neovim plugin.
|
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 5
|
|
|
|
if vimsupport.CurrentColumn() == 5:
|
|
|
|
return [ 'length' ]
|
|
|
|
return []
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'String test',
|
|
|
|
'',
|
|
|
|
'test.le' ],
|
|
|
|
filetype = FILETYPE,
|
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 3, 7 ) ):
|
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
assert_that(
|
|
|
|
vimsupport.CurrentLineAndColumn(),
|
|
|
|
contains( 2, 7 )
|
|
|
|
)
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': ToBytesOnPY2( [ 'length' ] ),
|
|
|
|
'completion_start_column': 6
|
|
|
|
} )
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-08-16 11:21:50 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 1 } )
|
|
|
|
def StartColumnCompliance( ycm,
|
|
|
|
omnifunc_start_column,
|
|
|
|
ycm_completions,
|
|
|
|
ycm_start_column ):
|
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return omnifunc_start_column
|
|
|
|
return [ 'foo' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'fo' ],
|
|
|
|
filetype = FILETYPE,
|
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 2 ) ):
|
|
|
|
ycm.SendCompletionRequest( force_semantic = True )
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': ToBytesOnPY2( ycm_completions ),
|
|
|
|
'completion_start_column': ycm_start_column
|
|
|
|
} )
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def OmniCompleter_GetCompletions_StartColumnCompliance_test():
|
|
|
|
yield StartColumnCompliance, -4, [ 'foo' ], 3
|
|
|
|
yield StartColumnCompliance, -3, [], 1
|
|
|
|
yield StartColumnCompliance, -2, [], 1
|
|
|
|
yield StartColumnCompliance, -1, [ 'foo' ], 3
|
|
|
|
yield StartColumnCompliance, 0, [ 'foo' ], 1
|
|
|
|
yield StartColumnCompliance, 1, [ 'foo' ], 2
|
|
|
|
yield StartColumnCompliance, 2, [ 'foo' ], 3
|
|
|
|
yield StartColumnCompliance, 3, [ 'foo' ], 3
|
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 0,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2017-07-07 08:11:45 -04:00
|
|
|
def OmniCompleter_GetCompletions_NoCache_NoSemanticTrigger_test( ycm ):
|
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 0
|
|
|
|
return [ 'test' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'te' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-07 08:11:45 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 3 ) ):
|
2017-07-07 08:11:45 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': empty(),
|
|
|
|
'completion_start_column': 1
|
|
|
|
} )
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-05-14 08:18:18 -04:00
|
|
|
@YouCompleteMeInstance( { 'g:ycm_cache_omnifunc': 0,
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2017-07-07 08:11:45 -04:00
|
|
|
def OmniCompleter_GetCompletions_NoCache_ForceSemantic_test( ycm ):
|
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 0
|
|
|
|
return [ 'test' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'te' ],
|
2017-11-06 17:51:16 -05:00
|
|
|
filetype = FILETYPE,
|
2017-07-07 08:11:45 -04:00
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 3 ) ):
|
2017-07-07 08:11:45 -04:00
|
|
|
ycm.SendCompletionRequest( force_semantic = True )
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': ToBytesOnPY2( [ 'test' ] ),
|
|
|
|
'completion_start_column': 1
|
|
|
|
} )
|
|
|
|
)
|
2018-03-26 10:51:07 -04:00
|
|
|
|
|
|
|
|
|
|
|
@YouCompleteMeInstance( {
|
2018-05-14 08:18:18 -04:00
|
|
|
'g:ycm_cache_omnifunc': 0,
|
|
|
|
'g:ycm_filetype_specific_completion_to_disable': { FILETYPE: 1 },
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2018-03-26 10:51:07 -04:00
|
|
|
def OmniCompleter_GetCompletions_FiletypeDisabled_SemanticTrigger_test( ycm ):
|
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 5
|
|
|
|
return [ 'a', 'b', 'cdef' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'test.' ],
|
|
|
|
filetype = FILETYPE,
|
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 6 ) ):
|
2018-03-26 10:51:07 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': empty(),
|
|
|
|
'completion_start_column': 6
|
|
|
|
} )
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@YouCompleteMeInstance( {
|
2018-05-14 08:18:18 -04:00
|
|
|
'g:ycm_cache_omnifunc': 0,
|
|
|
|
'g:ycm_filetype_specific_completion_to_disable': { '*': 1 },
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2018-03-26 10:51:07 -04:00
|
|
|
def OmniCompleter_GetCompletions_AllFiletypesDisabled_SemanticTrigger_test(
|
|
|
|
ycm ):
|
|
|
|
|
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 5
|
|
|
|
return [ 'a', 'b', 'cdef' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'test.' ],
|
|
|
|
filetype = FILETYPE,
|
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 6 ) ):
|
2018-03-26 10:51:07 -04:00
|
|
|
ycm.SendCompletionRequest()
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': empty(),
|
|
|
|
'completion_start_column': 6
|
|
|
|
} )
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@YouCompleteMeInstance( {
|
2018-05-14 08:18:18 -04:00
|
|
|
'g:ycm_cache_omnifunc': 0,
|
|
|
|
'g:ycm_filetype_specific_completion_to_disable': { FILETYPE: 1 },
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2018-03-26 10:51:07 -04:00
|
|
|
def OmniCompleter_GetCompletions_FiletypeDisabled_ForceSemantic_test( ycm ):
|
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 5
|
|
|
|
return [ 'a', 'b', 'cdef' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'test.' ],
|
|
|
|
filetype = FILETYPE,
|
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 6 ) ):
|
2018-03-26 10:51:07 -04:00
|
|
|
ycm.SendCompletionRequest( force_semantic = True )
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': ToBytesOnPY2( [ 'a', 'b', 'cdef' ] ),
|
|
|
|
'completion_start_column': 6
|
|
|
|
} )
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@YouCompleteMeInstance( {
|
2018-05-14 08:18:18 -04:00
|
|
|
'g:ycm_cache_omnifunc': 0,
|
|
|
|
'g:ycm_filetype_specific_completion_to_disable': { '*': 1 },
|
|
|
|
'g:ycm_semantic_triggers': TRIGGERS } )
|
2018-03-26 10:51:07 -04:00
|
|
|
def OmniCompleter_GetCompletions_AllFiletypesDisabled_ForceSemantic_test( ycm ):
|
|
|
|
def Omnifunc( findstart, base ):
|
|
|
|
if findstart:
|
|
|
|
return 5
|
|
|
|
return [ 'a', 'b', 'cdef' ]
|
|
|
|
|
|
|
|
current_buffer = VimBuffer( 'buffer',
|
|
|
|
contents = [ 'test.' ],
|
|
|
|
filetype = FILETYPE,
|
|
|
|
omnifunc = Omnifunc )
|
|
|
|
|
2018-05-17 08:52:40 -04:00
|
|
|
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 6 ) ):
|
2018-03-26 10:51:07 -04:00
|
|
|
ycm.SendCompletionRequest( force_semantic = True )
|
|
|
|
assert_that(
|
|
|
|
ycm.GetCompletionResponse(),
|
|
|
|
has_entries( {
|
|
|
|
'completions': ToBytesOnPY2( [ 'a', 'b', 'cdef' ] ),
|
|
|
|
'completion_start_column': 6
|
|
|
|
} )
|
|
|
|
)
|