MaskRay / ccls

C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlighting
Apache License 2.0
3.72k stars 254 forks source link

YCM command `GoToSymbol` report `IndexError: list index out of range` #956

Open ihexon opened 8 months ago

ihexon commented 8 months ago

Observed behavior

When CCLS is used as the LSP server in YCM, executing :YcmCompleter GoToSymbol prompts an IndexError: list index out of range. However, GoToDefinition/GoToDeclaration/GoToReferences/GoToImplementation/GoToType all work correctly.

Is it a compatibility issue between CCLS and the GoToSymbol command in YCM?

I have compile_commands.json in the project root directory. ccls generates an index in PROJECT_ROOT/.ccls-cache/, the size is about 14 M

I have minimal vimrc:

····
call plug#begin()
 Plug 'dracula/vim'
  Plug 'ycm-core/YouCompleteMe', { 'dir': '~/YouCompleteMe', 'do': 'git submodule update --init --recursive' }
call plug#end()

let g:ycm_language_server +=
  \ [{
  \   'name': 'ccls',
  \   'cmdline': [ 'ccls' ],
  \   'filetypes': [ 'c', 'cpp', 'cuda', 'objc', 'objcpp' ],
  \   'project_root_files': [ '.ccls-root', 'compile_commands.json' ]
  \ }]
····

File: /tmp/ycmd_45979_stderr_ew02c6a5.log

2023-12-23 18:37:29,327 - DEBUG - in-event <InotifyEvent: src_path=b'/home/ihexon/glibc/nss/nss_module.h', wd=36, mask=IN_OPEN, cookie=0, name='nss_module.h'>
2023-12-23 18:37:29,371 - DEBUG - in-event <InotifyEvent: src_path=b'/home/ihexon/glibc/sysdeps/generic/unwind.h', wd=78, mask=IN_OPEN, cookie=0, name='unwind.h'>
Traceback (most recent call last):
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 876, in _handle
    return route.call(**args)
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 1756, in wrapper
    rv = callback(*a, **ka)
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/watchdog_plugin.py", line 97, in wrapper
    return callback( *args, **kwargs )
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/hmac_plugin.py", line 62, in wrapper
    body = callback( *args, **kwargs )
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/handlers.py", line 93, in RunCompleterCommand
    return _JsonResponse( completer.OnUserCommand(
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/completers/completer.py", line 481, in OnUserCommand
    return command( self, request_data, arguments[ 1: ] )
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/completers/language_server/language_server_completer.py", line 90, in <lambda>
    lambda self, request_data, args: self.GoToSymbol( request_data, args )
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/completers/language_server/language_server_completer.py", line 2560, in GoToSymbol
    return _SymbolInfoListToGoTo( request_data, result )
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/completers/language_server/language_server_completer.py", line 3205, in _SymbolInfoListToGoTo
    locations = [ BuildGoToLocationFromSymbol( s ) for s in
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/completers/language_server/language_server_completer.py", line 3205, in <listcomp>
    locations = [ BuildGoToLocationFromSymbol( s ) for s in
  File "/home/ihexon/YouCompleteMe/third_party/ycmd/ycmd/completers/language_server/language_server_completer.py", line 3194, in BuildGoToLocationFromSymbol
    description = ( f'{ lsp.SYMBOL_KIND[ symbol[ "kind" ] ] }: '
IndexError: list index out of range
127.0.0.1 - - [23/Dec/2023 18:37:29] "POST /run_completer_command HTTP/1.1" 500 2105
2023-12-23 18:37:33,427 - INFO - Found executeCommandProvider support for command ExecuteCommand in ccls
2023-12-23 18:37:33,427 - INFO - Found codeActionProvider support for command FixIt in ccls

System information