Commit Graph

1831 Commits

Author SHA1 Message Date
Fangrui Song
a833b0cb22 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-10-24 18:37:55 -07:00
Fangrui Song
8f9973f03c GetFallback: append clang.extraArgs
When compile_commands.json is absent, GetFallback is called to get
default clang command line when there is no .ccls or .ccls is empty.
2019-10-24 18:37:55 -07:00
Fangrui Song
520991c009 Compute CompletionItemKind from Declaration instead of CursorKind 2019-10-24 18:37:55 -07:00
Riatre Foo
0793510541 Fix is_local for vars with non-auto storage period 2019-10-24 18:37:55 -07:00
Riatre Foo
90357034df textDocument/signatureHelp: enable documentation 2019-10-24 18:37:55 -07:00
Fangrui Song
823aea0207 Log {Request,Notification}Message, and timestamp change due to dependency 2019-10-24 18:37:55 -07:00
Riatre Foo
b5b7e9b7e2 Fix completion result sorting in VSCode (#210)
Fix #207
2019-10-24 18:37:55 -07:00
Fangrui Song
c4cc5d2697 cmake: delete SYSTEM_CLANG and auto-download mechanism 2019-10-24 18:37:55 -07:00
Fangrui Song
b6d7661fc4 Implement initialization option compilationDatabaseCommand on Windows 2019-10-24 18:37:55 -07:00
Fangrui Song
a7b2ce5c1f Drop support for clang 6 2019-10-24 18:37:55 -07:00
Fangrui Song
b0dab7a6d5 Add -log-file=stderr and make it default
Change -log-file-append to a boolean flag
2019-10-24 18:37:55 -07:00
Fangrui Song
118c5cea6a completion: if preamble size changes, rebuild it
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.
2019-10-24 18:37:55 -07:00
Fangrui Song
5a72ddda38 Update wiki links and delete comparison with cquery 2019-10-24 18:37:55 -07:00
Fangrui Song
e1b68383c6 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-10-24 18:37:55 -07:00
Fangrui Song
36f7775a67 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-10-24 18:37:55 -07:00
Fangrui Song
70e0eec831 Adjust FrontendOpts.Inputs[0] for inferred files 2019-10-24 18:37:55 -07:00
Fangrui Song
d430cb8ff9 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-10-24 18:37:55 -07:00
Fangrui Song
7977bf3edb Make cacheDirectory related to project root; delete Timer 2019-10-24 18:37:55 -07:00
Fangrui Song
61ff7aacc6 completion: ignore CXXDeductionGuide
Fix #173
2019-10-24 18:37:55 -07:00
Fangrui Song
f8c8eca8ee 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-10-24 18:37:55 -07:00
Fangrui Song
79732bf375 Make -v=1 work and log cflags for SemaManager session and Indexer 2019-10-24 18:37:55 -07:00
Fangrui Song
808aa120d1 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-10-24 18:37:55 -07:00
Fangrui Song
cd5c524089 ParameterInformation: use label: [number, number]
Don't bother checking signatureHelp.signatureInformationparameterInformation.labelOffsetSupport
2019-10-24 18:37:55 -07:00
Fangrui Song
ba39be4bcd 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-10-24 18:37:55 -07:00
Fangrui Song
926ea421e6 cmake_minimum_required 3.8; clean up 2019-10-24 18:37:55 -07:00
Fangrui Song
7b6768fd1c Rendezvous after receiving "exit" notification (#159) 2019-10-24 18:37:55 -07:00
Fangrui Song
1d7674bdfc 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-10-24 18:37:55 -07:00
Leszek Swirski
e53a1aba97 Spin IncludeComplete's destructor until scanning completes (#147) 2019-10-24 18:37:55 -07:00
Fangrui Song
4416a258ae query: fix UpdateUses when a new entity is seen; simplify {DeclRef,Use,Usr}Update
Thanks to Leszek Swirski
2019-10-24 18:37:55 -07:00
Fangrui Song
cc11d30dad 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-10-24 18:37:55 -07:00
Fangrui Song
1a7e463553 Add ReplyOnce::NotReady and error if didOpen is not seen
Use IgnoringDiagConsumer to override default TextDiagnosticPrinter
2019-10-24 18:37:55 -07:00
Fangrui Song
d49119b364 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-10-24 18:37:55 -07:00
Fangrui Song
bddd8d1209 completion: use Text for Macro{Instantiation,Definition} 2019-10-24 18:37:54 -07:00
Fangrui Song
58f6f6048f Fix ComputeGuessScore and delete dead code
Thanks to CXuesong
2019-10-24 18:37:54 -07:00
Fangrui Song
ab28a3a7ce Merge maybe.hh into utils.hh 2019-10-24 18:37:54 -07:00
Fangrui Song
5b41788ebb Merge query.hh and query_util.hh 2019-10-24 18:37:54 -07:00
Fangrui Song
bf6fc50b54 Refactor Matcher to use pimpl and merge match.hh into utils.hh 2019-10-24 18:37:54 -07:00
Fangrui Song
a3e635fb09 Make EmptyParam empty & rewrite LruCache 2019-10-24 18:37:54 -07:00
Fangrui Song
6379beb9ba constexpr std::string_view -> const std::string_view
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.
2019-10-24 18:37:54 -07:00
Fangrui Song
385eb582c8 codeAction: use codeActionProvider: CodeActionOptions and respect CodeActionParams::range 2019-10-24 18:37:54 -07:00
Fangrui Song
38227e2bd5 Make DocumentLink::range narrower
Thanks to Riatre #135
2019-10-24 18:37:54 -07:00
Fangrui Song
8fc6b8a9f4 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-10-24 18:37:54 -07:00
Fangrui Song
9d767ffa99 serializer: make visitor/vis value/v consistent 2019-10-24 18:37:54 -07:00
Fangrui Song
e6300aeb57 Refactor ReplyOnce; error if InitializeParams.rootUri is null 2019-10-24 18:37:54 -07:00
Fangrui Song
008b1762c1 indexer: handle DecltypeType and empty main file; diag: -Wno-unused-function for headers
Don't replace name with qualified name in Cls::*name
2019-10-24 18:37:54 -07:00
Fangrui Song
2d00b62f63 .ccls: add %objective-c %objective-cpp
Also allow multiple directives on a line, e.g. %c %cpp -DFOO
2019-10-24 18:37:54 -07:00
Fangrui Song
c2cf488114 Use clang::isIdentifierBody and clean up utils/working_files 2019-10-24 18:37:54 -07:00
Fangrui Song
d2969b5185 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-10-24 18:37:54 -07:00
Nikolaus Wittenstein
8b2076e158 Add Apache LICENSE file (#121) 2019-10-24 18:37:54 -07:00
Dso Tsin
6100a7a0d6 Fix VS2017 build issues and add Appveyor CI script (#118) 2019-10-24 18:37:54 -07:00