From 05f24952546257a8f9046b6099ff6c9ecaf11d0b Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 22 Nov 2018 22:51:53 -0800 Subject: [PATCH] FAQ: definition, hover --- FAQ.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/FAQ.md b/FAQ.md index 0e10032..1359b94 100644 --- a/FAQ.md +++ b/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`. * void foo(); A declaration jumps to the definition * void foo() {} 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 * namespace ns { find original or extension namespaces * // ns::foo 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 * #include <iostream> lists all `#include` lines in the project pointing to the included file