Fix#190
If a new header is added, the preamble size changes. Language clients may cache completion results, thus we rebuild preamble to avoid inaccurate results.
Fix#180
index.initialBlacklist: ["."] can inhibit initial indexing (useful for larger code bases).
Opened files are still indexed, though.
This heuristic allows related files (a/foo.c a/b/foo.cc) to be indexed when a header (foo.h) is opened.
This fixes a plethora of "not indexed" errors when the document has not been indexed.
* Message handler throws NotIndexed if not overdue
* The message is put into backlog and tagged with backlog_path
* path2backlog[path] tracks backlog associated with document `path`
* The backlog is cleared when the index is merged
* backlog[0] is forced to run if it becomes overdue
* In the "initialized" callback, send client/registerCapability with DidChangeWatchedFilesRegistrationOptions
* In workspace/didChangeWatchedFiles callback, call pipeline::Index
* In pipeline::Index, add a `deleted` status
* Add %h for C header files (the suffix .h is considered a C header, not a C++ header)
* Add %hpp for C++ header files
* If .ccls exists, it provides full command line for files not specified by compile_commands.json (before, compile_commands.json was ignored)
* If the first line of .ccls is %compile_commands.json, it appends flags to compile_commands.json "arguments", instead of overriding.
Files not specified by compile_commands.json will not be added to folder.entries, but their command line can be inferred from other files.
Also fix `#include <` completion of -I flags for clang < 8
In completion, underscore prefixed builtin macros may be annoying when the first type character is not an underscore.
When `strict` is true, `Match` enforces the first characters should be loosely of the same category.
textDocument/{declaration,definition,typeDefinition} return either LocationLink[] or Location[]
Add an initialization option client.linkSupport . When it is false, ccls will return Location[] disregarding client's linkSupport.
`struct LocationLink` does not include originSelectionRange as it is wasteful.
Initialization options are applied (deserialized to the same object) in the following order:
* "initializationOptions" from client
* first -init=
* second -init=
* ...
Scalar options will be overridden but arrays will get concatenated, e.g.
ccls -log-file=/dev/stderr -index . -init='{"clang":{"extraArgs":["-DA"]}}' -init='{"clang":{"extraArgs":["-DB"]}}'
results in clang.extraArgs: ["-DA", "-DB"]
* WorkingFiles::files : vector -> unordered_map
* Add timestamp to WorkingFile
* Rename "comp-preload" thread to "preamble"
* Rename CompletionManager to SemaManager as it is used by "diag" "comp" "preamble"
* Rename clang_complete.* to sema_manager.*
* Merge SemaManager::{preloads,sessions}
* Add initialization option session.maxNum
* In DiagnosticMain, if an included file was modified, cancel the DiagTask and create a PreambleTask instead. The task sets `from_diag` so as to trigger immediate DiagTask after the preamble is built.
This works around gcc 7.2/clang rC347417 which have a bad interaction with libstdc++'s implementation of P0426
constexpr std::string_view also emits a string_view object in .rodata that cannot be optimized out by clang (which means larger object file size)
So use good old const.
It decreases Content-Length: from 32K to 25K for the following case:
#include <bits/stdc++.h>
int main() { std::| }
Also
* make results deterministic when completion text is empty
* sort by newText, label, filterText
Delete method.{cc,h}
Rename $ccls/setSkippedRanges to $ccls/publishSkippedRanges
Rename $ccls/publishSemanticHighlighting to $ccls/publishSemanticHighlight; stableId -> id
* Better LanguageId detection with clangDriver (e.g. .cu -> types::TY_CUDA)
* fallback when there is no .ccls or compile_commands.json
Also Hide clangTooling options from --help
1. Fixed a bug on building document symbol tree: As sym2ds was updated in
place, nested funcs/types may be moved into children of another
lsDocumentSymbol before itself got processed.
2. Namespaces only have declarations, in the old implementation it wasn't included in the result, making the result less hierarchical. This
commit fixes this by including the declarations of a symbol if no
definitions found.
* Fix additionalTextEdits -> textEdit hack for VS Code
Visual Studio Code filters the completion result according to
textEdit.range and filterText, if the textEdit.range overlaps with
existing text, we have to include it in filterText, otherwise it would
be filtered out.
* Fix has_open_paren in FilterCandidates
blacklist some undesired candidates
additionalTextEdits if clang>=7
Use CodePatterns for preprocessor directive completion if there is a #
Prefer textEdit over insertText
* Delete index.enabled which can be achieved with index.blacklist: ['.']
* Move completion.include* to completion.include.*
* move largeFileSize to highlight.largeFileSize
index.{blacklist,whitelist}: disable indexes thoroughly
index.initial{Blacklist,Whitelist}: disable initial loading. will still be indexed after opening
Move using below #include to make preamble happy
textDocument/references: if no references, first line or last line => list where this file is included
malloc_trim() only if files have been indexed in last cycle
Intern: use CachedHashStringRef
$ccls/reload is renamed from $ccls/freshenIndex
This is useful when DB (merged index) diverges from backing IndexFile.
Also fix a semantic highlighting bug.
1. Normalize paths in LSP document URIs and project root to forward
slash and uppercase drive letters.
2. Normalize paths in compile_commands.json to forward slash and
uppercase drive letters.
3. Normalize paths from directory listing to forward slash. (Drive
letter should be same as input dir path, which is already uppercase
since path of project root dir is normalized)
4. Add llvm::sys::path::convert_to_slash after certain llvm::sys::path
and llvm::fs calls.
They allow files matching specified patterns to be indexed only once
even if index.multiVersion > 0. An example is to exclude system headers
with index.multiVersionBlacklist: ["^/usr/include"]
Before, QueryFile::Def::{all_symbols,outline} were built by indexers.
Now, {symbol,outline}2refcnt are used instead, built by main thread.
*_removed are augmented with Query*:Def to allow removal of old {symbol,outline}2refcnt entries.