Fixing python tests broken in rename
This commit is contained in:
parent
087cadcfaf
commit
381b86d595
@ -42,16 +42,17 @@ function! youcompleteme#Enable()
|
||||
exe 'python sys.path.insert( 0, "' . s:script_folder_path . '/../python" )'
|
||||
py from ycm import extra_conf_store
|
||||
py extra_conf_store.CallExtraConfYcmCorePreloadIfExists()
|
||||
py import ycm
|
||||
py from ycm import base
|
||||
|
||||
if !pyeval( 'ycm.CompatibleWithYcmCore()')
|
||||
if !pyeval( 'base.CompatibleWithYcmCore()')
|
||||
echohl WarningMsg |
|
||||
\ echomsg "YouCompleteMe unavailable: ycm_core too old, PLEASE RECOMPILE ycm_core" |
|
||||
\ echohl None
|
||||
return
|
||||
endif
|
||||
|
||||
py ycm_state = ycm.YouCompleteMe()
|
||||
py from ycm.youcompleteme import YouCompleteMe
|
||||
py ycm_state = YouCompleteMe()
|
||||
|
||||
augroup youcompleteme
|
||||
autocmd!
|
||||
@ -386,7 +387,7 @@ endfunction
|
||||
|
||||
|
||||
function! s:IdentifierFinishedOperations()
|
||||
if !pyeval( 'ycm.CurrentIdentifierFinished()' )
|
||||
if !pyeval( 'base.CurrentIdentifierFinished()' )
|
||||
return
|
||||
endif
|
||||
py ycm_state.OnCurrentIdentifierFinished()
|
||||
@ -511,7 +512,7 @@ function! youcompleteme#Complete( findstart, base )
|
||||
|
||||
|
||||
" TODO: make this a function-local variable instead of a script-local one
|
||||
let s:completion_start_column = pyeval( 'ycm.CompletionStartColumn()' )
|
||||
let s:completion_start_column = pyeval( 'base.CompletionStartColumn()' )
|
||||
let s:should_use_filetype_completion =
|
||||
\ pyeval( 'ycm_state.ShouldUseFiletypeCompleter(' .
|
||||
\ s:completion_start_column . ')' )
|
||||
@ -534,7 +535,7 @@ endfunction
|
||||
function! youcompleteme#OmniComplete( findstart, base )
|
||||
if a:findstart
|
||||
let s:omnifunc_mode = 1
|
||||
let s:completion_start_column = pyeval( 'ycm.CompletionStartColumn()' )
|
||||
let s:completion_start_column = pyeval( 'base.CompletionStartColumn()' )
|
||||
return s:completion_start_column
|
||||
else
|
||||
return s:CompletionsForQuery( a:base, 1, s:completion_start_column )
|
||||
|
@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (C) 2011, 2012 Strahinja Val Markovic <val@markovic.io>
|
||||
#
|
||||
# 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 youcompleteme import (
|
||||
YouCompleteMe, CompatibleWithYcmCore, CurrentIdentifierFinished,
|
||||
CompletionStartColumn )
|
||||
|
||||
# We don't really need to do this, but if we don't, pyflakes complains that we
|
||||
# have unused imports. Pyflakes should ignore unused imports in __init__.py
|
||||
# files, but doesn't. See this bug report:
|
||||
# https://bugs.launchpad.net/pyflakes/+bug/1178905
|
||||
__all__ = [
|
||||
YouCompleteMe.__name__,
|
||||
CompatibleWithYcmCore.__name__,
|
||||
CurrentIdentifierFinished.__name__,
|
||||
CompletionStartColumn.__name__
|
||||
]
|
83
python/ycm/base.py
Normal file
83
python/ycm/base.py
Normal file
@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (C) 2011, 2012 Strahinja Val Markovic <val@markovic.io>
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
import os
|
||||
import vim
|
||||
from ycm import vimsupport
|
||||
from ycm import utils
|
||||
|
||||
try:
|
||||
import ycm_core
|
||||
except ImportError as e:
|
||||
vimsupport.PostVimMessage(
|
||||
'Error importing ycm_core. Are you sure you have placed a version 3.2+ '
|
||||
'libclang.[so|dll|dylib] in folder "{0}"? See the Installation Guide in '
|
||||
'the docs. Full error: {1}'.format(
|
||||
os.path.dirname( os.path.abspath( __file__ ) ), str( e ) ) )
|
||||
|
||||
|
||||
def CompletionStartColumn():
|
||||
"""Returns the 0-based index where the completion string should start. So if
|
||||
the user enters:
|
||||
foo.bar^
|
||||
with the cursor being at the location of the caret, then the starting column
|
||||
would be the index of the letter 'b'.
|
||||
"""
|
||||
|
||||
line = vim.current.line
|
||||
start_column = vimsupport.CurrentColumn()
|
||||
|
||||
while start_column > 0 and utils.IsIdentifierChar( line[ start_column - 1 ] ):
|
||||
start_column -= 1
|
||||
return start_column
|
||||
|
||||
|
||||
def CurrentIdentifierFinished():
|
||||
current_column = vimsupport.CurrentColumn()
|
||||
previous_char_index = current_column - 1
|
||||
if previous_char_index < 0:
|
||||
return True
|
||||
line = vim.current.line
|
||||
try:
|
||||
previous_char = line[ previous_char_index ]
|
||||
except IndexError:
|
||||
return False
|
||||
|
||||
if utils.IsIdentifierChar( previous_char ):
|
||||
return False
|
||||
|
||||
if ( not utils.IsIdentifierChar( previous_char ) and
|
||||
previous_char_index > 0 and
|
||||
utils.IsIdentifierChar( line[ previous_char_index - 1 ] ) ):
|
||||
return True
|
||||
else:
|
||||
return line[ : current_column ].isspace()
|
||||
|
||||
|
||||
COMPATIBLE_WITH_CORE_VERSION = 3
|
||||
|
||||
def CompatibleWithYcmCore():
|
||||
try:
|
||||
current_core_version = ycm_core.YcmCoreVersion()
|
||||
except AttributeError:
|
||||
return False
|
||||
|
||||
return current_core_version == COMPATIBLE_WITH_CORE_VERSION
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from nose.tools import eq_
|
||||
from ycm_test_utils import MockVimModule
|
||||
from ycm.test_utils import MockVimModule
|
||||
vim_mock = MockVimModule()
|
||||
from .. import flags
|
||||
|
||||
|
@ -20,22 +20,12 @@
|
||||
import imp
|
||||
import os
|
||||
import vim
|
||||
from ycm import vimsupport
|
||||
from ycm import utils
|
||||
|
||||
try:
|
||||
import ycm_core
|
||||
except ImportError as e:
|
||||
vimsupport.PostVimMessage(
|
||||
'Error importing ycm_core. Are you sure you have placed a version 3.2+ '
|
||||
'libclang.[so|dll|dylib] in folder "{0}"? See the Installation Guide in '
|
||||
'the docs. Full error: {1}'.format(
|
||||
os.path.dirname( os.path.abspath( __file__ ) ), str( e ) ) )
|
||||
|
||||
|
||||
from ycm import vimsupport
|
||||
from ycm.completers.all.omni_completer import OmniCompleter
|
||||
from ycm.completers.general.general_completer_store import GeneralCompleterStore
|
||||
|
||||
|
||||
FILETYPE_SPECIFIC_COMPLETION_TO_DISABLE = vim.eval(
|
||||
'g:ycm_filetype_specific_completion_to_disable' )
|
||||
|
||||
@ -220,51 +210,3 @@ def _PathToFiletypeCompleterPluginLoader( filetype ):
|
||||
return os.path.join( _PathToCompletersFolder(), filetype, 'hook.py' )
|
||||
|
||||
|
||||
def CompletionStartColumn():
|
||||
"""Returns the 0-based index where the completion string should start. So if
|
||||
the user enters:
|
||||
foo.bar^
|
||||
with the cursor being at the location of the caret, then the starting column
|
||||
would be the index of the letter 'b'.
|
||||
"""
|
||||
|
||||
line = vim.current.line
|
||||
start_column = vimsupport.CurrentColumn()
|
||||
|
||||
while start_column > 0 and utils.IsIdentifierChar( line[ start_column - 1 ] ):
|
||||
start_column -= 1
|
||||
return start_column
|
||||
|
||||
|
||||
def CurrentIdentifierFinished():
|
||||
current_column = vimsupport.CurrentColumn()
|
||||
previous_char_index = current_column - 1
|
||||
if previous_char_index < 0:
|
||||
return True
|
||||
line = vim.current.line
|
||||
try:
|
||||
previous_char = line[ previous_char_index ]
|
||||
except IndexError:
|
||||
return False
|
||||
|
||||
if utils.IsIdentifierChar( previous_char ):
|
||||
return False
|
||||
|
||||
if ( not utils.IsIdentifierChar( previous_char ) and
|
||||
previous_char_index > 0 and
|
||||
utils.IsIdentifierChar( line[ previous_char_index - 1 ] ) ):
|
||||
return True
|
||||
else:
|
||||
return line[ : current_column ].isspace()
|
||||
|
||||
|
||||
COMPATIBLE_WITH_CORE_VERSION = 3
|
||||
|
||||
def CompatibleWithYcmCore():
|
||||
try:
|
||||
current_core_version = ycm_core.YcmCoreVersion()
|
||||
except AttributeError:
|
||||
return False
|
||||
|
||||
return current_core_version == COMPATIBLE_WITH_CORE_VERSION
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user