Auto merge of #2142 - micbou:check-core, r=vheon
[READY] Add error messages when ycmd crashed See PR Valloric/ycmd#467. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2142) <!-- Reviewable:end -->
This commit is contained in:
commit
87f0f7e16d
@ -42,43 +42,6 @@ elseif !has( 'python' ) && !has( 'python3' )
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:script_folder_path = escape( expand( '<sfile>:p:h' ), '\' )
|
||||
let s:python_folder_path = s:script_folder_path . '/../python/'
|
||||
let s:ycmd_folder_path = s:script_folder_path . '/../third_party/ycmd/'
|
||||
|
||||
function! s:YcmLibsPresentIn( path_prefix )
|
||||
if filereadable(a:path_prefix . 'ycm_core.so')
|
||||
return 1
|
||||
elseif filereadable(a:path_prefix . 'ycm_core.pyd')
|
||||
return 1
|
||||
elseif filereadable(a:path_prefix . 'ycm_core.dll')
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
if s:YcmLibsPresentIn( s:python_folder_path )
|
||||
echohl WarningMsg |
|
||||
\ echomsg "YCM libraries found in old YouCompleteMe/python location; " .
|
||||
\ "please RECOMPILE YCM." |
|
||||
\ echohl None
|
||||
call s:restore_cpo()
|
||||
finish
|
||||
endif
|
||||
|
||||
let g:ycm_check_if_ycm_core_present =
|
||||
\ get( g:, 'ycm_check_if_ycm_core_present', 1 )
|
||||
|
||||
if g:ycm_check_if_ycm_core_present &&
|
||||
\ !s:YcmLibsPresentIn( s:ycmd_folder_path )
|
||||
echohl WarningMsg |
|
||||
\ echomsg "ycm_core.[so|pyd|dll] not detected; you need to compile " .
|
||||
\ "YCM before using it. Read the docs!" |
|
||||
\ echohl None
|
||||
call s:restore_cpo()
|
||||
finish
|
||||
endif
|
||||
|
||||
let g:loaded_youcompleteme = 1
|
||||
|
||||
" NOTE: Most defaults are in third_party/ycmd/ycmd/default_settings.json. They
|
||||
|
@ -133,7 +133,3 @@ def IsPythonVersionCorrect( path ):
|
||||
|
||||
def PathToServerScript():
|
||||
return os.path.join( DIR_OF_YCMD, 'ycmd' )
|
||||
|
||||
|
||||
def PathToCheckCoreVersion():
|
||||
return os.path.join( DIR_OF_YCMD, 'check_core_version.py' )
|
||||
|
@ -42,18 +42,12 @@ def SetUpSystemPaths():
|
||||
|
||||
|
||||
def SetUpYCM():
|
||||
from ycm import base, paths
|
||||
from ycmd import user_options_store, utils
|
||||
from ycm import base
|
||||
from ycmd import user_options_store
|
||||
from ycm.youcompleteme import YouCompleteMe
|
||||
|
||||
base.LoadJsonDefaultsIntoVim()
|
||||
|
||||
user_options_store.SetAll( base.BuildServerConf() )
|
||||
|
||||
popen_args = [ paths.PathToPythonInterpreter(),
|
||||
paths.PathToCheckCoreVersion() ]
|
||||
|
||||
if utils.SafePopen( popen_args ).wait() == 2:
|
||||
raise RuntimeError( 'YCM support libs too old, PLEASE RECOMPILE.' )
|
||||
|
||||
return YouCompleteMe( user_options_store.GetAll() )
|
||||
|
@ -34,7 +34,9 @@ from subprocess import PIPE
|
||||
from tempfile import NamedTemporaryFile
|
||||
from ycm import paths, vimsupport
|
||||
from ycmd import utils
|
||||
from ycmd import server_utils
|
||||
from ycmd.request_wrap import RequestWrap
|
||||
from ycmd.responses import ServerError
|
||||
from ycm.diagnostic_interface import DiagnosticInterface
|
||||
from ycm.omni_completer import OmniCompleter
|
||||
from ycm import syntax_parse
|
||||
@ -47,7 +49,6 @@ from ycm.client.completion_request import ( CompletionRequest,
|
||||
from ycm.client.omni_completion_request import OmniCompletionRequest
|
||||
from ycm.client.event_notification import ( SendEventNotificationAsync,
|
||||
EventNotification )
|
||||
from ycmd.responses import ServerError
|
||||
|
||||
try:
|
||||
from UltiSnips import UltiSnips_Manager
|
||||
@ -77,13 +78,29 @@ PatchNoProxy()
|
||||
signal.signal( signal.SIGINT, signal.SIG_IGN )
|
||||
|
||||
HMAC_SECRET_LENGTH = 16
|
||||
SERVER_CRASH_MESSAGE_STDERR_FILE = (
|
||||
"The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). "
|
||||
SERVER_SHUTDOWN_MESSAGE = (
|
||||
"The ycmd server SHUT DOWN (restart with ':YcmRestartServer')." )
|
||||
STDERR_FILE_MESSAGE = (
|
||||
"Run ':YcmToggleLogs stderr' to check the logs." )
|
||||
SERVER_CRASH_MESSAGE_STDERR_FILE_DELETED = (
|
||||
"The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). "
|
||||
STDERR_FILE_DELETED_MESSAGE = (
|
||||
"Logfile was deleted; set 'g:ycm_server_keep_logfiles' to see errors "
|
||||
"in the future." )
|
||||
CORE_UNEXPECTED_MESSAGE = (
|
||||
'Unexpected error while loading the YCM core library.' )
|
||||
CORE_MISSING_MESSAGE = (
|
||||
'YCM core library not detected; you need to compile YCM before using it. '
|
||||
'Follow the instructions in the documentation.' )
|
||||
CORE_PYTHON2_MESSAGE = (
|
||||
"YCM core library compiled for Python 2 but loaded in Python 3. "
|
||||
"Set the 'g:ycm_server_python_interpreter' option to a Python 2 "
|
||||
"interpreter path." )
|
||||
CORE_PYTHON3_MESSAGE = (
|
||||
"YCM core library compiled for Python 3 but loaded in Python 2. "
|
||||
"Set the 'g:ycm_server_python_interpreter' option to a Python 3 "
|
||||
"interpreter path." )
|
||||
CORE_OUTDATED_MESSAGE = (
|
||||
'YCM core library too old; PLEASE RECOMPILE by running the install.py '
|
||||
'script. See the documentation for more details.' )
|
||||
SERVER_IDLE_SUICIDE_SECONDS = 10800 # 3 hours
|
||||
DIAGNOSTIC_UI_FILETYPES = set( [ 'cpp', 'cs', 'c', 'objc', 'objcpp' ] )
|
||||
|
||||
@ -159,11 +176,28 @@ class YouCompleteMe( object ):
|
||||
if self._user_notified_about_crash or self.IsServerAlive():
|
||||
return
|
||||
self._user_notified_about_crash = True
|
||||
|
||||
try:
|
||||
vimsupport.CheckFilename( self._server_stderr )
|
||||
vimsupport.PostVimMessage( SERVER_CRASH_MESSAGE_STDERR_FILE )
|
||||
stderr_message = STDERR_FILE_MESSAGE
|
||||
except RuntimeError:
|
||||
vimsupport.PostVimMessage( SERVER_CRASH_MESSAGE_STDERR_FILE_DELETED )
|
||||
stderr_message = STDERR_FILE_DELETED_MESSAGE
|
||||
|
||||
message = SERVER_SHUTDOWN_MESSAGE
|
||||
return_code = self._server_popen.poll()
|
||||
if return_code == server_utils.CORE_UNEXPECTED_STATUS:
|
||||
message += ' ' + CORE_UNEXPECTED_MESSAGE + ' ' + stderr_message
|
||||
elif return_code == server_utils.CORE_MISSING_STATUS:
|
||||
message += ' ' + CORE_MISSING_MESSAGE
|
||||
elif return_code == server_utils.CORE_PYTHON2_STATUS:
|
||||
message += ' ' + CORE_PYTHON2_MESSAGE
|
||||
elif return_code == server_utils.CORE_PYTHON3_STATUS:
|
||||
message += ' ' + CORE_PYTHON3_MESSAGE
|
||||
elif return_code == server_utils.CORE_OUTDATED_STATUS:
|
||||
message += ' ' + CORE_OUTDATED_MESSAGE
|
||||
else:
|
||||
message += ' ' + stderr_message
|
||||
vimsupport.PostVimMessage( message )
|
||||
|
||||
|
||||
def ServerPid( self ):
|
||||
|
2
third_party/ycmd
vendored
2
third_party/ycmd
vendored
@ -1 +1 @@
|
||||
Subproject commit 89e558f7d49b6d9672477c0d1b4df41d33f1c2e7
|
||||
Subproject commit ff72c8567201a9f9584357b2317fa80a6704b656
|
Loading…
Reference in New Issue
Block a user