Commit Graph

1531 Commits

Author SHA1 Message Date
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
Leszek Swirski
259b9fefb3 Spin IncludeComplete's destructor until scanning completes (#147) 2019-01-12 00:40:49 +08:00
Fangrui Song
d43b994557 query: fix UpdateUses when a new entity is seen; simplify {DeclRef,Use,Usr}Update
Thanks to Leszek Swirski
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
a37782dc0c Fix ComputeGuessScore and delete dead code
Thanks to CXuesong
2019-01-12 00:40:49 +08:00
Fangrui Song
72ee893d26 Merge maybe.hh into utils.hh 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
e6510f7428 Make EmptyParam empty & rewrite LruCache 2019-01-12 00:40:49 +08:00
Fangrui Song
0606b95754 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-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
f6fca76088 indexer: handle DecltypeType and empty main file; diag: -Wno-unused-function for headers
Don't replace name with qualified name in Cls::*name
2019-01-12 00:40:49 +08:00
Fangrui Song
afa654f0d1 .ccls: add %objective-c %objective-cpp
Also allow multiple directives on a line, e.g. %c %cpp -DFOO
2019-01-12 00:40:47 +08:00
Fangrui Song
8c73bbc3c7 Use clang::isIdentifierBody and clean up utils/working_files 2019-01-09 15:19:23 +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
63a510ac21 Use SM.isWrittenInMainFile; suppress -Werror in preamble
SM.isWrittenInMainFile is to work around preamble bug: spurious err_pp_unterminated_conditional with circular #include
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
5736dd094d Fix some MSVC 2017 errors
Thanks to Dso Tsin!
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
58c701d98a Improve semantic highlight in templates 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
ac09b085ff Misc 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
42b6b7b3f0 project.cc: deduplicate more cases 2019-01-09 15:19:23 +08:00
Fangrui Song
334557e9fe Fix EnumConstantDecl's kind & EnumDecl's vars 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
26d76b75c7 Report InvalidParams for serialization error 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
ce1c7ec76a Improve DeducedType 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
Fangrui Song
fc1db06538 Add pipeline::{Notify,Reply,ReplyError} and simplify message handling
Delete method.{cc,h}
Rename $ccls/setSkippedRanges to $ccls/publishSkippedRanges
Rename $ccls/publishSemanticHighlighting to $ccls/publishSemanticHighlight; stableId -> id
2019-01-09 15:19:17 +08:00
Fangrui Song
79352b451c Misc changes to project
* 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
2019-01-09 15:17:19 +08:00
Fangrui Song
4743124370 Adapt trunk change and write comments to PCH 2019-01-09 15:17:19 +08:00
Riatre Foo
f5816e3be3 Fix hierarchical document symbol
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.
2019-01-09 15:17:19 +08:00
Fangrui Song
51081c3cd2 Add namespace alias clang::vfs = llvm::vfs to adapt D52783
vfs::x should be written as llvm::vfs::x to work around a [namepace.udir] bug before GCC 8 when namespace alias is used
2019-01-09 15:17:19 +08:00
Fangrui Song
c5ae521d36 Namespace: improve indexer and don't trace bases in $ccls/member 2019-01-09 15:17:19 +08:00
Riatre Foo
ac2d921ab9 Fix additionalTextEdits -> textEdit hack for VS Code (#89)
* 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
2019-01-09 15:17:19 +08:00
Fangrui Song
5a1ed4c943 Support workspace folders 2019-01-09 15:17:19 +08:00
Fangrui Song
de9c77e1cc Improve completion
blacklist some undesired candidates
additionalTextEdits if clang>=7
Use CodePatterns for preprocessor directive completion if there is a #
Prefer textEdit over insertText
2019-01-09 15:17:19 +08:00
Fangrui Song
10c1c28dd1 Clean and update tests after Index* refactoring 2019-01-09 15:17:13 +08:00
Fangrui Song
8c2170172d Use DeclRef spell to represent Use spell + Use extent 2018-10-04 17:16:39 -07:00
Fangrui Song
6ec032c2a0 Redesign SymbolRef, Ref, Use
Remove lsLocationEx
2018-10-04 17:16:34 -07:00
Fangrui Song
38feb8d277 Add completion.maxNum: 100 2018-10-04 00:13:50 -07:00
Fangrui Song
c7ee3d85f3 For $ccls/member, use unadjusted RecordDecl (if there is forward declaration) and handle ClassTemplateSpecialization 2018-10-03 00:42:02 -07:00
Fangrui Song
fc8a60c630 Add PreambleStatCache 2018-10-02 22:15:21 -07:00
Fangrui Song
29f05d96fb Use pthread if defined(__unix__) || defined(__APPLE__) 2018-10-02 17:51:36 -07:00
firstlove
8d49b44154 regard conversion as method instead of constructor 2018-10-01 20:49:49 -07:00
Fangrui Song
da07cb2da4 Add $ccls/info 2018-10-01 16:56:53 -07:00
Fangrui Song
f2227cbaa2 Clean 2018-10-01 16:56:53 -07:00
Fangrui Song
84984c6c27 Use non-inferred entries and build preamble for .h; index on didOpen if no pending requests; documentHighlight 2018-10-01 16:56:50 -07:00
Fangrui Song
79373ba486 Rename some initialization options
* Delete index.enabled which can be achieved with index.blacklist: ['.']
* Move completion.include* to completion.include.*
* move largeFileSize to highlight.largeFileSize
2018-09-30 11:46:34 -07:00
Fangrui Song
da704521b5 Revamp codeLens & codeAction
b.ref: references of bases
d.ref: references of derived
when b.ref > 0, don't display 0 ref or x bases
2018-09-30 11:44:24 -07:00
Fangrui Song
d4871207ed Construct SourceManager with UserFilesAreVolatile
Prettify pipeline
2018-09-28 14:06:01 -07:00
Fangrui Song
a127ca9b02 Support textDocument/{formatting,onTypeFormatting,rangeFormatting} 2018-09-28 10:18:04 -07:00
Fangrui Song
05109b6fa4 Merge textDocument_did{Change,Close,Open,Save}.cc 2018-09-27 22:16:42 -07:00
Amos Bird
d6ad864f11 Update threaded_queue.h (#82)
https://en.cppreference.com/w/cpp/language/fold
2018-09-26 17:47:03 -07:00
Fangrui Song
41fcc0272c Simplify semantic highlighting; improve hover of auto && 2018-09-25 11:57:42 -07:00
Fangrui Song
0eb9428a32 Add index.trackDependency and improve pipeline 2018-09-24 00:38:56 -07:00
Fangrui Song
eb644bb78e Add index.initial{Blacklist,Whitelist}
index.{blacklist,whitelist}: disable indexes thoroughly
index.initial{Blacklist,Whitelist}: disable initial loading. will still be indexed after opening
2018-09-24 00:38:56 -07:00
Fangrui Song
ce68028caf Add GetAdjustedDecl to adjust Decl's that are missed by clangIndex 2018-09-24 00:38:54 -07:00
Fangrui Song
8f40c0c244 Remove clang_utils.* 2018-09-23 20:34:40 -07:00
Fangrui Song
854225bd30 Misc
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
2018-09-23 20:34:38 -07:00
Riatre Foo
32f7d148ca Allow force disabling snippet via client.snippetSupport 2018-09-23 11:32:57 -07:00
Fangrui Song
71e9835b8c documentSymbol: ignore TypeParameter
Reported by Riatre
2018-09-23 10:44:08 -07:00
Riatre Foo
e320ce42ab Include macros in completion result 2018-09-23 10:40:41 -07:00
Fangrui Song
22daed7001 Add kind to $ccls/member and iterate all QueryType::def
kind:2 => member functions
kind:3 => nested classes / namespace members
2018-09-23 10:40:41 -07:00
Fangrui Song
7eb58bb5e1 Misc 2018-09-23 10:40:41 -07:00
Fangrui Song
6ea399559d Fix spurious "Failed to index" errors 2018-09-23 10:40:41 -07:00
Fangrui Song
28d33324b1 Publish diagnostics of inferred files and change diagnostics.{onChange,onOpen,onSave} from bool to debounce time 2018-09-23 10:40:39 -07:00
Riatre Foo
1a519163da Remove chunks with CK_Information kind from insertText. (#78)
Without this ccls inserts "size() const" in the following scenario:

std::string text;
text.si| <-- Trigger completion here and pick "size"
2018-09-22 08:57:36 -07:00
Fangrui Song
4d76108d6b Delete file_consumer.* 2018-09-20 19:48:20 -07:00
Fangrui Song
41756297ef Simplify semantic highlighting 2018-09-20 17:49:39 -07:00
Fangrui Song
f9bd84a975 Clean up FileConsumer and improve pipeline 2018-09-20 09:20:07 -07:00
Fangrui Song
f515b4b466 Improve VarDef::type for textDocument/typeDefinition 2018-09-20 01:08:33 -07:00
Fangrui Song
08645d64c1 intern args 2018-09-20 01:08:33 -07:00
Fangrui Song
525b6da1ac intern strings in dependencies and IndexInclude::resolved_path 2018-09-20 01:08:33 -07:00
Fangrui Song
763106c3d4 Simplify pipeline and fix race 2018-09-20 01:08:31 -07:00
Fangrui Song
14b73f0d6f Add hierarchicalDocumentSymbolSupport 2018-09-16 20:53:52 -07:00
Fangrui Song
a18977b9fc Add clang.pathMappings to reuse cache files with differect source paths 2018-09-16 20:53:52 -07:00