This commit is contained in:
Fangrui Song 2018-09-01 15:37:09 -07:00
parent 6aee7b9648
commit 1ab0d492b7
3 changed files with 20 additions and 16 deletions

View File

@ -6,17 +6,21 @@
ccls, which originates from [cquery](https://github.com/cquery-project/cquery), is a C/C++/Objective-C language server. ccls, which originates from [cquery](https://github.com/cquery-project/cquery), is a C/C++/Objective-C language server.
* code completion (with both signature help and snippets) * code completion (with both signature help and snippets)
* [definition](src/messages/text_document_definition.cc)/[references](src/messages/text_document_references.cc), and other cross references * [definition](src/messages/textDocument_definition.cc)/[references](src/messages/textDcument_references.cc), and other cross references
* [call (caller/callee) hierarchy](src/messages/ccls_call_hierarchy.cc), [inheritance (base/derived) hierarchy](src/messages/ccls_inheritance_hierarchy.cc), [member hierarchy](src/messages/ccls_member_hierarchy.cc) * hierarchies: [call (caller/callee) hierarchy](src/messages/ccls_callHierarchy.cc), [inheritance (base/derived) hierarchy](src/messages/ccls_inheritanceHierarchy.cc), [member hierarchy](src/messages/ccls_memberHierarchy.cc)
* [symbol rename](src/messages/text_document_rename.cc) * [symbol rename](src/messages/text_documentRename.cc)
* [document symbols](src/messages/text_document_document_symbol.cc) and approximate search of [workspace symbol](src/messages/workspace_symbol.cc) * [document symbols](src/messages/textDocument_documentSymbol.cc) and approximate search of [workspace symbol](src/messages/workspace_symbol.cc)
* [hover information](src/messages/text_document_hover.cc) * [hover information](src/messages/textDocument_hover.cc)
* diagnostics * diagnostics and code actions (clang FixIts)
* code actions (clang FixIts) * semantic highlighting and preprocessor skipped regions
* preprocessor skipped regions
* semantic highlighting, including support for [rainbow semantic highlighting](https://medium.com/@evnbr/coding-in-color-3a6db2743a1e)
It makes use of C++17 features, has less third-party dependencies and slimmed-down code base. Cross reference features are strengthened, (see [wiki/FAQ](../../wiki/FAQ)). It currently uses libclang to index C++ code but will switch to Clang C++ API. Refactoring and formatting are non-goals as they can be provided by clang-format, clang-include-fixer and other Clang based tools. It has a global view of the code base and support a lot of cross reference features, see [wiki/FAQ](../../wiki/FAQ).
It starts indexing the whole project (including subprojects if exist) parallelly when you open the first file, while the main thread can serve requests before the indexing is complete.
Saving files will incrementally update the index.
Compared with cquery, it makes use of C++17 features, has less third-party dependencies and slimmed-down code base.
It leverages Clang C++ API as [clangd](https://clang.llvm.org/extra/clangd.html) does, which provides better support for code completion and diagnostics.
Refactoring and formatting are non-goals as they can be provided by clang-format, clang-include-fixer and other Clang based tools.
The comparison with cquery as noted on 2018-07-15: The comparison with cquery as noted on 2018-07-15:
@ -35,4 +39,7 @@ cquery has system include path detection (through running the compiler driver) w
* [Build](../../wiki/Build) * [Build](../../wiki/Build)
* [Emacs](../../wiki/Emacs) * [Emacs](../../wiki/Emacs)
* [LanguageClient-neovim](../../wiki/LanguageClient-neovim)
* [FAQ](../../wiki/FAQ) * [FAQ](../../wiki/FAQ)
ccls can index itself (~180MiB RSS when ide, noted on 2018-09-01), FreeBSD, glibc, Linux, LLVM (~1800MiB RSS), musl (~60MiB RSS), ... with decent memory footprint. See [wiki/compile_commands.json](../../wiki/compile_commands.json) for examples.

View File

@ -258,13 +258,10 @@ bool Indexer_Parse(DiagnosticsPublisher *diag_pub, WorkingFiles *working_files,
// Write current index to disk if requested. // Write current index to disk if requested.
LOG_S(INFO) << "store index for " << path; LOG_S(INFO) << "store index for " << path;
{ {
static Timer timer("write", "store index");
timer.startTimer();
std::string cache_path = GetCachePath(path); std::string cache_path = GetCachePath(path);
WriteToFile(cache_path, curr->file_contents); WriteToFile(cache_path, curr->file_contents);
WriteToFile(AppendSerializationFormat(cache_path), WriteToFile(AppendSerializationFormat(cache_path),
Serialize(g_config->cacheFormat, *curr)); Serialize(g_config->cacheFormat, *curr));
timer.stopTimer();
} }
vfs->Reset(path); vfs->Reset(path);

View File

@ -312,9 +312,9 @@ template <typename TVisitor> void Reflect(TVisitor &visitor, IndexFile &value) {
REFLECT_MEMBER_END(); REFLECT_MEMBER_END();
} }
void Reflect(Reader &visitor, SerializeFormat &value) { void Reflect(Reader &vis, SerializeFormat &v) {
std::string fmt = visitor.GetString(); v = vis.GetString()[0] == 'j' ? SerializeFormat::Json
value = fmt[0] == 'b' ? SerializeFormat::Binary : SerializeFormat::Json; : SerializeFormat::Binary;
} }
void Reflect(Writer &visitor, SerializeFormat &value) { void Reflect(Writer &visitor, SerializeFormat &value) {