Commit Graph

428 Commits

Author SHA1 Message Date
Fangrui Song
048f1dc7a5 indexer: index TemplateTypeParmDecl and ParmVarDecl in declarations for clang >= 9
Index ParmVarDecl in declarations if index.parametersInDeclarations is true

And support some unhandled Decl::Kind
2019-05-13 00:26:55 -07:00
Fangrui Song
05d1fbfc5b Add cache.{hierarchicalPath,retainInMemory}
cache.hierarchicalPath: store cache files as $directory/a/b/c.cc.blob to
work around NAME_MAX limitation.

cache.retainInMemory: after this number of loads, keep a copy of file
index in memory. If set to 1, it avoids cache corruption if the index
file is changed after the initial load, which may happen if several
language clients open the same project and share the same cache
directory.

Also rename cacheDirectory cacheFormat to cache.{directory,format}
2019-05-13 00:26:55 -07:00
Leszek Swirski
3a252fc0ad Use DiagnosticRelatedInformation if client supports publishDiagnostics.relatedInformation (#276)
In clients that support DiagnosticRelatedInformation, display
clang notes as these nested diagnostics rather than appending
them to the parent diagnostic's message. Behaviour for clients
that don't support related information should be unchanged.
2019-05-13 00:26:46 -07:00
Fangrui Song
3f6ece0a44 Add initialization option capabilities.* and index.maxInitializerLines
indexer.cc: use index.maxInitializerLines instead of kInitializerMaxLines

messages/initialize.cc: some ServerCapabilities are toggable:

documentOnTypeFormattingProvider.firstTriggerCharacter
foldingRangeProvider
workspace.workspaceFolders.supported
2019-03-17 18:50:25 -07:00
Fangrui Song
8724985388 Compute CompletionItemKind from Declaration instead of CursorKind 2019-03-17 18:50:25 -07:00
Riatre Foo
e4ba51aea3 textDocument/signatureHelp: enable documentation 2019-03-17 18:50:25 -07:00
Riatre Foo
d4de474be1 Fix completion result sorting in VSCode (#210)
Fix #207
2019-03-17 18:50:25 -07:00
Fangrui Song
0dbf6c89f1 Drop support for clang 6 2019-03-17 18:50:25 -07:00
Fangrui Song
7b3aca2952 textDocument/didOpen: index related files when a header is opened
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.
2019-03-17 18:50:25 -07:00
Fangrui Song
9a529bd691 Delay requests if the document has not not indexed (#176)
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
2019-03-17 18:50:25 -07:00
Fangrui Song
cbd36aeedb Handle file deletion and register workspace/didChangeWatchedFiles
* In the "initialized" callback, send client/registerCapability with DidChangeWatchedFilesRegistrationOptions
* In workspace/didChangeWatchedFiles callback, call pipeline::Index
* In pipeline::Index, add a `deleted` status
2019-03-17 18:50:25 -07:00
Fangrui Song
828c21c8d7 Make cacheDirectory related to project root; delete Timer 2019-03-17 18:50:25 -07:00
Fangrui Song
f2df43055f completion: ignore CXXDeductionGuide
Fix #173
2019-03-17 18:50:25 -07:00
Fangrui Song
573bfc27a1 Extend .ccls
* 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
2019-03-17 18:50:21 -07:00
Fangrui Song
18e4be616c Add strict to FuzzyMatcher::Match
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.
2019-01-12 00:40:49 +08:00
Fangrui Song
e0a6db8d9b ParameterInformation: use label: [number, number]
Don't bother checking signatureHelp.signatureInformationparameterInformation.labelOffsetSupport
2019-01-12 00:40:49 +08:00
Fangrui Song
fc38442967 Support textDocument/declaration & LocationLink
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.
2019-01-12 00:40:49 +08:00
Fangrui Song
37a9ad3f81 cmake_minimum_required 3.8; clean up 2019-01-12 00:40:49 +08:00
Fangrui Song
df7221affc Rendezvous after receiving "exit" notification (#159) 2019-01-12 00:40:49 +08:00
Fangrui Song
6945a56fb8 Support multiple -init=
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"]
2019-01-12 00:40:49 +08:00
Fangrui Song
04e80544b9 Refactor serializer
Delete virtual bases Reader & Writer
Delete unused MAKE_REFLECT_STRUCT_WRITER_AS_ARRAY
Merge serializers/{json,binary}.hh into serializer.{hh,cc}
MAKE_REFLECT_STRUCT => REFLECT_STRUCT
MAKE_REFLECT_TYPE_PROXY => REFLECT_UNDERLYING
2019-01-12 00:40:49 +08:00
Fangrui Song
872d7c5de9 Add ReplyOnce::NotReady and error if didOpen is not seen
Use IgnoringDiagConsumer to override default TextDiagnosticPrinter
2019-01-12 00:40:49 +08:00
Fangrui Song
ab48663ca0 Refactor WorkingFiles and CompletionManager
* 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.
2019-01-12 00:40:49 +08:00
Fangrui Song
e5b4a404df completion: use Text for Macro{Instantiation,Definition} 2019-01-12 00:40:49 +08:00
Fangrui Song
5a5165faa8 Merge query.hh and query_util.hh 2019-01-12 00:40:49 +08:00
Fangrui Song
5a723b489a Refactor Matcher to use pimpl and merge match.hh into utils.hh 2019-01-12 00:40:49 +08:00
Fangrui Song
9ffbf3c52e codeAction: use codeActionProvider: CodeActionOptions and respect CodeActionParams::range 2019-01-12 00:40:49 +08:00
Fangrui Song
eacbc1e1e7 Make DocumentLink::range narrower
Thanks to Riatre #135
2019-01-12 00:40:49 +08:00
Fangrui Song
7a363d2259 completion: delete insertText; don't set filterText if it is the same as label
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
2019-01-12 00:40:49 +08:00
Fangrui Song
3bcb5f23a4 serializer: make visitor/vis value/v consistent 2019-01-12 00:40:49 +08:00
Fangrui Song
58e996366d Refactor ReplyOnce; error if InitializeParams.rootUri is null 2019-01-12 00:40:49 +08:00
Fangrui Song
b31a1c6b3e hierarchicalDocumentSymbol: support SymbolKind::Function declaration and uniquify by range
Also ensure selectionRange is a subrange of range, otherwise VSCode won't show the item.
Use detailed_name for 'detail'
2019-01-09 15:19:23 +08:00
Fangrui Song
a24fe5a386 hierarchicalDocumentSymbol: display member function declarations 2019-01-09 15:19:23 +08:00
Fangrui Song
eeeb03c068 If clang >= 8, delete search path detection and use Sema::CodeCompleteIncludedFile 2019-01-09 15:19:23 +08:00
Fangrui Song
94d2b5821e Work around relative --sysroot= 2019-01-09 15:19:23 +08:00
Fangrui Song
e0e00cb48a Reduce MAKE_REFLECT_STRUCT in lsp.hh
Position -> Pos; lsPosition -> Position
2019-01-09 15:19:23 +08:00
Fangrui Song
11ba6b64ff Remove ls prefix from many LSP interfaces
Rename SymbolKind to Kind & lsSymbolKind to SymbolKind
Use textDocumentSync: TextDocumentSyncOptions
2019-01-09 15:19:23 +08:00
Fangrui Song
18e5d5c498 Simplify and work around vscode _sortTextLow 2019-01-09 15:19:23 +08:00
Fangrui Song
90a94cbb4f textDocument/references workspace/symbol: add folders
For textDocument/reference, base/excludeRole/role has been lifted from params.context.* to params.*
2019-01-09 15:19:23 +08:00
Fangrui Song
5599ddd343 Simplify and better compatibility with encodings retaining the feature of low bytes being 1-byte characters 2019-01-09 15:19:23 +08:00
Fangrui Song
df20969788 *.h -> *.hh 2019-01-09 15:19:23 +08:00
Fangrui Song
ea1271a84e Refactor message handler and namespace ccls 2019-01-09 15:19:23 +08:00
Fangrui Song
6e19a5964e Implement textDocument/documentLink 2019-01-09 15:19:23 +08:00
Fangrui Song
1d67a40ce8 Implement textDocument/foldingRange 2019-01-09 15:19:23 +08:00
Fangrui Song
16c2e0643b Deprioritize completion items with additionTextEdits 2019-01-09 15:19:23 +08:00
Fangrui Song
32a658ad24 Fix textDocument/implementation 2019-01-09 15:19:23 +08:00
Fangrui Song
283d887271 Add command line option -index=root to index without starting language server 2019-01-09 15:19:23 +08:00
Fangrui Song
119a05597d Improve extent of definition/declaration; uniquify typeDefinition 2019-01-09 15:19:23 +08:00
Fangrui Song
87ea7d244d Simplify 2019-01-09 15:19:23 +08:00
Fangrui Song
cb7ed9415d Add ExtentRef; merge symbol2refcnt and outline2refcnt
Fix hierarchical document symbol for namespaces when there are multiple declarations.
2019-01-09 15:19:23 +08:00