Futurize pass + manual fixes
This commit is contained in:
parent
cb8607796e
commit
4e82409cc1
@ -15,6 +15,15 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
|
from future.utils import iteritems
|
||||||
from ycm import vimsupport
|
from ycm import vimsupport
|
||||||
from ycmd import user_options_store
|
from ycmd import user_options_store
|
||||||
from ycmd import request_wrap
|
from ycmd import request_wrap
|
||||||
@ -29,7 +38,7 @@ def BuildServerConf():
|
|||||||
|
|
||||||
vim_globals = vimsupport.GetReadOnlyVimGlobals( force_python_objects = True )
|
vim_globals = vimsupport.GetReadOnlyVimGlobals( force_python_objects = True )
|
||||||
server_conf = {}
|
server_conf = {}
|
||||||
for key, value in vim_globals.items():
|
for key, value in iteritems( vim_globals ):
|
||||||
if not key.startswith( YCM_VAR_PREFIX ):
|
if not key.startswith( YCM_VAR_PREFIX ):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
@ -45,7 +54,7 @@ def BuildServerConf():
|
|||||||
def LoadJsonDefaultsIntoVim():
|
def LoadJsonDefaultsIntoVim():
|
||||||
defaults = user_options_store.DefaultOptions()
|
defaults = user_options_store.DefaultOptions()
|
||||||
vim_defaults = {}
|
vim_defaults = {}
|
||||||
for key, value in defaults.iteritems():
|
for key, value in iteritems( defaults ):
|
||||||
vim_defaults[ 'ycm_' + key ] = value
|
vim_defaults[ 'ycm_' + key ] = value
|
||||||
|
|
||||||
vimsupport.LoadDictIntoVimGlobals( vim_defaults, overwrite = False )
|
vimsupport.LoadDictIntoVimGlobals( vim_defaults, overwrite = False )
|
||||||
@ -115,7 +124,7 @@ def AdjustCandidateInsertionText( candidates ):
|
|||||||
|
|
||||||
new_candidates = []
|
new_candidates = []
|
||||||
for candidate in candidates:
|
for candidate in candidates:
|
||||||
if type( candidate ) is dict:
|
if isinstance( candidate, dict ):
|
||||||
new_candidate = candidate.copy()
|
new_candidate = candidate.copy()
|
||||||
|
|
||||||
if not 'abbr' in new_candidate:
|
if not 'abbr' in new_candidate:
|
||||||
@ -127,7 +136,7 @@ def AdjustCandidateInsertionText( candidates ):
|
|||||||
|
|
||||||
new_candidates.append( new_candidate )
|
new_candidates.append( new_candidate )
|
||||||
|
|
||||||
elif type( candidate ) is str:
|
elif isinstance( candidate, str ) or isinstance( candidate, bytes ):
|
||||||
new_candidates.append(
|
new_candidates.append(
|
||||||
{ 'abbr': candidate,
|
{ 'abbr': candidate,
|
||||||
'word': NewCandidateInsertionText( candidate, text_after_cursor ) } )
|
'word': NewCandidateInsertionText( candidate, text_after_cursor ) } )
|
||||||
|
@ -15,8 +15,16 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import urlparse
|
import urllib.parse
|
||||||
import json
|
import json
|
||||||
from base64 import b64decode, b64encode
|
from base64 import b64decode, b64encode
|
||||||
from retries import retries
|
from retries import retries
|
||||||
@ -133,7 +141,7 @@ class BaseRequest( object ):
|
|||||||
headers = dict( _HEADERS )
|
headers = dict( _HEADERS )
|
||||||
headers[ _HMAC_HEADER ] = b64encode(
|
headers[ _HMAC_HEADER ] = b64encode(
|
||||||
CreateRequestHmac( method,
|
CreateRequestHmac( method,
|
||||||
urlparse.urlparse( request_uri ).path,
|
urllib.parse.urlparse( request_uri ).path,
|
||||||
request_body,
|
request_body,
|
||||||
BaseRequest.hmac_secret ) )
|
BaseRequest.hmac_secret ) )
|
||||||
return headers
|
return headers
|
||||||
@ -196,7 +204,7 @@ def _ValidateResponseObject( response ):
|
|||||||
|
|
||||||
|
|
||||||
def _BuildUri( handler ):
|
def _BuildUri( handler ):
|
||||||
return urlparse.urljoin( BaseRequest.server_location, handler )
|
return urllib.parse.urljoin( BaseRequest.server_location, handler )
|
||||||
|
|
||||||
|
|
||||||
SERVER_HEALTHY = False
|
SERVER_HEALTHY = False
|
||||||
|
@ -15,6 +15,14 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
import vim
|
import vim
|
||||||
from ycm.client.base_request import BaseRequest, BuildRequestData, ServerError
|
from ycm.client.base_request import BaseRequest, BuildRequestData, ServerError
|
||||||
from ycm import vimsupport
|
from ycm import vimsupport
|
||||||
|
@ -15,6 +15,14 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
from ycm.client.base_request import ( BaseRequest, BuildRequestData,
|
from ycm.client.base_request import ( BaseRequest, BuildRequestData,
|
||||||
HandleServerException )
|
HandleServerException )
|
||||||
|
|
||||||
|
@ -15,7 +15,15 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from ycmd.utils import ToBytes, ToUnicode
|
from __future__ import unicode_literals
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
|
from ycmd.utils import ToUnicode
|
||||||
from ycm.client.base_request import ( BaseRequest, JsonFromFuture,
|
from ycm.client.base_request import ( BaseRequest, JsonFromFuture,
|
||||||
HandleServerException,
|
HandleServerException,
|
||||||
MakeServerException )
|
MakeServerException )
|
||||||
@ -69,22 +77,22 @@ def ConvertCompletionDataToVimData( completion_data ):
|
|||||||
|
|
||||||
if ( 'extra_data' in completion_data and
|
if ( 'extra_data' in completion_data and
|
||||||
'doc_string' in completion_data[ 'extra_data' ] ):
|
'doc_string' in completion_data[ 'extra_data' ] ):
|
||||||
doc_string = ToBytes( completion_data[ 'extra_data' ][ 'doc_string' ] )
|
doc_string = completion_data[ 'extra_data' ][ 'doc_string' ]
|
||||||
else:
|
else:
|
||||||
doc_string = ""
|
doc_string = ""
|
||||||
|
|
||||||
if 'insertion_text' in completion_data:
|
if 'insertion_text' in completion_data:
|
||||||
vim_data[ 'word' ] = ToBytes( completion_data[ 'insertion_text' ] )
|
vim_data[ 'word' ] = completion_data[ 'insertion_text' ]
|
||||||
if 'menu_text' in completion_data:
|
if 'menu_text' in completion_data:
|
||||||
vim_data[ 'abbr' ] = ToBytes( completion_data[ 'menu_text' ] )
|
vim_data[ 'abbr' ] = completion_data[ 'menu_text' ]
|
||||||
if 'extra_menu_info' in completion_data:
|
if 'extra_menu_info' in completion_data:
|
||||||
vim_data[ 'menu' ] = ToBytes( completion_data[ 'extra_menu_info' ] )
|
vim_data[ 'menu' ] = completion_data[ 'extra_menu_info' ]
|
||||||
if 'kind' in completion_data:
|
if 'kind' in completion_data:
|
||||||
kind = ToUnicode( completion_data[ 'kind' ] )
|
kind = ToUnicode( completion_data[ 'kind' ] )
|
||||||
if kind:
|
if kind:
|
||||||
vim_data[ 'kind' ] = ToBytes( kind[ 0 ].lower() )
|
vim_data[ 'kind' ] = kind[ 0 ].lower()
|
||||||
if 'detailed_info' in completion_data:
|
if 'detailed_info' in completion_data:
|
||||||
vim_data[ 'info' ] = ToBytes( completion_data[ 'detailed_info' ] )
|
vim_data[ 'info' ] = completion_data[ 'detailed_info' ]
|
||||||
if doc_string:
|
if doc_string:
|
||||||
vim_data[ 'info' ] += '\n' + doc_string
|
vim_data[ 'info' ] += '\n' + doc_string
|
||||||
elif doc_string:
|
elif doc_string:
|
||||||
|
@ -15,6 +15,14 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
from ycm import vimsupport
|
from ycm import vimsupport
|
||||||
from ycmd.responses import UnknownExtraConf
|
from ycmd.responses import UnknownExtraConf
|
||||||
from ycm.client.base_request import ( BaseRequest, BuildRequestData,
|
from ycm.client.base_request import ( BaseRequest, BuildRequestData,
|
||||||
|
@ -15,7 +15,14 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from ycmd.utils import ToBytes
|
from __future__ import unicode_literals
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
from ycm.client.completion_request import CompletionRequest
|
from ycm.client.completion_request import CompletionRequest
|
||||||
|
|
||||||
|
|
||||||
@ -46,15 +53,15 @@ def ConvertVimDataToCompletionData( vim_data ):
|
|||||||
completion_data = {}
|
completion_data = {}
|
||||||
|
|
||||||
if 'word' in vim_data:
|
if 'word' in vim_data:
|
||||||
completion_data[ 'insertion_text' ] = ToBytes( vim_data[ 'word' ] )
|
completion_data[ 'insertion_text' ] = vim_data[ 'word' ]
|
||||||
if 'abbr' in vim_data:
|
if 'abbr' in vim_data:
|
||||||
completion_data[ 'menu_text' ] = ToBytes( vim_data[ 'abbr' ] )
|
completion_data[ 'menu_text' ] = vim_data[ 'abbr' ]
|
||||||
if 'menu' in vim_data:
|
if 'menu' in vim_data:
|
||||||
completion_data[ 'extra_menu_info' ] = ToBytes( vim_data[ 'menu' ] )
|
completion_data[ 'extra_menu_info' ] = vim_data[ 'menu' ]
|
||||||
if 'kind' in vim_data:
|
if 'kind' in vim_data:
|
||||||
completion_data[ 'kind' ] = [ ToBytes( vim_data[ 'kind' ] ) ]
|
completion_data[ 'kind' ] = [ vim_data[ 'kind' ] ]
|
||||||
if 'info' in vim_data:
|
if 'info' in vim_data:
|
||||||
completion_data[ 'detailed_info' ] = ToBytes( vim_data[ 'info' ] )
|
completion_data[ 'detailed_info' ] = vim_data[ 'info' ]
|
||||||
|
|
||||||
return completion_data
|
return completion_data
|
||||||
|
|
||||||
|
@ -15,6 +15,14 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
from ycm.test_utils import MockVimModule
|
from ycm.test_utils import MockVimModule
|
||||||
MockVimModule()
|
MockVimModule()
|
||||||
|
|
||||||
@ -24,7 +32,7 @@ from nose.tools import ok_
|
|||||||
from ycm.client.command_request import CommandRequest
|
from ycm.client.command_request import CommandRequest
|
||||||
|
|
||||||
|
|
||||||
class GoToResponse_QuickFix_test:
|
class GoToResponse_QuickFix_test( object ):
|
||||||
"""This class tests the generation of QuickFix lists for GoTo responses which
|
"""This class tests the generation of QuickFix lists for GoTo responses which
|
||||||
return multiple locations, such as the Python completer and JavaScript
|
return multiple locations, such as the Python completer and JavaScript
|
||||||
completer. It mostly proves that we use 1-based indexing for the column
|
completer. It mostly proves that we use 1-based indexing for the column
|
||||||
@ -92,7 +100,7 @@ class GoToResponse_QuickFix_test:
|
|||||||
] )
|
] )
|
||||||
|
|
||||||
|
|
||||||
class Response_Detection_test:
|
class Response_Detection_test( object ):
|
||||||
|
|
||||||
def BasicResponse_test( self ):
|
def BasicResponse_test( self ):
|
||||||
def _BasicResponseTest( command, response ):
|
def _BasicResponseTest( command, response ):
|
||||||
|
@ -15,13 +15,21 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
from nose.tools import eq_
|
from nose.tools import eq_
|
||||||
from ycm.test_utils import MockVimModule
|
from ycm.test_utils import MockVimModule
|
||||||
vim_mock = MockVimModule()
|
vim_mock = MockVimModule()
|
||||||
|
|
||||||
from .. import completion_request
|
from .. import completion_request
|
||||||
|
|
||||||
class ConvertCompletionResponseToVimDatas_test:
|
class ConvertCompletionResponseToVimDatas_test( object ):
|
||||||
""" This class tests the
|
""" This class tests the
|
||||||
completion_request._ConvertCompletionResponseToVimDatas method """
|
completion_request._ConvertCompletionResponseToVimDatas method """
|
||||||
|
|
||||||
@ -32,10 +40,10 @@ class ConvertCompletionResponseToVimDatas_test:
|
|||||||
try:
|
try:
|
||||||
eq_( expected_vim_data, vim_data )
|
eq_( expected_vim_data, vim_data )
|
||||||
except:
|
except:
|
||||||
print "Expected:\n'{0}'\nwhen parsing:\n'{1}'\nBut found:\n'{2}'".format(
|
print( "Expected:\n'{0}'\nwhen parsing:\n'{1}'\nBut found:\n'{2}'".format(
|
||||||
expected_vim_data,
|
expected_vim_data,
|
||||||
completion_data,
|
completion_data,
|
||||||
vim_data )
|
vim_data ) )
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,6 +15,14 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from ycm.client.base_request import BaseRequest
|
from ycm.client.base_request import BaseRequest
|
||||||
|
@ -15,6 +15,15 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
|
from future.utils import itervalues, iteritems
|
||||||
from collections import defaultdict, namedtuple
|
from collections import defaultdict, namedtuple
|
||||||
from ycm import vimsupport
|
from ycm import vimsupport
|
||||||
import vim
|
import vim
|
||||||
@ -95,8 +104,8 @@ class DiagnosticInterface( object ):
|
|||||||
line_to_diags = self._buffer_number_to_line_to_diags[
|
line_to_diags = self._buffer_number_to_line_to_diags[
|
||||||
vim.current.buffer.number ]
|
vim.current.buffer.number ]
|
||||||
|
|
||||||
for diags in line_to_diags.itervalues():
|
for diags in itervalues( line_to_diags ):
|
||||||
matched_diags.extend( filter( predicate, diags ) )
|
matched_diags.extend( list( filter( predicate, diags ) ) )
|
||||||
return matched_diags
|
return matched_diags
|
||||||
|
|
||||||
|
|
||||||
@ -104,7 +113,7 @@ def _UpdateSquiggles( buffer_number_to_line_to_diags ):
|
|||||||
vimsupport.ClearYcmSyntaxMatches()
|
vimsupport.ClearYcmSyntaxMatches()
|
||||||
line_to_diags = buffer_number_to_line_to_diags[ vim.current.buffer.number ]
|
line_to_diags = buffer_number_to_line_to_diags[ vim.current.buffer.number ]
|
||||||
|
|
||||||
for diags in line_to_diags.itervalues():
|
for diags in itervalues( line_to_diags ):
|
||||||
for diag in diags:
|
for diag in diags:
|
||||||
location_extent = diag[ 'location_extent' ]
|
location_extent = diag[ 'location_extent' ]
|
||||||
is_error = _DiagnosticIsError( diag )
|
is_error = _DiagnosticIsError( diag )
|
||||||
@ -168,11 +177,11 @@ def _GetKeptAndNewSigns( placed_signs, buffer_number_to_line_to_diags,
|
|||||||
next_sign_id ):
|
next_sign_id ):
|
||||||
new_signs = []
|
new_signs = []
|
||||||
kept_signs = []
|
kept_signs = []
|
||||||
for buffer_number, line_to_diags in buffer_number_to_line_to_diags.iteritems():
|
for buffer_number, line_to_diags in iteritems( buffer_number_to_line_to_diags ):
|
||||||
if not vimsupport.BufferIsVisible( buffer_number ):
|
if not vimsupport.BufferIsVisible( buffer_number ):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for line, diags in line_to_diags.iteritems():
|
for line, diags in iteritems( line_to_diags ):
|
||||||
for diag in diags:
|
for diag in diags:
|
||||||
sign = _DiagSignPlacement( next_sign_id,
|
sign = _DiagSignPlacement( next_sign_id,
|
||||||
line,
|
line,
|
||||||
@ -217,8 +226,8 @@ def _ConvertDiagListToDict( diag_list ):
|
|||||||
line_number = location[ 'line_num' ]
|
line_number = location[ 'line_num' ]
|
||||||
buffer_to_line_to_diags[ buffer_number ][ line_number ].append( diag )
|
buffer_to_line_to_diags[ buffer_number ][ line_number ].append( diag )
|
||||||
|
|
||||||
for line_to_diags in buffer_to_line_to_diags.itervalues():
|
for line_to_diags in itervalues( buffer_to_line_to_diags ):
|
||||||
for diags in line_to_diags.itervalues():
|
for diags in itervalues( line_to_diags ):
|
||||||
# We also want errors to be listed before warnings so that errors aren't
|
# We also want errors to be listed before warnings so that errors aren't
|
||||||
# hidden by the warnings; Vim won't place a sign oven an existing one.
|
# hidden by the warnings; Vim won't place a sign oven an existing one.
|
||||||
diags.sort( key = lambda diag: ( diag[ 'location' ][ 'column_num' ],
|
diags.sort( key = lambda diag: ( diag[ 'location' ][ 'column_num' ],
|
||||||
|
@ -15,6 +15,14 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
import vim
|
import vim
|
||||||
from ycm import vimsupport
|
from ycm import vimsupport
|
||||||
from ycmd.completers.completer import Completer
|
from ycmd.completers.completer import Completer
|
||||||
@ -84,7 +92,7 @@ class OmniCompleter( Completer ):
|
|||||||
if not hasattr( items, '__iter__' ):
|
if not hasattr( items, '__iter__' ):
|
||||||
raise TypeError( OMNIFUNC_NOT_LIST )
|
raise TypeError( OMNIFUNC_NOT_LIST )
|
||||||
|
|
||||||
return filter( bool, items )
|
return list( filter( bool, items ) )
|
||||||
except ( TypeError, ValueError, vim.error ) as error:
|
except ( TypeError, ValueError, vim.error ) as error:
|
||||||
vimsupport.PostVimMessage(
|
vimsupport.PostVimMessage(
|
||||||
OMNIFUNC_RETURNED_BAD_VALUE + ' ' + str( error ) )
|
OMNIFUNC_RETURNED_BAD_VALUE + ' ' + str( error ) )
|
||||||
|
@ -15,6 +15,14 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import vim
|
import vim
|
||||||
|
@ -15,6 +15,15 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
|
from future.utils import itervalues
|
||||||
import re
|
import re
|
||||||
import vim
|
import vim
|
||||||
from ycm import vimsupport
|
from ycm import vimsupport
|
||||||
@ -174,7 +183,7 @@ def _ConnectGroupChildren( group_name_to_group ):
|
|||||||
parent_names.append( line[ len( links_to ): ] )
|
parent_names.append( line[ len( links_to ): ] )
|
||||||
return parent_names
|
return parent_names
|
||||||
|
|
||||||
for group in group_name_to_group.itervalues():
|
for group in itervalues( group_name_to_group ):
|
||||||
parent_names = GetParentNames( group )
|
parent_names = GetParentNames( group )
|
||||||
|
|
||||||
for parent_name in parent_names:
|
for parent_name in parent_names:
|
||||||
|
@ -15,6 +15,14 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
from mock import MagicMock
|
from mock import MagicMock
|
||||||
from hamcrest import assert_that, equal_to
|
from hamcrest import assert_that, equal_to
|
||||||
import re
|
import re
|
||||||
|
@ -17,6 +17,14 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
from nose.tools import eq_, ok_
|
from nose.tools import eq_, ok_
|
||||||
from mock import patch
|
from mock import patch
|
||||||
|
@ -15,6 +15,14 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
from ycm.test_utils import MockVimModule, ExtendedMock
|
from ycm.test_utils import MockVimModule, ExtendedMock
|
||||||
MockVimModule()
|
MockVimModule()
|
||||||
|
|
||||||
|
@ -15,6 +15,13 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
from mock import MagicMock
|
from mock import MagicMock
|
||||||
from nose.tools import eq_
|
from nose.tools import eq_
|
||||||
|
@ -15,6 +15,14 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
from ycm.test_utils import MockVimModule
|
from ycm.test_utils import MockVimModule
|
||||||
MockVimModule()
|
MockVimModule()
|
||||||
|
|
||||||
|
@ -15,6 +15,14 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
from ycm.test_utils import MockVimModule
|
from ycm.test_utils import MockVimModule
|
||||||
MockVimModule()
|
MockVimModule()
|
||||||
|
|
||||||
|
@ -15,6 +15,14 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
from ycm.test_utils import MockVimModule
|
from ycm.test_utils import MockVimModule
|
||||||
MockVimModule()
|
MockVimModule()
|
||||||
|
|
||||||
|
@ -15,6 +15,14 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
from ycm.test_utils import ExtendedMock, MockVimModule, MockVimCommand
|
from ycm.test_utils import ExtendedMock, MockVimModule, MockVimCommand
|
||||||
MockVimModule()
|
MockVimModule()
|
||||||
|
|
||||||
@ -565,7 +573,7 @@ def ReplaceChunksInBuffer_UnsortedChunks_test():
|
|||||||
eq_( expected_buffer, result_buffer )
|
eq_( expected_buffer, result_buffer )
|
||||||
|
|
||||||
|
|
||||||
class MockBuffer( ):
|
class MockBuffer( object ):
|
||||||
"""An object that looks like a vim.buffer object, enough for ReplaceChunk to
|
"""An object that looks like a vim.buffer object, enough for ReplaceChunk to
|
||||||
generate a location list"""
|
generate a location list"""
|
||||||
|
|
||||||
@ -1167,27 +1175,13 @@ def BufferIsVisibleForFilename_test():
|
|||||||
eq_( vimsupport.BufferIsVisibleForFilename( 'another_filename' ), False )
|
eq_( vimsupport.BufferIsVisibleForFilename( 'another_filename' ), False )
|
||||||
|
|
||||||
|
|
||||||
|
@patch( 'ycm.vimsupport.GetBufferNumberForFilename',
|
||||||
|
side_effect = [ 2, 5, -1 ] )
|
||||||
@patch( 'vim.command',
|
@patch( 'vim.command',
|
||||||
side_effect = MockVimCommand,
|
side_effect = MockVimCommand,
|
||||||
new_callable=ExtendedMock )
|
new_callable = ExtendedMock )
|
||||||
def CloseBuffersForFilename_test( vim_command ):
|
def CloseBuffersForFilename_test( vim_command, *args ):
|
||||||
buffers = [
|
vimsupport.CloseBuffersForFilename( 'some_filename' )
|
||||||
{
|
|
||||||
'number': 2,
|
|
||||||
'filename': os.path.realpath( 'some_filename' ),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'number': 5,
|
|
||||||
'filename': os.path.realpath( 'some_filename' ),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'number': 1,
|
|
||||||
'filename': os.path.realpath( 'another_filename' )
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
with patch( 'vim.buffers', buffers ):
|
|
||||||
vimsupport.CloseBuffersForFilename( 'some_filename' )
|
|
||||||
|
|
||||||
vim_command.assert_has_exact_calls( [
|
vim_command.assert_has_exact_calls( [
|
||||||
call( 'silent! bwipeout! 2' ),
|
call( 'silent! bwipeout! 2' ),
|
||||||
@ -1195,8 +1189,8 @@ def CloseBuffersForFilename_test( vim_command ):
|
|||||||
], any_order = True )
|
], any_order = True )
|
||||||
|
|
||||||
|
|
||||||
@patch( 'vim.command', new_callable=ExtendedMock )
|
@patch( 'vim.command', new_callable = ExtendedMock )
|
||||||
@patch( 'vim.current', new_callable=ExtendedMock )
|
@patch( 'vim.current', new_callable = ExtendedMock )
|
||||||
def OpenFilename_test( vim_current, vim_command ):
|
def OpenFilename_test( vim_current, vim_command ):
|
||||||
# Options used to open a logfile
|
# Options used to open a logfile
|
||||||
options = {
|
options = {
|
||||||
|
@ -15,13 +15,22 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
|
from future.utils import iterkeys
|
||||||
import vim
|
import vim
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from ycmd.utils import ToBytes, ToUnicode
|
from ycmd.utils import ToUnicode
|
||||||
from ycmd import user_options_store
|
from ycmd import user_options_store
|
||||||
|
|
||||||
BUFFER_COMMAND_MAP = { 'same-buffer' : 'edit',
|
BUFFER_COMMAND_MAP = { 'same-buffer' : 'edit',
|
||||||
@ -277,7 +286,7 @@ def ConvertDiagnosticsToQfList( diagnostics ):
|
|||||||
'bufnr' : GetBufferNumberForFilename( location[ 'filepath' ] ),
|
'bufnr' : GetBufferNumberForFilename( location[ 'filepath' ] ),
|
||||||
'lnum' : line_num,
|
'lnum' : line_num,
|
||||||
'col' : location[ 'column_num' ],
|
'col' : location[ 'column_num' ],
|
||||||
'text' : ToBytes( text ),
|
'text' : text,
|
||||||
'type' : diagnostic[ 'kind' ][ 0 ],
|
'type' : diagnostic[ 'kind' ][ 0 ],
|
||||||
'valid' : 1
|
'valid' : 1
|
||||||
}
|
}
|
||||||
@ -310,7 +319,7 @@ def GetReadOnlyVimGlobals( force_python_objects = False ):
|
|||||||
|
|
||||||
def VimExpressionToPythonType( vim_expression ):
|
def VimExpressionToPythonType( vim_expression ):
|
||||||
result = vim.eval( vim_expression )
|
result = vim.eval( vim_expression )
|
||||||
if not isinstance( result, basestring ):
|
if not isinstance( result, str ):
|
||||||
return result
|
return result
|
||||||
try:
|
try:
|
||||||
return int( result )
|
return int( result )
|
||||||
@ -607,7 +616,7 @@ def ReplaceChunks( chunks ):
|
|||||||
chunks_by_file = _SortChunksByFile( chunks )
|
chunks_by_file = _SortChunksByFile( chunks )
|
||||||
|
|
||||||
# We sort the file list simply to enable repeatable testing
|
# We sort the file list simply to enable repeatable testing
|
||||||
sorted_file_list = sorted( chunks_by_file.iterkeys() )
|
sorted_file_list = sorted( iterkeys( chunks_by_file ) )
|
||||||
|
|
||||||
# Make sure the user is prepared to have her screen mutilated by the new
|
# Make sure the user is prepared to have her screen mutilated by the new
|
||||||
# buffers
|
# buffers
|
||||||
@ -885,7 +894,7 @@ def OpenFilename( filename, options = {} ):
|
|||||||
|
|
||||||
# There is no command in Vim to return to the previous tab so we need to
|
# There is no command in Vim to return to the previous tab so we need to
|
||||||
# remember the current tab if needed.
|
# remember the current tab if needed.
|
||||||
if not focus and command is 'tabedit':
|
if not focus and command == 'tabedit':
|
||||||
previous_tab = GetIntValue( 'tabpagenr()' )
|
previous_tab = GetIntValue( 'tabpagenr()' )
|
||||||
else:
|
else:
|
||||||
previous_tab = None
|
previous_tab = None
|
||||||
@ -920,7 +929,7 @@ def OpenFilename( filename, options = {} ):
|
|||||||
# focus back (if the focus option is disabled) when opening a new tab or
|
# focus back (if the focus option is disabled) when opening a new tab or
|
||||||
# window.
|
# window.
|
||||||
if not focus:
|
if not focus:
|
||||||
if command is 'tabedit':
|
if command == 'tabedit':
|
||||||
JumpToTab( previous_tab )
|
JumpToTab( previous_tab )
|
||||||
if command in [ 'split', 'vsplit' ]:
|
if command in [ 'split', 'vsplit' ]:
|
||||||
JumpToPreviousWindow()
|
JumpToPreviousWindow()
|
||||||
@ -930,9 +939,9 @@ def _SetUpLoadedBuffer( command, filename, fix, position, watch ):
|
|||||||
"""After opening a buffer, configure it according to the supplied options,
|
"""After opening a buffer, configure it according to the supplied options,
|
||||||
which are as defined by the OpenFilename method."""
|
which are as defined by the OpenFilename method."""
|
||||||
|
|
||||||
if command is 'split':
|
if command == 'split':
|
||||||
vim.current.window.options[ 'winfixheight' ] = fix
|
vim.current.window.options[ 'winfixheight' ] = fix
|
||||||
if command is 'vsplit':
|
if command == 'vsplit':
|
||||||
vim.current.window.options[ 'winfixwidth' ] = fix
|
vim.current.window.options[ 'winfixwidth' ] = fix
|
||||||
|
|
||||||
if watch:
|
if watch:
|
||||||
@ -940,6 +949,6 @@ def _SetUpLoadedBuffer( command, filename, fix, position, watch ):
|
|||||||
vim.command( "exec 'au BufEnter <buffer> :silent! checktime {0}'"
|
vim.command( "exec 'au BufEnter <buffer> :silent! checktime {0}'"
|
||||||
.format( filename ) )
|
.format( filename ) )
|
||||||
|
|
||||||
if position is 'end':
|
if position == 'end':
|
||||||
vim.command( 'silent! normal G zz' )
|
vim.command( 'silent! normal G zz' )
|
||||||
|
|
||||||
|
@ -15,6 +15,15 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
from builtins import * # noqa
|
||||||
|
|
||||||
|
from future.utils import iteritems
|
||||||
import os
|
import os
|
||||||
import vim
|
import vim
|
||||||
import tempfile
|
import tempfile
|
||||||
@ -303,7 +312,7 @@ class YouCompleteMe( object ):
|
|||||||
|
|
||||||
def GetCompleteDoneHooks( self ):
|
def GetCompleteDoneHooks( self ):
|
||||||
filetypes = vimsupport.CurrentFiletypes()
|
filetypes = vimsupport.CurrentFiletypes()
|
||||||
for key, value in self._complete_done_hooks.iteritems():
|
for key, value in iteritems( self._complete_done_hooks ):
|
||||||
if key in filetypes:
|
if key in filetypes:
|
||||||
yield value
|
yield value
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user