Commit 97ff8a6e authored by David Kalnischkies's avatar David Kalnischkies

New upstream version 0+20180620+gite1ead99

parent 5b1dd9b0
This diff is collapsed.
......@@ -98,15 +98,7 @@ function! s:ReceiveMessages( timer_id )
endfunction
function! youcompleteme#Enable()
call s:SetUpBackwardsCompatibility()
" This can be 0 if YCM libs are old or -1 if an exception occured while
" executing the function.
if s:SetUpPython() != 1
return
endif
function! s:SetUpOptions()
call s:SetUpCommands()
call s:SetUpCpoptions()
call s:SetUpCompleteopt()
......@@ -118,6 +110,17 @@ function! youcompleteme#Enable()
call s:SetUpSigns()
call s:SetUpSyntaxHighlighting()
endfunction
function! youcompleteme#Enable()
call s:SetUpBackwardsCompatibility()
if !s:SetUpPython()
return
endif
call s:SetUpOptions()
call youcompleteme#EnableCursorMovedAutocommands()
augroup youcompleteme
......@@ -191,17 +194,20 @@ import vim
# Add python sources folder to the system path.
script_folder = vim.eval( 's:script_folder_path' )
sys.path.insert( 0, os.path.join( script_folder, '..', 'python' ) )
from ycm.setup import SetUpSystemPaths, SetUpYCM
sys.path.insert( 0, os.path.join( script_folder, '..', 'third_party', 'ycmd' ) )
# We enclose this code in a try/except block to avoid backtraces in Vim.
try:
SetUpSystemPaths()
from ycmd import server_utils as su
su.AddNearestThirdPartyFoldersToSysPath( script_folder )
# We need to import ycmd's third_party folders as well since we import and
# use ycmd code in the client.
su.AddNearestThirdPartyFoldersToSysPath( su.__file__ )
# Import the modules used in this file.
from ycm import base, vimsupport
from ycm import base, vimsupport, youcompleteme
ycm_state = SetUpYCM()
ycm_state = youcompleteme.YouCompleteMe()
except Exception as error:
# We don't use PostVimMessage or EchoText from the vimsupport module because
# importing this module may fail.
......@@ -363,6 +369,7 @@ function! s:TurnOffSyntasticForCFamily()
let g:syntastic_c_checkers = []
let g:syntastic_objc_checkers = []
let g:syntastic_objcpp_checkers = []
let g:syntastic_cuda_checkers = []
endfunction
......@@ -849,6 +856,8 @@ endfunction
function! s:RestartServer()
call s:SetUpOptions()
exec s:python_command "ycm_state.RestartServer()"
call timer_stop( s:pollers.receive_messages.id )
......
This diff is collapsed.
flake8 >= 3.0.0
flake8-comprehensions >= 1.4.1
flake8-ycm >= 0.1.0
mock >= 1.0.1
nose >= 1.3.7
PyHamcrest >= 1.8.0
......
......@@ -27,7 +27,8 @@ from ycm.client.event_notification import EventNotification
from ycm.diagnostic_interface import DiagnosticInterface
DIAGNOSTIC_UI_FILETYPES = { 'cpp', 'cs', 'c', 'objc', 'objcpp', 'typescript' }
DIAGNOSTIC_UI_FILETYPES = { 'cpp', 'cs', 'c', 'objc', 'objcpp', 'cuda',
'typescript' }
DIAGNOSTIC_UI_ASYNC_FILETYPES = { 'java' }
......
......@@ -32,7 +32,7 @@ from ycmd.utils import ToBytes, urljoin, urlparse, GetCurrentDirectory
from ycmd.hmac_utils import CreateRequestHmac, CreateHmac, SecureBytesEqual
from ycmd.responses import ServerError, UnknownExtraConf
_HEADERS = {'content-type': 'application/json'}
_HEADERS = { 'content-type': 'application/json' }
_CONNECT_TIMEOUT_SEC = 0.01
# Setting this to None seems to screw up the Requests/urllib3 libs.
_READ_TIMEOUT_SEC = 30
......
......@@ -94,7 +94,7 @@ def _FormatCompleterDebugInfo( completer ):
message += ' {0} process ID: {1}\n'.format( name, server[ 'pid' ] )
else:
message += ' {0} not running\n'.format( name )
message += ' {0} executable: {1}\n'.format( name, server[ 'executable'] )
message += ' {0} executable: {1}\n'.format( name, server[ 'executable' ] )
logfiles = server[ 'logfiles' ]
if logfiles:
message += ' {0} logfiles:\n'.format( name )
......
# Copyright (C) 2013 Google Inc.
# Copyright (C) 2013-2018 YouCompleteMe contributors
#
# This file is part of YouCompleteMe.
#
......@@ -36,7 +36,6 @@ class DiagnosticInterface( object ):
self._diag_filter = DiagnosticFilter.CreateFromOptions( user_options )
# Line and column numbers are 1-based
self._line_to_diags = defaultdict( list )
self._next_sign_id = vimsupport.SIGN_BUFFER_ID_INITIAL_VALUE
self._previous_diag_line_number = -1
self._diag_message_needs_clearing = False
......@@ -60,7 +59,7 @@ class DiagnosticInterface( object ):
def PopulateLocationList( self ):
# Do nothing if loc list is already populated by diag_interface
if not self._user_options[ 'always_populate_location_list' ]:
self._UpdateLocationList()
self._UpdateLocationLists()
return bool( self._diagnostics )
......@@ -78,7 +77,7 @@ class DiagnosticInterface( object ):
self.UpdateMatches()
if self._user_options[ 'always_populate_location_list' ]:
self._UpdateLocationList()
self._UpdateLocationLists()
def _ApplyDiagnosticFilter( self, diags ):
......@@ -120,8 +119,8 @@ class DiagnosticInterface( object ):
return count
def _UpdateLocationList( self ):
vimsupport.SetLocationListForBuffer(
def _UpdateLocationLists( self ):
vimsupport.SetLocationListsForBuffer(
self._bufnr,
vimsupport.ConvertDiagnosticsToQfList( self._diagnostics ) )
......@@ -130,46 +129,28 @@ class DiagnosticInterface( object ):
if not self._user_options[ 'enable_diagnostic_highlighting' ]:
return
matches_to_remove = vimsupport.GetDiagnosticMatchesInCurrentWindow()
with vimsupport.CurrentWindow():
for window in vimsupport.GetWindowsForBufferNumber( self._bufnr ):
vimsupport.SwitchWindow( window )
for diags in itervalues( self._line_to_diags ):
# Insert squiggles in reverse order so that errors overlap warnings.
for diag in reversed( diags ):
patterns = []
group = ( 'YcmErrorSection' if _DiagnosticIsError( diag ) else
'YcmWarningSection' )
location_extent = diag[ 'location_extent' ]
if location_extent[ 'start' ][ 'line_num' ] <= 0:
location = diag[ 'location' ]
patterns.append( vimsupport.GetDiagnosticMatchPattern(
location[ 'line_num' ],
location[ 'column_num' ] ) )
else:
patterns.append( vimsupport.GetDiagnosticMatchPattern(
location_extent[ 'start' ][ 'line_num' ],
location_extent[ 'start' ][ 'column_num' ],
location_extent[ 'end' ][ 'line_num' ],
location_extent[ 'end' ][ 'column_num' ] ) )
for diag_range in diag[ 'ranges' ]:
patterns.append( vimsupport.GetDiagnosticMatchPattern(
diag_range[ 'start' ][ 'line_num' ],
diag_range[ 'start' ][ 'column_num' ],
diag_range[ 'end' ][ 'line_num' ],
diag_range[ 'end' ][ 'column_num' ] ) )
for pattern in patterns:
# The id doesn't matter for matches that we may add.
match = vimsupport.DiagnosticMatch( 0, group, pattern )
try:
matches_to_remove.remove( match )
except ValueError:
vimsupport.AddDiagnosticMatch( match )
for match in matches_to_remove:
vimsupport.RemoveDiagnosticMatch( match )
matches_to_remove = vimsupport.GetDiagnosticMatchesInCurrentWindow()
for diags in itervalues( self._line_to_diags ):
# Insert squiggles in reverse order so that errors overlap warnings.
for diag in reversed( diags ):
group = ( 'YcmErrorSection' if _DiagnosticIsError( diag ) else
'YcmWarningSection' )
for pattern in _ConvertDiagnosticToMatchPatterns( diag ):
# The id doesn't matter for matches that we may add.
match = vimsupport.DiagnosticMatch( 0, group, pattern )
try:
matches_to_remove.remove( match )
except ValueError:
vimsupport.AddDiagnosticMatch( match )
for match in matches_to_remove:
vimsupport.RemoveDiagnosticMatch( match )
def _UpdateSigns( self ):
......@@ -183,16 +164,12 @@ class DiagnosticInterface( object ):
# are sorted by errors in priority and Vim can only display one sign by
# line.
name = 'YcmError' if _DiagnosticIsError( diags[ 0 ] ) else 'YcmWarning'
sign = vimsupport.DiagnosticSign( self._next_sign_id,
line,
name,
self._bufnr )
sign = vimsupport.CreateSign( line, name, self._bufnr )
try:
signs_to_unplace.remove( sign )
except ValueError:
vimsupport.PlaceSign( sign )
self._next_sign_id += 1
for sign in signs_to_unplace:
vimsupport.UnplaceSign( sign )
......@@ -226,3 +203,29 @@ def _NormalizeDiagnostic( diag ):
location[ 'column_num' ] = ClampToOne( location[ 'column_num' ] )
location[ 'line_num' ] = ClampToOne( location[ 'line_num' ] )
return diag
def _ConvertDiagnosticToMatchPatterns( diagnostic ):
patterns = []
location_extent = diagnostic[ 'location_extent' ]
if location_extent[ 'start' ][ 'line_num' ] <= 0:
location = diagnostic[ 'location' ]
patterns.append( vimsupport.GetDiagnosticMatchPattern(
location[ 'line_num' ],
location[ 'column_num' ] ) )
else:
patterns.append( vimsupport.GetDiagnosticMatchPattern(
location_extent[ 'start' ][ 'line_num' ],
location_extent[ 'start' ][ 'column_num' ],
location_extent[ 'end' ][ 'line_num' ],
location_extent[ 'end' ][ 'column_num' ] ) )
for diagnostic_range in diagnostic[ 'ranges' ]:
patterns.append( vimsupport.GetDiagnosticMatchPattern(
diagnostic_range[ 'start' ][ 'line_num' ],
diagnostic_range[ 'start' ][ 'column_num' ],
diagnostic_range[ 'end' ][ 'line_num' ],
diagnostic_range[ 'end' ][ 'column_num' ] ) )
return patterns
# Copyright (C) 2016 YouCompleteMe contributors
#
# 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
# No imports from `future` because when this is loaded, sys.path hasn't been set
# up yet!
import sys
import os
# Can't import these from paths.py because that uses `future` imports
DIR_OF_CURRENT_SCRIPT = os.path.dirname( os.path.abspath( __file__ ) )
DIR_OF_YCMD = os.path.join( DIR_OF_CURRENT_SCRIPT, '..', '..', 'third_party',
'ycmd' )
def SetUpSystemPaths():
sys.path.insert( 0, os.path.join( DIR_OF_YCMD ) )
from ycmd import server_utils as su
su.AddNearestThirdPartyFoldersToSysPath( DIR_OF_CURRENT_SCRIPT )
# We need to import ycmd's third_party folders as well since we import and
# use ycmd code in the client.
su.AddNearestThirdPartyFoldersToSysPath( su.__file__ )
def SetUpYCM():
from ycm import base
from ycmd import user_options_store
from ycm.youcompleteme import YouCompleteMe
base.LoadJsonDefaultsIntoVim()
user_options_store.SetAll( base.BuildServerConf() )
return YouCompleteMe( user_options_store.GetAll() )
......@@ -42,7 +42,7 @@ SYNTAX_ARGUMENT_REGEX = re.compile(
r"^\w+=.*$" )
SYNTAX_REGION_ARGUMENT_REGEX = re.compile(
r"^(?:matchgroup|start)=.*$")
r"^(?:matchgroup|start)=.*$" )
# See ":h syn-nextgroup".
SYNTAX_NEXTGROUP_ARGUMENTS = {
......@@ -106,7 +106,7 @@ def _SyntaxGroupsFromOutput( syntax_output ):
group_name_to_group[ current_group.name ] = current_group
current_group = SyntaxGroup( match.group( 'group_name' ),
[ match.group( 'content').strip() ] )
[ match.group( 'content' ).strip() ] )
else:
if looking_for_group:
continue
......
# Copyright (C) 2016 YouCompleteMe contributors
# Copyright (C) 2016-2018 YouCompleteMe contributors
#
# This file is part of YouCompleteMe.
#
......@@ -25,6 +25,7 @@ from builtins import * # noqa
from ycm.tests.test_utils import MockVimModule
MockVimModule()
import contextlib
import functools
import os
import requests
......@@ -32,22 +33,23 @@ import time
import warnings
from ycm.client.base_request import BaseRequest
from ycm.tests import test_utils
from ycm.youcompleteme import YouCompleteMe
from ycmd import user_options_store
from ycmd.utils import CloseStandardStreams, WaitUntilProcessIsTerminated
# The default options which are only relevant to the client, not the server and
# thus are not part of default_options.json, but are required for a working
# YouCompleteMe object.
DEFAULT_CLIENT_OPTIONS = {
'log_level': 'info',
'keep_logfiles': 0,
'extra_conf_vim_data': [],
'show_diagnostics_ui': 1,
'echo_current_diagnostic': 1,
'enable_diagnostic_signs': 1,
'enable_diagnostic_highlighting': 0,
'always_populate_location_list': 0,
'g:ycm_server_python_interpreter': '',
'g:ycm_log_level': 'info',
'g:ycm_keep_logfiles': 0,
'g:ycm_extra_conf_vim_data': [],
'g:ycm_show_diagnostics_ui': 1,
'g:ycm_echo_current_diagnostic': 1,
'g:ycm_enable_diagnostic_signs': 1,
'g:ycm_enable_diagnostic_highlighting': 0,
'g:ycm_always_populate_location_list': 0,
}
......@@ -56,11 +58,15 @@ def PathToTestFile( *args ):
return os.path.join( dir_of_current_script, 'testdata', *args )
def MakeUserOptions( custom_options = {} ):
options = dict( user_options_store.DefaultOptions() )
options.update( DEFAULT_CLIENT_OPTIONS )
options.update( custom_options )
return options
@contextlib.contextmanager
def UserOptions( options ):
old_vim_options = test_utils.VIM_OPTIONS.copy()
test_utils.VIM_OPTIONS.update( DEFAULT_CLIENT_OPTIONS )
test_utils.VIM_OPTIONS.update( options )
try:
yield
finally:
test_utils.VIM_OPTIONS = old_vim_options
def _IsReady():
......@@ -123,12 +129,13 @@ def YouCompleteMeInstance( custom_options = {} ):
def Decorator( test ):
@functools.wraps( test )
def Wrapper( *args, **kwargs ):
ycm = YouCompleteMe( MakeUserOptions( custom_options ) )
WaitUntilReady()
ycm.CheckIfServerIsReady()
try:
test( ycm, *args, **kwargs )
finally:
StopServer( ycm )
with UserOptions( custom_options ):
ycm = YouCompleteMe()
WaitUntilReady()
ycm.CheckIfServerIsReady()
try:
test( ycm, *args, **kwargs )
finally:
StopServer( ycm )
return Wrapper
return Decorator
......@@ -35,7 +35,7 @@ from ycm import base
@contextlib.contextmanager
def MockCurrentFiletypes( filetypes = [''] ):
def MockCurrentFiletypes( filetypes = [ '' ] ):
with patch( 'ycm.vimsupport.CurrentFiletypes', return_value = filetypes ):
yield
......@@ -180,7 +180,7 @@ def LastEnteredCharIsIdentifierChar_Basic_test():
def LastEnteredCharIsIdentifierChar_FiletypeHtml_test():
with MockCurrentFiletypes( ['html'] ):
with MockCurrentFiletypes( [ 'html' ] ):
with MockCurrentColumnAndLineContents( 3, 'ab-' ):
ok_( base.LastEnteredCharIsIdentifierChar() )
......@@ -272,7 +272,7 @@ def CurrentIdentifierFinished_InMiddleOfLine_test():
def CurrentIdentifierFinished_Html_test():
with MockCurrentFiletypes( ['html'] ):
with MockCurrentFiletypes( [ 'html' ] ):
with MockCurrentColumnAndLineContents( 4, 'bar-zoo' ):
ok_( not base.CurrentIdentifierFinished() )
......
......@@ -34,7 +34,7 @@ from ycm.client.base_request import BuildRequestData
return_value = '/some/dir' )
def BuildRequestData_AddWorkingDir_test( *args ):
current_buffer = VimBuffer( 'foo' )
with MockVimBuffers( [ current_buffer ], current_buffer, ( 1, 1 ) ):
with MockVimBuffers( [ current_buffer ], [ current_buffer ] ):
assert_that( BuildRequestData(), has_entry( 'working_dir', '/some/dir' ) )
......@@ -42,6 +42,6 @@ def BuildRequestData_AddWorkingDir_test( *args ):
return_value = '/some/dir' )
def BuildRequestData_AddWorkingDirWithFileName_test( *args ):
current_buffer = VimBuffer( 'foo' )
with MockVimBuffers( [ current_buffer ], current_buffer, ( 1, 1 ) ):
with MockVimBuffers( [ current_buffer ], [ current_buffer ] ):
assert_that( BuildRequestData( current_buffer.number ),
has_entry( 'working_dir', '/some/dir' ) )
......@@ -203,7 +203,7 @@ class Response_Detection_test( object ):
[ 'and8434fd andy garbag!',
basic_fixit, basic_fixit_chunks, 0, False ],
[ 'Format',
basic_fixit, basic_fixit_chunks, 0, True ],
basic_fixit, basic_fixit_chunks, 0, True ],
[ 'select from multiple 1',
multi_fixit, multi_fixit_first_chunks, 0, False ],
[ 'select from multiple 2',
......@@ -293,7 +293,7 @@ class Response_Detection_test( object ):
[ GoToTest, 'FindAThing', basic_goto ],
[ GoToTest, 'FixItGoto', basic_goto ],
[ GoToListTest, 'AnythingYouLike', [ basic_goto ] ],
[ GoToListTest, 'GoTo', [] ],
[ GoToListTest, 'GoTo', [] ],
[ GoToListTest, 'FixItGoto', [ basic_goto, basic_goto ] ],
]
......
......@@ -98,10 +98,10 @@ def HandlePollResponse_MultipleDiagnostics_test():
assert_that( _HandlePollResponse( messages, diagnostics_handler ),
equal_to( True ) )
diagnostics_handler.UpdateWithNewDiagnosticsForFile.assert_has_exact_calls( [
call ( 'foo', [ 'PLACEHOLDER1' ] ),
call ( 'bar', [ 'PLACEHOLDER2' ] ),
call ( 'baz', [ 'PLACEHOLDER3' ] ),
call ( 'foo', [ 'PLACEHOLDER4' ] )
call( 'foo', [ 'PLACEHOLDER1' ] ),
call( 'bar', [ 'PLACEHOLDER2' ] ),
call( 'baz', [ 'PLACEHOLDER3' ] ),
call( 'foo', [ 'PLACEHOLDER4' ] )
] )
......@@ -122,10 +122,10 @@ def HandlePollResponse_MultipleMessagesAndDiagnostics_test( post_vim_message ):
assert_that( _HandlePollResponse( messages, diagnostics_handler ),
equal_to( True ) )
diagnostics_handler.UpdateWithNewDiagnosticsForFile.assert_has_exact_calls( [
call ( 'foo', [ 'PLACEHOLDER1' ] ),
call ( 'bar', [ 'PLACEHOLDER2' ] ),
call ( 'baz', [ 'PLACEHOLDER3' ] ),
call ( 'foo', [ 'PLACEHOLDER4' ] )
call( 'foo', [ 'PLACEHOLDER1' ] ),
call( 'bar', [ 'PLACEHOLDER2' ] ),
call( 'baz', [ 'PLACEHOLDER3' ] ),
call( 'foo', [ 'PLACEHOLDER4' ] )
] )
post_vim_message.assert_has_exact_calls( [
......
......@@ -64,8 +64,8 @@ def RawResponse_ConvertedFromOmniCompleter_test():
"kind": "KIND", "info": "INFO" },
{ "word": "WORD2", "abbr": "ABBR2", "menu": "MENU2",
"kind": "KIND2", "info": "INFO" },
{ "word": "WORD", "abbr": "ABBR", },
{ },
{ "word": "WORD", "abbr": "ABBR", },
{},
]
expected_results = [
has_entries( { "insertion_text": "WORD", "menu_text": "ABBR",
......@@ -74,8 +74,8 @@ def RawResponse_ConvertedFromOmniCompleter_test():
has_entries( { "insertion_text": "WORD2", "menu_text": "ABBR2",
"extra_menu_info": "MENU2", "kind": [ "KIND2" ],
"detailed_info": "INFO" } ),
has_entries( { "insertion_text": "WORD", "menu_text": "ABBR", } ),
has_entries( { } ),
has_entries( { "insertion_text": "WORD", "menu_text": "ABBR", } ),
has_entries( {} ),
]
request = BuildOmnicompletionRequest( vim_results )
......
......@@ -31,10 +31,10 @@ from mock import patch
from ycm.tests import YouCompleteMeInstance
@YouCompleteMeInstance( { 'extra_conf_vim_data': [ 'tempname()' ] } )
@YouCompleteMeInstance( { 'g:ycm_extra_conf_vim_data': [ 'tempname()' ] } )
def SendCommandRequest_ExtraConfVimData_Works_test( ycm ):
current_buffer = VimBuffer( 'buffer' )
with MockVimBuffers( [ current_buffer ], current_buffer ):
with MockVimBuffers( [ current_buffer ], [ current_buffer ] ):
with patch( 'ycm.youcompleteme.SendCommandRequest' ) as send_request:
ycm.SendCommandRequest( [ 'GoTo' ], 'python', False, 1, 1 )
assert_that(
......@@ -56,10 +56,10 @@ def SendCommandRequest_ExtraConfVimData_Works_test( ycm ):
)
@YouCompleteMeInstance( { 'extra_conf_vim_data': [ 'undefined_value' ] } )
@YouCompleteMeInstance( { 'g:ycm_extra_conf_vim_data': [ 'undefined_value' ] } )
def SendCommandRequest_ExtraConfData_UndefinedValue_test( ycm ):
current_buffer = VimBuffer( 'buffer' )
with MockVimBuffers( [ current_buffer ], current_buffer ):
with MockVimBuffers( [ current_buffer ], [ current_buffer ] ):
with patch( 'ycm.youcompleteme.SendCommandRequest' ) as send_request:
ycm.SendCommandRequest( [ 'GoTo' ], 'python', False, 1, 1 )
assert_that(
......@@ -82,7 +82,7 @@ def SendCommandRequest_ExtraConfData_UndefinedValue_test( ycm ):
def SendCommandRequest_BuildRange_NoVisualMarks_test( ycm, *args ):
current_buffer = VimBuffer( 'buffer', contents = [ 'first line',
'second line' ] )
with MockVimBuffers( [ current_buffer ], current_buffer ):
with MockVimBuffers( [ current_buffer ], [ current_buffer ] ):
with patch( 'ycm.youcompleteme.SendCommandRequest' ) as send_request:
ycm.SendCommandRequest( [ 'GoTo' ], 'python', True, 1, 2 )
send_request.assert_called_once_with(
......@@ -114,7 +114,7 @@ def SendCommandRequest_BuildRange_VisualMarks_test( ycm, *args ):
'second line' ],
visual_start = [ 1, 4 ],
visual_end = [ 2, 8 ] )
with MockVimBuffers( [ current_buffer ], current_buffer ):
with MockVimBuffers( [ current_buffer ], [ current_buffer ] ):
with patch( 'ycm.youcompleteme.SendCommandRequest' ) as send_request:
ycm.SendCommandRequest( [ 'GoTo' ], 'python', True, 1, 2 )
send_request.assert_called_once_with(
......
......@@ -66,7 +66,7 @@ def SendCompletionRequest_UnicodeWorkingDirectory_test( ycm ):
return { 'completions': [], 'completion_start_column': 1 }
with CurrentWorkingDirectory( unicode_dir ):
with MockVimBuffers( [ current_buffer ], current_buffer ):
with MockVimBuffers( [ current_buffer ], [ current_buffer ] ):
with MockCompletionRequest( ServerResponse ):
ycm.SendCompletionRequest()
ok_( ycm.CompletionRequestReady() )
......@@ -106,7 +106,7 @@ def SendCompletionRequest_ResponseContainingError_test( ycm, post_vim_message ):
} ]
}
with MockVimBuffers( [ current_buffer ], current_buffer ):
with MockVimBuffers( [ current_buffer ], [ current_buffer ] ):
with MockCompletionRequest( ServerResponse ):
ycm.SendCompletionRequest()
ok_( ycm.CompletionRequestReady() )
......@@ -138,7 +138,7 @@ def SendCompletionRequest_ErrorFromServer_test( ycm,
post_vim_message,
logger ):
current_buffer = VimBuffer( 'buffer' )
with MockVimBuffers( [ current_buffer ], current_buffer ):
with MockVimBuffers( [ current_buffer ], [ current_buffer ] ):
with MockCompletionRequest( ServerError( 'Server error' ) ):
ycm.SendCompletionRequest()
ok_( ycm.CompletionRequestReady() )
......
......@@ -61,7 +61,7 @@ def RegexFilter_test():
def RegexSingleList_test():
opts = _JavaFilter( { 'regex' : [ 'taco' ] } )
opts = _JavaFilter( { 'regex' : [ 'taco' ] } )
f = _CreateFilterForTypes( opts, [ 'java' ] )
_assert_rejects( f, 'This is a Taco' )
......
......@@ -57,10 +57,9 @@ def MockArbitraryBuffer( filetype ):
# Arbitrary, but valid, single buffer open.
current_buffer = VimBuffer( os.path.realpath( 'TEST_BUFFER' ),
window = 1,
filetype = filetype )
with MockVimBuffers( [ current_buffer ], current_buffer ):
with MockVimBuffers( [ current_buffer ], [ current_buffer ] ):
yield
......@@ -351,7 +350,7 @@ def _Check_FileReadyToParse_Diagnostic_Warning( ycm ):
assert_that(
test_utils.VIM_SIGNS,
contains(
VimSign( SIGN_BUFFER_ID_INITIAL_VALUE + 1, 2, 'YcmWarning', 1 )
VimSign( SIGN_BUFFER_ID_INITIAL_VALUE + 2, 2, 'YcmWarning', 1 )
)
)
eq_( ycm.GetErrorCount(), 0 )
......@@ -363,7 +362,7 @@ def _Check_FileReadyToParse_Diagnostic_Warning( ycm ):
assert_that(
test_utils.VIM_SIGNS,
contains(
VimSign( SIGN_BUFFER_ID_INITIAL_VALUE + 1, 2, 'YcmWarning', 1 )
VimSign( SIGN_BUFFER_ID_INITIAL_VALUE + 2, 2, 'YcmWarning', 1 )
)
)
eq_( ycm.GetErrorCount(), 0 )
......@@ -390,7 +389,7 @@ def _Check_FileReadyToParse_Diagnostic_Clean( ycm ):
@patch( 'ycm.youcompleteme.YouCompleteMe._AddUltiSnipsDataIfNeeded' )
@YouCompleteMeInstance( { 'collect_identifiers_from_tags_files': 1 } )
@YouCompleteMeInstance( { 'g:ycm_collect_identifiers_from_tags_files': 1 } )
def EventNotification_FileReadyToParse_TagFiles_UnicodeWorkingDirectory_test(
ycm, *args ):
unicode_dir = PathToTestFile( 'uni¢𐍈d€' )
......@@ -402,7 +401,7 @@ def EventNotification_FileReadyToParse_TagFiles_UnicodeWorkingDirectory_test(
with patch( 'ycm.client.event_notification.EventNotification.'
'PostDataToHandlerAsync' ) as post_data_to_handler_async:
with CurrentWorkingDirectory( unicode_dir ):
with MockVimBuffers( [ current_buffer ], current_buffer, ( 1, 5 ) ):
with MockVimBuffers( [ current_buffer ], [ current_buffer ], ( 1, 5 ) ):
ycm.OnFileReadyToParse()
assert_that(
......@@ -455,7 +454,7 @@ def EventNotification_BufferVisit_BuildRequestForCurrentAndUnsavedBuffers_test(
with patch( 'ycm.client.event_notification.EventNotification.'
'PostDataToHandlerAsync' ) as post_data_to_handler_async:
with MockVimBuffers( [ current_buffer, modified_buffer, unmodified_buffer ],
current_buffer,
[ current_buffer ],
( 1, 5 ) ):
ycm.OnBufferVisit()
......@@ -503,7 +502,8 @@ def EventNotification_BufferUnload_BuildRequestForDeletedAndUnsavedBuffers_test(
with patch( 'ycm.client.event_notification.EventNotification.'
'PostDataToHandlerAsync' ) as post_data_to_handler_async:
with MockVimBuffers( [ current_buffer, deleted_buffer ], current_buffer ):
with MockVimBuffers( [ current_buffer, deleted_buffer ],
[ current_buffer ] ):
ycm.OnBufferUnload( deleted_buffer.number )
assert_that(
......@@ -534,7 +534,7 @@ def EventNotification_BufferUnload_BuildRequestForDeletedAndUnsavedBuffers_test(
@patch( 'ycm.vimsupport.CaptureVimCommand', return_value = """
fooGroup xxx foo bar
links to Statement""" )
@YouCompleteMeInstance( { 'seed_identifiers_with_syntax': 1 } )
@YouCompleteMeInstance( { 'g:ycm_seed_identifiers_with_syntax': 1 } )
def EventNotification_FileReadyToParse_SyntaxKeywords_SeedWithCache_test(
ycm, *args ):
......@@ -543,7 +543,7 @@ def EventNotification_FileReadyToParse_SyntaxKeywords_SeedWithCache_test(
with patch( 'ycm.client.event_notification.EventNotification.'
'PostDataToHandlerAsync' ) as post_data_to_handler_async:
with MockVimBuffers( [ current_buffer ], current_buffer ):
with MockVimBuffers( [ current_buffer ], [ current_buffer ] ):
ycm.OnFileReadyToParse()
assert_that(
# Positional arguments passed to PostDataToHandlerAsync.
......@@ -569,7 +569,7 @@ def EventNotification_FileReadyToParse_SyntaxKeywords_SeedWithCache_test(
@patch( 'ycm.vimsupport.CaptureVimCommand', return_value = """
fooGroup xxx foo bar
links to Statement""" )
@YouCompleteMeInstance( { 'seed_identifiers_with_syntax': 1 } )
@YouCompleteMeInstance( { 'g:ycm_seed_identifiers_with_syntax': 1 } )
def EventNotification_FileReadyToParse_SyntaxKeywords_ClearCacheIfRestart_test(
ycm, *args ):
......@@ -578,7 +578,7 @@ def EventNotification_FileReadyToParse_SyntaxKeywords_ClearCacheIfRestart_test(
with patch( 'ycm.client.event_notification.EventNotification.'
'PostDataToHandlerAsync' ) as post_data_to_handler_async: