Updating code to work with new ycmd location

This commit is contained in:
Strahinja Val Markovic 2014-05-13 13:09:19 -07:00
parent abfba7a1aa
commit a69bbb3009
44 changed files with 112 additions and 102 deletions

View File

@ -49,12 +49,13 @@ function! youcompleteme#Enable()
py import sys py import sys
py import vim py import vim
exe 'python sys.path.insert( 0, "' . s:script_folder_path . '/../python" )' exe 'python sys.path.insert( 0, "' . s:script_folder_path . '/../python" )'
py from ycm import utils exe 'python sys.path.insert( 0, "' . s:script_folder_path .
\ '/../third_party/ycmd" )'
py from ycmd import utils
py utils.AddThirdPartyFoldersToSysPath() py utils.AddThirdPartyFoldersToSysPath()
py from ycm import base py from ycm import base
py base.LoadJsonDefaultsIntoVim() py base.LoadJsonDefaultsIntoVim()
py from ycm import vimsupport py from ycmd import user_options_store
py from ycm import user_options_store
py user_options_store.SetAll( base.BuildServerConf() ) py user_options_store.SetAll( base.BuildServerConf() )
if !pyeval( 'base.CompatibleWithYcmCore()') if !pyeval( 'base.CompatibleWithYcmCore()')

View File

@ -19,8 +19,8 @@
import vim import vim
from ycm import vimsupport from ycm import vimsupport
from ycm import utils from ycmd import utils
from ycm import user_options_store from ycmd import user_options_store
import ycm_client_support import ycm_client_support
YCM_VAR_PREFIX = 'ycm_' YCM_VAR_PREFIX = 'ycm_'

View File

@ -25,9 +25,9 @@ from retries import retries
from requests_futures.sessions import FuturesSession from requests_futures.sessions import FuturesSession
from ycm.unsafe_thread_pool_executor import UnsafeThreadPoolExecutor from ycm.unsafe_thread_pool_executor import UnsafeThreadPoolExecutor
from ycm import vimsupport from ycm import vimsupport
from ycm import utils from ycmd import utils
from ycm.utils import ToUtf8Json from ycmd.utils import ToUtf8Json
from ycm.server.responses import ServerError, UnknownExtraConf from ycmd.responses import ServerError, UnknownExtraConf
_HEADERS = {'content-type': 'application/json'} _HEADERS = {'content-type': 'application/json'}
_EXECUTOR = UnsafeThreadPoolExecutor( max_workers = 30 ) _EXECUTOR = UnsafeThreadPoolExecutor( max_workers = 30 )

View File

@ -20,7 +20,7 @@
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
from ycm.utils import ToUtf8IfNeeded from ycmd.utils import ToUtf8IfNeeded
def _EnsureBackwardsCompatibility( arguments ): def _EnsureBackwardsCompatibility( arguments ):
if arguments and arguments[ 0 ] == 'GoToDefinitionElseDeclaration': if arguments and arguments[ 0 ] == 'GoToDefinitionElseDeclaration':

View File

@ -19,7 +19,7 @@
from ycm import base from ycm import base
from ycm import vimsupport from ycm import vimsupport
from ycm.utils import ToUtf8IfNeeded from ycmd.utils import ToUtf8IfNeeded
from ycm.client.base_request import ( BaseRequest, BuildRequestData, from ycm.client.base_request import ( BaseRequest, BuildRequestData,
JsonFromFuture ) JsonFromFuture )

View File

@ -18,7 +18,7 @@
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>. # along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
from ycm import vimsupport from ycm import vimsupport
from ycm.server.responses import UnknownExtraConf from ycmd.responses import UnknownExtraConf
from ycm.client.base_request import ( BaseRequest, BuildRequestData, from ycm.client.base_request import ( BaseRequest, BuildRequestData,
JsonFromFuture ) JsonFromFuture )

View File

@ -20,7 +20,7 @@
import vim import vim
from ycm import vimsupport from ycm import vimsupport
from ycm import base from ycm import base
from ycm.completers.completer import Completer from ycmd.completers.completer import Completer
from ycm.client.base_request import BuildRequestData from ycm.client.base_request import BuildRequestData
OMNIFUNC_RETURNED_BAD_VALUE = 'Omnifunc returned bad value to YCM!' OMNIFUNC_RETURNED_BAD_VALUE = 'Omnifunc returned bad value to YCM!'

View File

@ -21,7 +21,7 @@ import os
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 ycm.completers.general import syntax_parse from ycm import syntax_parse
def ContentsOfTestFile( test_file ): def ContentsOfTestFile( test_file ):

View File

@ -20,8 +20,8 @@
import vim import vim
import os import os
import json import json
from ycm.utils import ToUtf8IfNeeded from ycmd.utils import ToUtf8IfNeeded
from ycm import user_options_store from ycmd import user_options_store
BUFFER_COMMAND_MAP = { 'same-buffer' : 'edit', BUFFER_COMMAND_MAP = { 'same-buffer' : 'edit',
'horizontal-split' : 'split', 'horizontal-split' : 'split',

View File

@ -25,11 +25,11 @@ import signal
import base64 import base64
from subprocess import PIPE from subprocess import PIPE
from ycm import vimsupport from ycm import vimsupport
from ycm import utils from ycmd import utils
from ycm.diagnostic_interface import DiagnosticInterface from ycm.diagnostic_interface import DiagnosticInterface
from ycm.completers.all.omni_completer import OmniCompleter from ycm.omni_completer import OmniCompleter
from ycm.completers.general import syntax_parse from ycm import syntax_parse
from ycm.completers.completer_utils import FiletypeCompleterExistsForFiletype from ycmd.completers.completer_utils import FiletypeCompleterExistsForFiletype
from ycm.client.ycmd_keepalive import YcmdKeepalive from ycm.client.ycmd_keepalive import YcmdKeepalive
from ycm.client.base_request import BaseRequest, BuildRequestData from ycm.client.base_request import BaseRequest, BuildRequestData
from ycm.client.command_request import SendCommandRequest from ycm.client.command_request import SendCommandRequest
@ -37,7 +37,7 @@ from ycm.client.completion_request import CompletionRequest
from ycm.client.omni_completion_request import OmniCompletionRequest from ycm.client.omni_completion_request import OmniCompletionRequest
from ycm.client.event_notification import ( SendEventNotificationAsync, from ycm.client.event_notification import ( SendEventNotificationAsync,
EventNotification ) EventNotification )
from ycm.server.responses import ServerError from ycmd.responses import ServerError
try: try:
from UltiSnips import UltiSnips_Manager from UltiSnips import UltiSnips_Manager
@ -363,7 +363,7 @@ class YouCompleteMe( object ):
def _PathToServerScript(): def _PathToServerScript():
dir_of_current_script = os.path.dirname( os.path.abspath( __file__ ) ) dir_of_current_script = os.path.dirname( os.path.abspath( __file__ ) )
return os.path.join( dir_of_current_script, 'server/ycmd.py' ) return os.path.join( dir_of_current_script, '../../third_party/ycmd/ycmd' )
def _AddUltiSnipsDataIfNeeded( extra_data ): def _AddUltiSnipsDataIfNeeded( extra_data ):

View File

@ -28,11 +28,11 @@ import waitress
import signal import signal
import os import os
import base64 import base64
from ycm import user_options_store from ycmd import user_options_store
from ycm import extra_conf_store from ycmd import extra_conf_store
from ycm import utils from ycmd import utils
from ycm.server.watchdog_plugin import WatchdogPlugin from ycmd.watchdog_plugin import WatchdogPlugin
from ycm.server.hmac_plugin import HmacPlugin from ycmd.hmac_plugin import HmacPlugin
def YcmCoreSanityCheck(): def YcmCoreSanityCheck():
if 'ycm_core' in sys.modules: if 'ycm_core' in sys.modules:
@ -126,7 +126,7 @@ def Main():
# This can't be a top-level import because it transitively imports # This can't be a top-level import because it transitively imports
# ycm_core which we want to be imported ONLY after extra conf # ycm_core which we want to be imported ONLY after extra conf
# preload has executed. # preload has executed.
from ycm.server import handlers from ycmd import handlers
handlers.UpdateUserOptions( options ) handlers.UpdateUserOptions( options )
SetUpSignalHandler(args.stdout, args.stderr, args.keep_logfiles) SetUpSignalHandler(args.stdout, args.stderr, args.keep_logfiles)
handlers.app.install( WatchdogPlugin( args.idle_suicide_seconds ) ) handlers.app.install( WatchdogPlugin( args.idle_suicide_seconds ) )

View File

@ -21,11 +21,10 @@ import os
import logging import logging
import ycm_core import ycm_core
from collections import defaultdict from collections import defaultdict
from ycm.completers.general_completer import GeneralCompleter from ycmd.completers.general_completer import GeneralCompleter
# from ycm.completers.general import syntax_parse from ycmd import utils
from ycm import utils from ycmd.utils import ToUtf8IfNeeded
from ycm.utils import ToUtf8IfNeeded from ycmd import responses
from ycm.server import responses
MAX_IDENTIFIER_COMPLETIONS_RETURNED = 10 MAX_IDENTIFIER_COMPLETIONS_RETURNED = 10
SYNTAX_FILENAME = 'YCM_PLACEHOLDER_FOR_SYNTAX' SYNTAX_FILENAME = 'YCM_PLACEHOLDER_FOR_SYNTAX'

View File

@ -18,7 +18,7 @@
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>. # along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
from nose.tools import eq_ from nose.tools import eq_
from ycm.completers.all import identifier_completer from ycmd.completers.all import identifier_completer
def GetCursorIdentifier_StartOfLine_test(): def GetCursorIdentifier_StartOfLine_test():

View File

@ -18,7 +18,7 @@
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>. # along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
import ycm_core import ycm_core
from ycm.completers.cpp.clang_completer import ClangCompleter from ycmd.completers.cpp.clang_completer import ClangCompleter
def GetCompleter( user_options ): def GetCompleter( user_options ):
if ycm_core.HasClangSupport(): if ycm_core.HasClangSupport():

View File

@ -20,15 +20,15 @@
import abc import abc
import threading import threading
from collections import defaultdict from collections import defaultdict
from ycm.utils import ToUtf8IfNeeded, ForceSemanticCompletion, RunningInsideVim from ycmd.utils import ToUtf8IfNeeded, ForceSemanticCompletion, RunningInsideVim
if RunningInsideVim(): if RunningInsideVim():
from ycm_client_support import FilterAndSortCandidates from ycm_client_support import FilterAndSortCandidates
else: else:
from ycm_core import FilterAndSortCandidates from ycm_core import FilterAndSortCandidates
from ycm.completers.completer_utils import TriggersForFiletype from ycmd.completers.completer_utils import TriggersForFiletype
from ycm.server.responses import NoDiagnosticSupport from ycmd.responses import NoDiagnosticSupport
NO_USER_COMMANDS = 'This completer does not define any commands.' NO_USER_COMMANDS = 'This completer does not define any commands.'
@ -70,7 +70,7 @@ class Completer( object ):
"foo.bar", the user query is "bar" and completions matching this string should "foo.bar", the user query is "bar" and completions matching this string should
be shown. It should return the list of candidates. The format of the result be shown. It should return the list of candidates. The format of the result
can be a list of strings or a more complicated list of dictionaries. Use can be a list of strings or a more complicated list of dictionaries. Use
ycm.server.responses.BuildCompletionData to build the detailed response. See ycmd.responses.BuildCompletionData to build the detailed response. See
clang_completer.py to see how its used in practice. clang_completer.py to see how its used in practice.
Again, you probably want to override ComputeCandidatesInner(). Again, you probably want to override ComputeCandidatesInner().

View File

@ -19,9 +19,7 @@
from collections import defaultdict from collections import defaultdict
from nose.tools import eq_ from nose.tools import eq_
from ycm.test_utils import MockVimModule from ycmd.completers import completer_utils
vim_mock = MockVimModule()
from ycm.completers import completer_utils
def FiletypeTriggerDictFromSpec_Works_test(): def FiletypeTriggerDictFromSpec_Works_test():

View File

@ -19,11 +19,11 @@
from collections import defaultdict from collections import defaultdict
import ycm_core import ycm_core
from ycm.server import responses from ycmd import responses
from ycm import extra_conf_store from ycmd import extra_conf_store
from ycm.utils import ToUtf8IfNeeded from ycmd.utils import ToUtf8IfNeeded
from ycm.completers.completer import Completer from ycmd.completers.completer import Completer
from ycm.completers.cpp.flags import Flags, PrepareFlagsForClang from ycmd.completers.cpp.flags import Flags, PrepareFlagsForClang
CLANG_FILETYPES = set( [ 'c', 'cpp', 'objc', 'objcpp' ] ) CLANG_FILETYPES = set( [ 'c', 'cpp', 'objc', 'objcpp' ] )
MIN_LINES_IN_FILE_TO_PARSE = 5 MIN_LINES_IN_FILE_TO_PARSE = 5

View File

@ -20,9 +20,9 @@
import ycm_core import ycm_core
import os import os
import inspect import inspect
from ycm import extra_conf_store from ycmd import extra_conf_store
from ycm.utils import ToUtf8IfNeeded from ycmd.utils import ToUtf8IfNeeded
from ycm.server.responses import NoExtraConfDetected from ycmd.responses import NoExtraConfDetected
INCLUDE_FLAGS = [ '-isystem', '-I', '-iquote', '--sysroot=', '-isysroot', INCLUDE_FLAGS = [ '-isystem', '-I', '-iquote', '--sysroot=', '-isysroot',
'-include' ] '-include' ]

View File

@ -18,7 +18,7 @@
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>. # along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
import ycm_core import ycm_core
from ycm.completers.cpp.clang_completer import ClangCompleter from ycmd.completers.cpp.clang_completer import ClangCompleter
def GetCompleter( user_options ): def GetCompleter( user_options ):
if ycm_core.HasClangSupport(): if ycm_core.HasClangSupport():

View File

@ -21,9 +21,9 @@
from collections import defaultdict from collections import defaultdict
import os import os
import glob import glob
from ycm.completers.completer import Completer from ycmd.completers.completer import Completer
from ycm.server import responses from ycmd import responses
from ycm import utils from ycmd import utils
import urllib2 import urllib2
import urllib import urllib
import urlparse import urlparse
@ -41,7 +41,7 @@ FILE_TOO_SHORT_MESSAGE = (
NO_DIAGNOSTIC_MESSAGE = 'No diagnostic for current line!' NO_DIAGNOSTIC_MESSAGE = 'No diagnostic for current line!'
PATH_TO_OMNISHARP_BINARY = os.path.join( PATH_TO_OMNISHARP_BINARY = os.path.join(
os.path.abspath( os.path.dirname( __file__ ) ), os.path.abspath( os.path.dirname( __file__ ) ),
'../../../../third_party/OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe' ) '../../../../OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe' )
#TODO: Handle this better than dummy classes #TODO: Handle this better than dummy classes

View File

@ -15,7 +15,7 @@
# 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 ycm.completers.cs.cs_completer import CsharpCompleter from ycmd.completers.cs.cs_completer import CsharpCompleter
def GetCompleter( user_options ): def GetCompleter( user_options ):
return CsharpCompleter( user_options ) return CsharpCompleter( user_options )

View File

@ -20,11 +20,11 @@ import os
import re import re
from collections import defaultdict from collections import defaultdict
from ycm.completers.completer import Completer from ycmd.completers.completer import Completer
from ycm.completers.cpp.clang_completer import InCFamilyFile from ycmd.completers.cpp.clang_completer import InCFamilyFile
from ycm.completers.cpp.flags import Flags from ycmd.completers.cpp.flags import Flags
from ycm.utils import ToUtf8IfNeeded from ycmd.utils import ToUtf8IfNeeded
from ycm.server import responses from ycmd import responses
EXTRA_INFO_MAP = { 1 : '[File]', 2 : '[Dir]', 3 : '[File&Dir]' } EXTRA_INFO_MAP = { 1 : '[File]', 2 : '[Dir]', 3 : '[File&Dir]' }

View File

@ -18,10 +18,10 @@
# 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 ycm.completers.completer import Completer from ycmd.completers.completer import Completer
from ycm.completers.all.identifier_completer import IdentifierCompleter from ycmd.completers.all.identifier_completer import IdentifierCompleter
from ycm.completers.general.filename_completer import FilenameCompleter from ycmd.completers.general.filename_completer import FilenameCompleter
from ycm.completers.general.ultisnips_completer import UltiSnipsCompleter from ycmd.completers.general.ultisnips_completer import UltiSnipsCompleter
class GeneralCompleterStore( Completer ): class GeneralCompleterStore( Completer ):

View File

@ -19,8 +19,8 @@
import os import os
from nose.tools import eq_ from nose.tools import eq_
from ycm.completers.general.filename_completer import FilenameCompleter from ycmd.completers.general.filename_completer import FilenameCompleter
from ycm import user_options_store from ycmd import user_options_store
test_dir = os.path.dirname( os.path.abspath( __file__ ) ) test_dir = os.path.dirname( os.path.abspath( __file__ ) )
data_dir = os.path.join( test_dir, "testdata", "filename_completer" ) data_dir = os.path.join( test_dir, "testdata", "filename_completer" )

View File

@ -18,8 +18,8 @@
# 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 ycm.completers.general_completer import GeneralCompleter from ycmd.completers.general_completer import GeneralCompleter
from ycm.server import responses from ycmd import responses
class UltiSnipsCompleter( GeneralCompleter ): class UltiSnipsCompleter( GeneralCompleter ):

View File

@ -17,7 +17,7 @@
# 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 ycm.completers.completer import Completer from ycmd.completers.completer import Completer
class GeneralCompleter( Completer ): class GeneralCompleter( Completer ):
""" """

View File

@ -18,7 +18,7 @@
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>. # along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
import ycm_core import ycm_core
from ycm.completers.cpp.clang_completer import ClangCompleter from ycmd.completers.cpp.clang_completer import ClangCompleter
def GetCompleter( user_options ): def GetCompleter( user_options ):
if ycm_core.HasClangSupport(): if ycm_core.HasClangSupport():

View File

@ -18,7 +18,7 @@
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>. # along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
import ycm_core import ycm_core
from ycm.completers.cpp.clang_completer import ClangCompleter from ycmd.completers.cpp.clang_completer import ClangCompleter
def GetCompleter( user_options ): def GetCompleter( user_options ):
if ycm_core.HasClangSupport(): if ycm_core.HasClangSupport():

View File

@ -15,7 +15,7 @@
# 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 ycm.completers.python.jedi_completer import JediCompleter from ycmd.completers.python.jedi_completer import JediCompleter
def GetCompleter( user_options ): def GetCompleter( user_options ):
return JediCompleter( user_options ) return JediCompleter( user_options )

View File

@ -19,8 +19,8 @@
# 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 ycm.completers.completer import Completer from ycmd.completers.completer import Completer
from ycm.server import responses from ycmd import responses
try: try:
import jedi import jedi

View File

@ -26,8 +26,8 @@ import string
import sys import sys
import logging import logging
from threading import Lock from threading import Lock
from ycm import user_options_store from ycmd import user_options_store
from ycm.server.responses import UnknownExtraConf, YCM_EXTRA_CONF_FILENAME from ycmd.responses import UnknownExtraConf, YCM_EXTRA_CONF_FILENAME
from fnmatch import fnmatch from fnmatch import fnmatch

View File

@ -26,7 +26,7 @@ except ImportError as e:
'Error importing ycm_core. Are you sure you have placed a ' 'Error importing ycm_core. Are you sure you have placed a '
'version 3.2+ libclang.[so|dll|dylib] in folder "{0}"? ' 'version 3.2+ libclang.[so|dll|dylib] in folder "{0}"? '
'See the Installation Guide in the docs. Full error: {1}'.format( 'See the Installation Guide in the docs. Full error: {1}'.format(
path.realpath( path.join( path.abspath( __file__ ), '../../..' ) ), path.realpath( path.join( path.abspath( __file__ ), '../..' ) ),
str( e ) ) ) str( e ) ) )
import atexit import atexit
@ -36,10 +36,10 @@ import bottle
import httplib import httplib
from bottle import request, response from bottle import request, response
import server_state import server_state
from ycm import user_options_store from ycmd import user_options_store
from ycm.server.responses import BuildExceptionResponse from ycmd.responses import BuildExceptionResponse
from ycm.server import hmac_plugin from ycmd import hmac_plugin
from ycm import extra_conf_store from ycmd import extra_conf_store
# num bytes for the request body buffer; request.json only works if the request # num bytes for the request body buffer; request.json only works if the request

View File

@ -21,7 +21,7 @@ import logging
import httplib import httplib
from base64 import b64decode, b64encode from base64 import b64decode, b64encode
from bottle import request, response, abort from bottle import request, response, abort
from ycm import utils from ycmd import utils
_HMAC_HEADER = 'x-ycm-hmac' _HMAC_HEADER = 'x-ycm-hmac'

View File

@ -19,9 +19,9 @@
import imp import imp
import os import os
from ycm.utils import ForceSemanticCompletion from ycmd.utils import ForceSemanticCompletion
from ycm.completers.general.general_completer_store import GeneralCompleterStore from ycmd.completers.general.general_completer_store import GeneralCompleterStore
from ycm.completers.completer_utils import PathToFiletypeCompleterPluginLoader from ycmd.completers.completer_utils import PathToFiletypeCompleterPluginLoader
class ServerState( object ): class ServerState( object ):

View File

@ -21,14 +21,9 @@ import sys
import os import os
def SetUpPythonPath(): def SetUpPythonPath():
# We want to have the YouCompleteMe/python directory on the Python PATH
# because all the code already assumes that it's there. This is a relic from
# before the client/server architecture.
# TODO: Fix things so that this is not needed anymore when we split ycmd into
# a separate repository.
sys.path.insert( 0, os.path.join( sys.path.insert( 0, os.path.join(
os.path.dirname( os.path.abspath( __file__ ) ), os.path.dirname( os.path.abspath( __file__ ) ),
'../..' ) ) '..' ) )
from ycm import utils from ycmd import utils
utils.AddThirdPartyFoldersToSysPath() utils.AddThirdPartyFoldersToSysPath()

View File

@ -18,9 +18,7 @@
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>. # along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
from nose.tools import eq_ from nose.tools import eq_
from ycm.test_utils import MockVimModule from ycmd.extra_conf_store import _PathsToAllParentFolders
vim_mock = MockVimModule()
from ycm.extra_conf_store import _PathsToAllParentFolders
def PathsToAllParentFolders_Basic_test(): def PathsToAllParentFolders_Basic_test():

View File

@ -20,7 +20,7 @@
import os import os
import time import time
from .. import handlers from .. import handlers
from ycm import user_options_store from ycmd import user_options_store
def BuildRequest( **kwargs ): def BuildRequest( **kwargs ):
filepath = kwargs[ 'filepath' ] if 'filepath' in kwargs else '/foo' filepath = kwargs[ 'filepath' ] if 'filepath' in kwargs else '/foo'

View File

@ -42,8 +42,7 @@ def LoadDefaults():
def DefaultOptions(): def DefaultOptions():
settings_path = os.path.join( settings_path = os.path.join(
os.path.dirname( os.path.abspath( __file__ ) ), os.path.dirname( os.path.abspath( __file__ ) ), 'default_settings.json' )
'server/default_settings.json' )
with open( settings_path ) as f: with open( settings_path ) as f:
return json.loads( f.read() ) return json.loads( f.read() )

View File

@ -191,15 +191,35 @@ def TerminateProcess( pid ):
os.kill( pid, signal.SIGTERM ) os.kill( pid, signal.SIGTERM )
def AncestorFolders( path ):
folder = os.path.abspath( path )
while True:
parent = os.path.dirname( folder )
if parent == folder:
break
folder = parent
yield folder
def PathToNearestThirdPartyFolder( path ):
for folder in AncestorFolders( path ):
path_to_third_party = os.path.join( folder, 'third_party' )
if os.path.isdir( path_to_third_party ):
return path_to_third_party
return None
def AddThirdPartyFoldersToSysPath(): def AddThirdPartyFoldersToSysPath():
path_to_third_party = os.path.join( path_to_third_party = PathToNearestThirdPartyFolder( __file__ )
os.path.dirname( os.path.abspath( __file__ ) ), if not path_to_third_party:
'../../third_party' ) raise RuntimeError(
'No third_party folder found for: {0}'.format( __file__) )
for folder in os.listdir( path_to_third_party ): for folder in os.listdir( path_to_third_party ):
sys.path.insert( 0, os.path.realpath( os.path.join( path_to_third_party, sys.path.insert( 0, os.path.realpath( os.path.join( path_to_third_party,
folder ) ) ) folder ) ) )
def ForceSemanticCompletion( request_data ): def ForceSemanticCompletion( request_data ):
return ( 'force_semantic' in request_data and return ( 'force_semantic' in request_data and
bool( request_data[ 'force_semantic' ] ) ) bool( request_data[ 'force_semantic' ] ) )

View File

@ -20,7 +20,7 @@
import time import time
import os import os
import copy import copy
from ycm import utils from ycmd import utils
from threading import Thread, Lock from threading import Thread, Lock
# This class implements the Bottle plugin API: # This class implements the Bottle plugin API: