summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/CodeComplete.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Remove 'using namespace llvm' from .cpp files. NFCIlya Biryukov2019-01-071-66/+72
| | | | | | | | The new guideline is to qualify with 'llvm::' explicitly both in '.h' and '.cpp' files. This simplifies moving the code between header and source files and is easier to keep consistent. llvm-svn: 350531
* [clangd] Move helpers from global namespace into anonymous namespace, NFC.Haojian Wu2019-01-031-22/+22
| | | | llvm-svn: 350325
* [clangd] clang-format everything. NFCIlya Biryukov2019-01-031-35/+34
| | | | llvm-svn: 350303
* [clangd] Get rid of AST matchers in CodeComplete, NFCHaojian Wu2018-12-031-9/+18
| | | | | | | | | | | | | | Summary: The isIndexedForCodeCompletion is called in the code patch of SymbolCollector. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D55206 llvm-svn: 348130
* [clangd] Drop injected class name when class scope is not explicitly specified.Eric Liu2018-11-301-3/+14
| | | | | | | | | | | | Summary: E.g. allow injected "A::A" in `using A::A^` but not in "A^". Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D55065 llvm-svn: 347982
* [clangd] Add type boosting in code completionIlya Biryukov2018-11-261-2/+26
| | | | | | | | | | | | Reviewers: sammccall, ioeric Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52276 llvm-svn: 347562
* [clangd] Deduplicate query scopes.Eric Liu2018-11-061-8/+6
| | | | | | | | | | | | | | Summary: For example, when anonymous namespace is present, duplicated namespaces might be generated for the enclosing namespace. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54105 llvm-svn: 346224
* [clangd] Really fix clang -Wimplicit-fallthroughFangrui Song2018-11-021-1/+4
| | | | | | | | The intention was to fall through to Function case in LLVM_ENABLE_ASSERTIONS=Off builds. Use #ifndef NDEBUG to fix -Wimplicit-fallthrough llvm-svn: 345953
* [clangd] Fix clang -Wimplicit-fallthroughFangrui Song2018-11-021-1/+1
| | | | llvm-svn: 345952
* [clangd] Do not query index for new name completions.Kadir Cetinkaya2018-10-241-4/+6
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53192 llvm-svn: 345153
* [clangd] Don't show base class versions of members as completions.Sam McCall2018-10-241-3/+3
| | | | | | | | | | | | | | Summary: These are available via qualifiers, but signal to noise level is low. Keep required quailifier machinery around though, for cross-ns completion. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53571 llvm-svn: 345141
* [clangd] Namespace style cleanup in cpp files. NFC.Sam McCall2018-10-201-55/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Standardize on the most common namespace setup in our *.cpp files: using namespace llvm; namespace clang { namespace clangd { void foo(StringRef) { ... } And remove redundant llvm:: qualifiers. (Except for cases like make_unique where this causes problems with std:: and ADL). This choice is pretty arbitrary, but some broad consistency is nice. This is going to conflict with everything. Sorry :-/ Squash the other configurations: A) using namespace llvm; using namespace clang; using namespace clangd; void clangd::foo(StringRef); This is in some of the older files. (It prevents accidentally defining a new function instead of one in the header file, for what that's worth). B) namespace clang { namespace clangd { void foo(llvm::StringRef) { ... } This is fine, but in practice the using directive often gets added over time. C) namespace clang { namespace clangd { using namespace llvm; // inside the namespace This was pretty common, but is a bit misleading: name lookup preferrs clang::clangd::foo > clang::foo > llvm:: foo (no matter where the using directive is). llvm-svn: 344850
* Fix warning about unused variable [NFC]Mikael Holmen2018-10-181-1/+1
| | | | llvm-svn: 344724
* [clangd] Support scope proximity in code completion.Eric Liu2018-10-171-14/+24
| | | | | | | | | | | | | | | | Summary: This should make all-scope completion more usable. Scope proximity for indexes will be added in followup patch. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53131 llvm-svn: 344688
* Lift VFS from clang to llvm (NFC)Jonas Devlieghere2018-10-101-4/+4
| | | | | | | | | | | | | | | | | | | This patch moves the virtual file system form clang to llvm so it can be used by more projects. Concretely the patch: - Moves VirtualFileSystem.{h|cpp} from clang/Basic to llvm/Support. - Moves the corresponding unit test from clang to llvm. - Moves the vfs namespace from clang::vfs to llvm::vfs. - Formats the lines affected by this change, mostly this is the result of the added llvm namespace. RFC on the mailing list: http://lists.llvm.org/pipermail/llvm-dev/2018-October/126657.html Differential revision: https://reviews.llvm.org/D52783 llvm-svn: 344140
* [clangd] NFC: Migrate to LLVM STLExtras API where possibleKirill Bobyrev2018-10-071-14/+12
| | | | | | | | | | | | | | This patch improves readability by migrating `std::function(ForwardIt start, ForwardIt end, ...)` to LLVM's STLExtras range-based equivalent `llvm::function(RangeT &&Range, ...)`. Similar change in Clang: D52576. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D52650 llvm-svn: 343937
* [clangd] Remove unused headers from CodeComplete.cppFangrui Song2018-10-061-3/+0
| | | | | | | queue is not used after index-provided completions' merge with those from Sema USRGeneration.h is not used after introduction of getSymbolID llvm-svn: 343912
* [clangd] Cache FS stat() calls when building preamble.Eric Liu2018-10-021-10/+17
| | | | | | | | | | | | | | | | | | | | Summary: The file stats can be reused when preamble is reused (e.g. code completion). It's safe to assume that cached status is not outdated as we assume preamble files to remain unchanged. On real file system, this made code completion ~20% faster on a measured file (with big preamble). The preamble build time doesn't change much. Reviewers: sammccall, ilya-biryukov Reviewed By: sammccall Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52419 llvm-svn: 343576
* [clangd] Remove override result handling logic from clangdKadir Cetinkaya2018-10-021-90/+9
| | | | | | | | | | | | | | | | | Summary: Since we plan to move handling of override suggestions to Sema with D52225 this patch just makes sure clangd-side has no logic related to that anymore and updates tests. Reviewers: ioeric, ilya-biryukov Reviewed By: ioeric Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D52226 llvm-svn: 343567
* [clangd] Initial supoprt for cross-namespace global code completion.Eric Liu2018-09-271-14/+37
| | | | | | | | | | | | | | | | | | | | | Summary: When no scope qualifier is specified, allow completing index symbols from any scope and insert proper automatically. This is still experimental and hidden behind a flag. Things missing: - Scope proximity based scoring. - FuzzyFind supports weighted scopes. Reviewers: sammccall Reviewed By: sammccall Subscribers: kbobyrev, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52364 llvm-svn: 343248
* Tell whether file/folder for include completions.Kadir Cetinkaya2018-09-271-0/+5
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, ioeric, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D52547 llvm-svn: 343221
* [clangd] Handle template args for disabled function arg snippetsIlya Biryukov2018-09-261-6/+36
| | | | | | | | | | | | Reviewers: kadircet, ioeric, sammccall Reviewed By: kadircet Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D52422 llvm-svn: 343066
* [clangd] Update code completion for #include completions in r342449Sam McCall2018-09-181-4/+10
| | | | llvm-svn: 342453
* [clangd] Don't override the preamble while completing inside it, it doesn't ↵Sam McCall2018-09-141-2/+11
| | | | | | | | | | | | | | | | | | | | work. Summary: To stay fast, enable single-file-mode instead. This is fine since completions in the preamble are simple. The net effect for now is to suppress the spurious TopLevel completions when completing inside the preamble. Once Sema has include directive completion, this will be more important. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52071 llvm-svn: 342230
* [clangd] Cleanup FuzzyFindRequest filtering limit semanticsKirill Bobyrev2018-09-131-1/+1
| | | | | | | | | | | As discussed during D51860 review, it is better to use `llvm::Optional` here as it has clear semantics which reflect intended behavior. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D52028 llvm-svn: 342138
* [clangd] Implement FuzzyFindRequest JSON (de)serializationKirill Bobyrev2018-09-101-2/+1
| | | | | | | | | | | | JSON (de)serialization of `FuzzyFindRequest` might be useful for both D51090 and D51628. Also, this allows precise logging of the fuzzy find requests. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D51852 llvm-svn: 341802
* [clangd] Add "Deprecated" field to Symbol and CodeCompletion.Eric Liu2018-09-061-0/+5
| | | | | | | | | | | | | | Summary: Also set "deprecated" field in LSP CompletionItem. Reviewers: sammccall, kadircet Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D51724 llvm-svn: 341576
* [clangd] Set SymbolID for sema macros so that they can be merged with index ↵Eric Liu2018-09-061-3/+5
| | | | | | | | | | | | macros. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51688 llvm-svn: 341534
* [clangd] Fix typo. NFCFangrui Song2018-09-051-1/+1
| | | | llvm-svn: 341452
* Remove lambda default parameter to silence -Wpedantic warning. NFCI.Simon Pilgrim2018-09-041-3/+3
| | | | llvm-svn: 341362
* [clangd] Some nitpicking around the new split (preamble/main) dynamic indexSam McCall2018-09-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | Summary: - DynamicIndex doesn't implement ParsingCallbacks, to make its role clearer. ParsingCallbacks is a separate object owned by the receiving TUScheduler. (I tried to get rid of the "index-like-object that doesn't implement index" but it was too messy). - Clarified(?) docs around DynamicIndex - fewer details up front, more details inside. - Exposed dynamic index from ClangdServer for memory monitoring and more direct testing of its contents (actual tests not added here, wanted to get this out for review) - Removed a redundant and sligthly confusing filename param in a callback Reviewers: ilya-biryukov Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51221 llvm-svn: 341325
* [clangd] Avoid crashes in override completionsIlya Biryukov2018-09-031-3/+3
| | | | | | | | | | | | | | Summary: NamedDecl::getName cannot be called on non-identifier names. Reviewers: kadircet, ioeric, hokein, sammccall Reviewed By: ioeric Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D51598 llvm-svn: 341322
* [clangd] Support multiple #include headers in one symbol.Eric Liu2018-09-031-32/+71
| | | | | | | | | | | | | | | | | | | | Summary: Currently, a symbol can have only one #include header attached, which might not work well if the symbol can be imported via different #includes depending on where it's used. This patch stores multiple #include headers (with # references) for each symbol, so that CodeCompletion can decide which include to insert. In this patch, code completion simply picks the most popular include as the default inserted header. We also return all possible includes and their edits in the `CodeCompletion` results. Reviewers: sammccall Reviewed By: sammccall Subscribers: mgrang, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51291 llvm-svn: 341304
* [clangd] Flatten out Symbol::Details. It was ill-conceived, sorry.Sam McCall2018-08-311-11/+8
| | | | | | | | | | Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51504 llvm-svn: 341211
* [clangd] Report position of opening paren in singature helpIlya Biryukov2018-08-301-1/+11
| | | | | | | | | | | | | | Summary: Only accessible via the C++ API at the moment. Reviewers: sammccall Reviewed By: sammccall Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51437 llvm-svn: 341065
* [clangd] Speculative code completion index request before Sema is run.Eric Liu2018-08-241-11/+96
| | | | | | | | | | | | | | | | | | | | | | | | Summary: For index-based code completion, send an asynchronous speculative index request, based on the index request for the last code completion on the same file and the filter text typed before the cursor, before sema code completion is invoked. This can reduce the code completion latency (by roughly latency of sema code completion) if the speculative request is the same as the one generated for the ongoing code completion from sema. As a sequence of code completions often have the same scopes and proximity paths etc, this should be effective for a number of code completions. Trace with speculative index request:{F6997544} Reviewers: hokein, ilya-biryukov Reviewed By: ilya-biryukov Subscribers: javed.absar, jfb, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D50962 llvm-svn: 340604
* [clangd] Suggest code-completions for overriding base class virtual methods.Kadir Cetinkaya2018-08-231-9/+100
| | | | | | | | | | | | | | | | | Summary: Whenever a code-completion is triggered within a class/struct/union looks at base classes and figures out non-overriden virtual functions. Than suggests completions for those. Reviewers: ilya-biryukov, hokein, ioeric Reviewed By: hokein Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50898 llvm-svn: 340530
* [clangd] Move function argument snippet disable mechanism from LSP rendering ↵Kadir Cetinkaya2018-08-231-15/+16
| | | | | | | | | | | | | | | | | | | to internal clangd reprensentation. Summary: We were handling the EnableFunctionArgSnippets only when we are producing LSP response. Move that code into CompletionItem generation so that internal clients can benefit from that as well. Reviewers: ilya-biryukov, ioeric, hokein Reviewed By: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D51102 llvm-svn: 340527
* [clangd] Add parantheses while auto-completing functions.Kadir Cetinkaya2018-08-171-2/+11
| | | | | | | | | | | | | | | | | | | Summary: Currently we only add parantheses to the functions if snippets are enabled, which also inserts snippets for parameters into parantheses. Adding a new option to put only parantheses. Also it moves the cursor within parantheses or at the end of them by looking at whether completion item has any parameters or not. Still requires snippets support on the client side. Reviewers: ioeric, ilya-biryukov, hokein Reviewed By: ioeric Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50835 llvm-svn: 340040
* [clangd] Fetch documentation from the Index during signature helpIlya Biryukov2018-08-171-58/+99
| | | | | | | | | | | | | | | | Summary: Sema can only be used for documentation in the current file, other doc comments should be fetched from the index. Reviewers: hokein, ioeric, kadircet Reviewed By: hokein, kadircet Subscribers: MaskRay, jkorous, mgrang, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50727 llvm-svn: 340005
* [clangd] Show function documentation in signature helpIlya Biryukov2018-08-171-2/+3
| | | | | | | | | | | | | | | | | | | | | | Summary: Previously, clangd was trying to show documentation for the active parameter instead, which is wrong per LSP specification. Moreover, the code path that attempts to get parameter comments never succeds, because no attempt is made to parse function doc comment and extract parameter-specific parts out of it. So we also remove the code that claims to fetch parameter comments: it is not used anymore and is incorrect. Reviewers: hokein, ioeric, kadircet Reviewed By: ioeric Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50726 llvm-svn: 340004
* NFC: Enforce good formatting across multiple clang-tools-extra filesKirill Bobyrev2018-08-141-3/+3
| | | | | | | | | | | This patch improves readability of multiple files in clang-tools-extra and enforces LLVM Coding Guidelines. Reviewed by: ioeric Differential Revision: https://reviews.llvm.org/D50707 llvm-svn: 339687
* [clangd] Show non-instantiated decls in signatureHelpIlya Biryukov2018-08-141-1/+9
| | | | | | | | | | | | | | | | | | | | | | | Summary: To avoid producing very verbose output in substitutions involving typedefs, e.g. T -> std::vector<std::string>::iterator gets turned into an unreadable mess when printed out for libstdc++, result contains internal types (std::__Vector_iterator<...>) and expanded well-defined typedefs (std::basic_string<char>). Until we improve the presentation code in clang, going with non-instantiated decls looks like a better UX trade-off. Reviewers: hokein, ioeric, kadircet Reviewed By: hokein Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50645 llvm-svn: 339665
* [clangd] Introduce scoring mechanism for SignatureInformations.Kadir Cetinkaya2018-08-131-11/+56
| | | | | | | | | | | | Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: mgrang, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50555 llvm-svn: 339547
* [clangd] Support textEdit in addition to insertText.Kadir Cetinkaya2018-08-131-7/+44
| | | | | | | | | | | | | | | | Summary: Completion replies contains textEdits as well. Note that this change relies on https://reviews.llvm.org/D50443. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: mgrang, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50449 llvm-svn: 339543
* Port getLocStart -> getBeginLocStephen Kelly2018-08-091-1/+1
| | | | | | | | | | Reviewers: javed.absar Subscribers: nemanjai, kbarton, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50354 llvm-svn: 339400
* Added functionality to suggest FixIts for conversion of '->' to '.' and vice ↵Kadir Cetinkaya2018-08-081-3/+14
| | | | | | | | | | | | | | | | versa. Summary: Added functionality to suggest FixIts for conversion of '->' to '.' and vice versa. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: yvvan, ioeric, jkorous, arphaman, cfe-commits, kadircet Differential Revision: https://reviews.llvm.org/D50193 llvm-svn: 339224
* [clangd] Share getSymbolID implementation.Haojian Wu2018-08-071-4/+1
| | | | | | | | | | | | Summary: And remove all duplicated implementation. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50375 llvm-svn: 339116
* [clangd] Fix (most) naming warnings from clang-tidy. NFCIlya Biryukov2018-07-261-2/+2
| | | | llvm-svn: 338021
* [clangd] Penalize non-instance members when accessed via class instances.Eric Liu2018-07-231-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The following are metrics for explicit member access completions. There is no noticeable impact on other completion types. Before: EXPLICIT_MEMBER_ACCESS Total measurements: 24382 All measurements: MRR: 62.27 Top10: 80.21% Top-100: 94.48% Full identifiers: MRR: 98.81 Top10: 99.89% Top-100: 99.95% 0-5 filter len: MRR: 13.25 46.31 62.47 67.77 70.40 81.91 Top-10: 29% 74% 84% 91% 91% 97% Top-100: 67% 99% 99% 99% 99% 100% After: EXPLICIT_MEMBER_ACCESS Total measurements: 24382 All measurements: MRR: 63.18 Top10: 80.58% Top-100: 95.07% Full identifiers: MRR: 98.79 Top10: 99.89% Top-100: 99.95% 0-5 filter len: MRR: 13.84 48.39 63.55 68.83 71.28 82.64 Top-10: 30% 75% 84% 91% 91% 97% Top-100: 70% 99% 99% 99% 99% 100% * Top-N: wanted result is found in the first N completion results. * MRR: Mean reciprocal rank. Remark: the change seems to have minor positive impact. Although the improvement is relatively small, down-ranking non-instance members in instance member access should reduce noise in the completion results. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D49543 llvm-svn: 337681
OpenPOWER on IntegriCloud