FAQ: definition, hover

Fangrui Song 2018-11-22 22:51:53 -08:00
parent 737d9bd921
commit 05f2495254

15
FAQ.md

@ -166,9 +166,16 @@ For macros, there is code to track different usage, thus you may find them able
`index.multiVersion` is an experimental option to index every version to certify that the author is aware of this issue :)
It may not be very useful though. It is of type `number` but not `boolean` as the author is also aware of other dimensions of the multi-version problem.
### Completion and diagnostics
While most cross reference requests (`textDocument/definition` `textDocument/references` `$ccls/member` ...) are served by the index (`query.h:DB`) and have a global view, completion and diagnostics are single-TU features.
They use unsaved buffers and require re-parsing for each new request.
### Definitions
`textDocument/definition` can be used in many places. Some are current implementation details and may subject to change.
`textDocument/definition` jumps to the definitions (there can be many across many TUs, thinking of odr violation) if available. If the cursor is on a definition, jump to declarations instead.
When jumping from a dependent name in a template, ccls tries its best to get every target when the information is available. If the template is written in a main file and you instantiate it multiple times, it can assuredly find all target. However if the template is in a header, because by default a header is indexed for one TU, you won't get all targets. See the discussion about `index.multiVersion`.
* <code>void <kbd>foo</kbd>();</code> A declaration jumps to the definition
* <code>void <kbd>foo</kbd>() {}</code> The definition lists all declarations
@ -181,6 +188,12 @@ It may not be very useful though. It is of type `number` but not `boolean` as th
* <code>namespace <kbd>ns</kbd> {</code> find original or extension namespaces
* <code>// ns::<kbd>foo</kbd></code> in comments, it recognizes the identifier around the cursor, approximately finds the best matching symbol and jumps to it; on `ns`, it jumps to the namespace
### Hover
`textDocument/hover` is served by the index, which is built when you save the file. This model is simple to implement and has lower CPU cycles, but the drawback is that you don't get immediate hover information for newly-created declarations that are not in the index.
See the initialization option `index.onChange`.
### References
* <code><kbd>#include &lt;iostream&gt;</kbd></code> lists all `#include` lines in the project pointing to the included file