Commit Graph

1812 Commits

Author SHA1 Message Date
Fangrui Song
3b361d0429 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
2018-12-28 12:35:34 -08:00
Fangrui Song
9918246508 Make -v=1 work and log cflags for SemaManager session and Indexer 2018-12-28 12:35:34 -08:00
Fangrui Song
413c4c74f1 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.
2018-12-28 12:35:34 -08:00
Fangrui Song
c719cf7c58 ParameterInformation: use label: [number, number]
Don't bother checking signatureHelp.signatureInformationparameterInformation.labelOffsetSupport
2018-12-28 12:35:34 -08:00
Fangrui Song
2743a24457 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.
2018-12-28 12:35:34 -08:00
Fangrui Song
f30a0af39a cmake_minimum_required 3.8; clean up 2018-12-28 12:35:33 -08:00
Fangrui Song
eb84991cb3 Rendezvous after receiving "exit" notification (#159) 2018-12-28 12:35:33 -08:00
Fangrui Song
24fc0ae39e 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"]
2018-12-28 12:35:33 -08:00
Leszek Swirski
55ca8af549 Spin IncludeComplete's destructor until scanning completes (#147) 2018-12-28 12:35:33 -08:00
Fangrui Song
871e37fe3f query: fix UpdateUses when a new entity is seen; simplify {DeclRef,Use,Usr}Update
Thanks to Leszek Swirski
2018-12-28 12:35:33 -08:00
Fangrui Song
b53314c89c 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
2018-12-28 12:35:33 -08:00
Fangrui Song
16393025f2 Add ReplyOnce::NotReady and error if didOpen is not seen
Use IgnoringDiagConsumer to override default TextDiagnosticPrinter
2018-12-28 12:35:33 -08:00
Fangrui Song
c724779627 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.
2018-12-28 12:35:33 -08:00
Fangrui Song
df095b60bd completion: use Text for Macro{Instantiation,Definition} 2018-12-28 12:35:33 -08:00
Fangrui Song
27fdecc140 Fix ComputeGuessScore and delete dead code
Thanks to CXuesong
2018-12-28 12:35:33 -08:00
Fangrui Song
15f07ca170 Merge maybe.hh into utils.hh 2018-12-28 12:35:33 -08:00
Fangrui Song
935117af76 Merge query.hh and query_util.hh 2018-12-28 12:35:33 -08:00
Fangrui Song
44075382a9 Refactor Matcher to use pimpl and merge match.hh into utils.hh 2018-12-28 12:35:33 -08:00
Fangrui Song
ff8caceafa Make EmptyParam empty & rewrite LruCache 2018-12-28 12:35:33 -08:00
Fangrui Song
5b3be677ec 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.
2018-12-28 12:35:33 -08:00
Fangrui Song
27201f72d5 codeAction: use codeActionProvider: CodeActionOptions and respect CodeActionParams::range 2018-12-28 12:35:32 -08:00
Fangrui Song
7d0f8989a0 Make DocumentLink::range narrower
Thanks to Riatre #135
2018-12-20 00:28:12 -08:00
Fangrui Song
544610c959 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
2018-12-20 00:28:12 -08:00
Fangrui Song
301b5c32ce serializer: make visitor/vis value/v consistent 2018-12-20 00:28:12 -08:00
Fangrui Song
05b30265e5 Refactor ReplyOnce; error if InitializeParams.rootUri is null 2018-12-20 00:28:12 -08:00
Fangrui Song
5734ab2ad5 indexer: handle DecltypeType and empty main file; diag: -Wno-unused-function for headers
Don't replace name with qualified name in Cls::*name
2018-12-20 00:28:12 -08:00
Fangrui Song
1371be4274 .ccls: add %objective-c %objective-cpp
Also allow multiple directives on a line, e.g. %c %cpp -DFOO
2018-12-20 00:28:12 -08:00
Fangrui Song
f348186615 Use clang::isIdentifierBody and clean up utils/working_files 2018-12-20 00:28:12 -08:00
Fangrui Song
da31c7d608 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'
2018-12-20 00:27:34 -08:00
Fangrui Song
cf000ea7c8 README: add client feature table 2018-12-11 15:08:28 -08:00
Nikolaus Wittenstein
c2cc5567c0 Add Apache LICENSE file (#121) 2018-12-11 15:08:28 -08:00
Dso Tsin
428089b2e6 Fix VS2017 build issues and add Appveyor CI script (#118) 2018-12-11 15:08:28 -08:00
Fangrui Song
200651245e Use SM.isWrittenInMainFile; suppress -Werror in preamble
SM.isWrittenInMainFile is to work around preamble bug: spurious err_pp_unterminated_conditional with circular #include
2018-12-11 15:08:01 -08:00
Fangrui Song
1ab10322ec hierarchicalDocumentSymbol: display member function declarations 2018-12-11 15:04:00 -08:00
Fangrui Song
ae4a81cab9 Fix some MSVC 2017 errors
Thanks to Dso Tsin!
2018-12-11 15:04:00 -08:00
Fangrui Song
f37ef4f48b If clang >= 8, delete search path detection and use Sema::CodeCompleteIncludedFile 2018-12-11 15:04:00 -08:00
Fangrui Song
adcf713e23 Work around relative --sysroot= 2018-12-11 15:04:00 -08:00
Fangrui Song
2bd69b66f2 Improve semantic highlight in templates 2018-12-11 15:04:00 -08:00
Fangrui Song
8f9e1c4ae4 Reduce MAKE_REFLECT_STRUCT in lsp.hh
Position -> Pos; lsPosition -> Position
2018-12-11 15:04:00 -08:00
Fangrui Song
8a68dfbf8f Remove ls prefix from many LSP interfaces
Rename SymbolKind to Kind & lsSymbolKind to SymbolKind
Use textDocumentSync: TextDocumentSyncOptions
2018-12-11 15:04:00 -08:00
Fangrui Song
f5df8bee42 Misc 2018-12-11 15:04:00 -08:00
Fangrui Song
6787f0129b Simplify and work around vscode _sortTextLow 2018-12-11 15:04:00 -08:00
Fangrui Song
2184e94062 project.cc: deduplicate more cases 2018-12-11 15:04:00 -08:00
Fangrui Song
f3d4f8fe3f Fix EnumConstantDecl's kind & EnumDecl's vars 2018-12-11 15:04:00 -08:00
Fangrui Song
c7c5abd40c textDocument/references workspace/symbol: add folders
For textDocument/reference, base/excludeRole/role has been lifted from params.context.* to params.*
2018-12-11 15:04:00 -08:00
Fangrui Song
f29d03e9d3 Report InvalidParams for serialization error 2018-12-11 15:04:00 -08:00
Fangrui Song
93371b9b3b Simplify and better compatibility with encodings retaining the feature of low bytes being 1-byte characters 2018-12-11 15:04:00 -08:00
Fangrui Song
7817821959 *.h -> *.hh 2018-12-11 15:04:00 -08:00
Fangrui Song
77e1f354fd Refactor message handler and namespace ccls 2018-12-11 15:03:56 -08:00
Fangrui Song
323d2ec8bf Implement textDocument/documentLink 2018-10-24 20:14:53 -07:00