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

Multiple invalid targetUri for function declaration while jumping from cpp file to hpp file #946

Open jbarik opened 1 year ago

jbarik commented 1 year ago

Observed behavior

I think there is something wrong with how I am setting up ccls.

I am trying to jump to the declaration of a function from the definition in cpp file. Below is the request send from neovim and the response from ccls

[pid 3867781] <... read resumed>"Content-Length: 240\r\n\r\n{\"params\":{\"position\":{\"character\":27,\"line\":122},\"textDocument\":{\"uri\":\"file:\\/\\/\\/local-ssd\\/jbarik\\/ls_eventport2\\/matlab\\/src\\/sl_lang_blocks\\/ctrlport\\/ControlPortBlock.cpp\"}},\"id\":7,\"jsonrpc\":\"2.0\",\"method\":\"textDocument\\/definition\"}", 4096) = 263
[pid 3867781] read(0,  <unfinished ...>
[pid 3867782] write(1, "Content-Length: 1179\r\n\r\n{\"jsonrpc\":\"2.0\",\"id\":7,\"result\":[{\"targetUri\":\"file://../../../../../../src/sl_lang_blocks/export/include/sl_lang_blocks/ControlPortBlock.hpp\",\"targetRange\":{\"start\":{\"line\":49,\"character\":4},\"end\":{\"line\":49,\"character\":80}},\"targetSelectionRange\":{\"start\":{\"line\":49,\"character\":9},\"end\":{\"line\":49,\"character\":27}}},{\"targetUri\":\"file://../../../src/sl_lang_blocks/export/include/sl_lang_blocks/ControlPortBlock.hpp\",\"targetRange\":{\"start\":{\"line\":49,\"character\":4},\"end\":{\"line\":49,\"character\":80}},\"targetSelectionRange\":{\"start\":{\"line\":49,\"character\":9},\"end\":{\"line\":49,\"character\":27}}},{\"targetUri\":\"file://../../src/sl_lang_blocks/export/include/sl_lang_blocks/ControlPortBlock.hpp\",\"targetRange\":{\"start\":{\"line\":49,\"character\":4},\"end\":{\"line\":49,\"character\":80}},\"targetSelectionRange\":{\"start\":{\"line\":49,\"character\":9},\"end\":{\"line\":49,\"character\":27}}},{\"targetUri\":\"file:///local-ssd/jbarik/ls_eventport2/matlab/src/sl_lang_blocks/export/include/sl_lang_blocks/ControlPortBlock.hpp\",\"targetRange\":{\"start\":{\"line\":49,\"character\":4},\"end\":{\"line\":49,\"character\":80}},\"targetSelectionRange\":{\"start\":{\"line\":49,\"character\":9},\"end\":{\"line\":49,\"character\":27}}}]}", 1203) = 1203

The response contains 4 targetUris:

file://../../../../../../src/sl_lang_blocks/export/include/sl_lang_blocks/ControlPortBlock.hpp
file://../../../src/sl_lang_blocks/export/include/sl_lang_blocks/ControlPortBlock.hpp
file://../../src/sl_lang_blocks/export/include/sl_lang_blocks/ControlPortBlock.hpp
file:///local-ssd/jbarik/ls_eventport2/matlab/src/sl_lang_blocks/export/include/sl_lang_blocks/ControlPortBlock.hpp

All the targetUris point to ControlPortBlock.hpp, one absolute path and three relative paths. Some of those relative paths don't seem to be correct and result in errors in neovim - it can't find the files.

For some cpp files, I get only one targetUri, one containing absolute path. What can cause ccls to return multiple targetUri?

System information