summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/CodeComplete.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [clangd] Pass Context implicitly using TLS.Sam McCall2018-01-311-32/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Instead of passing Context explicitly around, we now have a thread-local Context object `Context::current()` which is an implicit argument to every function. Most manipulation of this should use the WithContextValue helper, which augments the current Context to add a single KV pair, and restores the old context on destruction. Advantages are: - less boilerplate in functions that just propagate contexts - reading most code doesn't require understanding context at all, and using context as values in fewer places still - fewer options to pass the "wrong" context when it changes within a scope (e.g. when using Span) - contexts pass through interfaces we can't modify, such as VFS - propagating contexts across threads was slightly tricky (e.g. copy vs move, no move-init in lambdas), and is now encapsulated in the threadpool Disadvantages are all the usual TLS stuff - hidden magic, and potential for higher memory usage on threads that don't use the context. (In practice, it's just one pointer) Reviewers: ilya-biryukov Subscribers: klimek, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D42517 llvm-svn: 323872
* [clangd] Trace code completion.Sam McCall2018-01-301-7/+25
| | | | | | Context passing is a little messy, but will go away with TLS soon. llvm-svn: 323792
* [clangd] Disable typo correction when doing code completion.Haojian Wu2018-01-251-4/+3
| | | | | | | | | | | | Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: klimek, jkorous-apple, cfe-commits, ioeric Differential Revision: https://reviews.llvm.org/D42491 llvm-svn: 323410
* [clangd] Limit completion results.Haojian Wu2018-01-251-0/+2
| | | | | | | | | | | | | | | | | | Summary: * truncate symbols from static/dynamic index to the limited number (which would save lots of cost in constructing the merged symbols). * add an CLI option allowing to limit the number of returned completion results. (default to 100) Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, ilya-biryukov, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D42484 llvm-svn: 323408
* [clangd] Use accessible scopes to query indexes for global code completion.Haojian Wu2018-01-231-42/+95
| | | | | | | | | | | | | | | | | | | Summary: * For qualified completion (foo::a^) * unresolved qualifier - use global namespace ("::") * resolved qualifier - use all accessible namespaces inside the resolved qualifier. * For unqualified completion (vec^), use scopes that are accessible from the scope from which code completion occurs. Reviewers: sammccall, ilya-biryukov Reviewed By: sammccall Subscribers: jkorous-apple, ioeric, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42073 llvm-svn: 323189
* [clangd] Drop ~destructor completions - rarely helpful and work inconsistentlySam McCall2018-01-221-0/+4
| | | | llvm-svn: 323149
* Fix MSVC implicit double-float truncation warning. NFCI.Simon Pilgrim2018-01-221-1/+1
| | | | llvm-svn: 323112
* [clangd] Change index scope convention from "outer::inner" to "outer::inner::"Sam McCall2018-01-191-8/+7
| | | | | | | | | | | | | | | | | | | Global scope is "" (was "") Top-level namespace scope is "ns::" (was "ns") Nested namespace scope is "ns::ns::" (was "ns::ns") This composes more naturally: - qname = scope + name - full scope = resolved scope + unresolved scope (D42073 was the trigger) It removes a wart from the old way: "foo::" has one more separator than "". Another alternative that has these properties is "::ns", but that lacks the property that both the scope and the name are substrings of the qname as produced by clang. This is re-landing r322996 which didn't build. llvm-svn: 323000
* Revert "[clangd] Change index scope convention from "outer::inner" to ↵Sam McCall2018-01-191-6/+8
| | | | | | | | "outer::inner::"" This reverts commit r322996. llvm-svn: 322998
* [clangd] Change index scope convention from "outer::inner" to "outer::inner::"Sam McCall2018-01-191-8/+6
| | | | | | | | | | | | | | | | | Global scope is "" (was "") Top-level namespace scope is "ns::" (was "ns") Nested namespace scope is "ns::ns::" (was "ns::ns") This composes more naturally: - qname = scope + name - full scope = resolved scope + unresolved scope (D42073 was the trigger) It removes a wart from the old way: "foo::" has one more separator than "". Another alternative that has these properties is "::ns", but that lacks the property that both the scope and the name are substrings of the qname as produced by clang. llvm-svn: 322996
* [clangd] Merge index-provided completions with those from Sema.Sam McCall2018-01-191-243/+461
| | | | | | | | | | | | | | | | | | | Summary: - we match on USR, and do a field-by-field merge if both have results - scoring is post-merge, with both sets of information available (for now, sema priority is used if available, static score for index results) - limit is applied to the complete result set (previously index ignored limit) - CompletionItem is only produces for the returned results - If the user doesn't type a scope, we send the global scope for completion (we can improve this after D42073) Reviewers: ioeric Subscribers: klimek, ilya-biryukov, mgrang, cfe-commits Differential Revision: https://reviews.llvm.org/D42181 llvm-svn: 322945
* [clangd] Remove unused IncludeGlobals completion option, always pass true to ↵Sam McCall2018-01-181-1/+1
| | | | | | sema llvm-svn: 322856
* [clangd] Always use preamble (even stale) for code completionIlya Biryukov2018-01-181-4/+8
| | | | | | | | | | | | | | | | | | | | | | | Summary: This improves performance of code completion, because we avoid stating the files from the preamble and never attempt to parse the files without using the preamble if it's provided. However, the change comes at a cost of sometimes providing incorrect results when doing code completion after making actually considerable changes to the files used in the preamble or the preamble itself. Eventually the preamble will get rebuilt and code completion will be providing the correct results. Reviewers: bkramer, sammccall, jkorous-apple Reviewed By: sammccall Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D41991 llvm-svn: 322854
* [clangd] Merge results from static/dynamic index.Sam McCall2018-01-151-11/+4
| | | | | | | | | | | | | | | | Summary: We now hide the static/dynamic split from the code completion, behind a new implementation of the SymbolIndex interface. This will reduce the complexity of the sema/index merging that needs to be done by CodeComplete, at a fairly small cost in flexibility. Reviewers: hokein Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D42049 llvm-svn: 322480
* [clangd] Code completion uses Sema for NS-level things in the current file.Sam McCall2018-01-121-2/+4
| | | | | | | | | | | | | | | Summary: To stay fast, it avoids deserializing anything outside the current file, by disabling the LoadExternal code completion option added in r322377, when the index is enabled. Reviewers: hokein Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41996 llvm-svn: 322387
* [clangd] Include debugging tags for both static and dynamic index. NFCSam McCall2018-01-121-2/+2
| | | | llvm-svn: 322379
* [clangd] Incorporate fuzzy-match into result rankings.Sam McCall2018-01-121-31/+29
| | | | | | | | | | | | Summary: The scoring function is fuzzy-match-quality * existing quality score. Reviewers: ioeric Subscribers: klimek, cfe-commits, ilya-biryukov Differential Revision: https://reviews.llvm.org/D40780 llvm-svn: 322377
* [clangd] Add static index for the global code completion.Haojian Wu2018-01-101-12/+38
| | | | | | | | | | | | | | | | | | | | Summary: Use the YAML-format symbols (generated by the global-symbol-builder tool) to do the global code completion. It is **experimental** only , but it allows us to experience global code completion on a relatively small project. Tested with LLVM project. Reviewers: sammccall, ioeric Reviewed By: sammccall, ioeric Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41668 llvm-svn: 322191
* [clangd] Remove duplicates from code completionIlya Biryukov2018-01-101-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch removes hidden items from code completion. Items can be hidden, e.g., by other items in the child scopes. This patch addresses a particular problem of a duplicate completion item for the class in the following example: struct Adapter { void method(); }; void Adapter::method() { Adapter^ } We should probably investigate if there are other duplicates in completion and remove them, possibly adding assertions that it never happens. Reviewers: sammccall Reviewed By: sammccall Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D41901 llvm-svn: 322185
* [clangd] Add more symbol information for code completion.Eric Liu2018-01-091-3/+6
| | | | | | | | | | | | Reviewers: hokein, sammccall Reviewed By: sammccall Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41345 llvm-svn: 322097
* [clangd] Fix memory leak in code completionIlya Biryukov2018-01-051-0/+1
| | | | llvm-svn: 321867
* [clangd] Properly set filterText for index-based completion itemsIlya Biryukov2017-12-291-1/+1
| | | | | | | It was previously set to an identifier that the user typed, leading to surprising behavior in VSCode (probably in other editors too). llvm-svn: 321554
* [clangd] Pull CodeCompletionString handling logic into its own file and add ↵Eric Liu2017-12-201-210/+14
| | | | | | | | | | | | unit test. Reviewers: sammccall Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41450 llvm-svn: 321193
* [clangd] Supress a log warning by putting it behind a condition.Eric Liu2017-12-191-2/+3
| | | | llvm-svn: 321094
* [clangd] Fix warnings/compiler pickiness after r321083Sam McCall2017-12-191-1/+1
| | | | llvm-svn: 321086
* [clangd] Index-based code completion.Eric Liu2017-12-191-20/+177
| | | | | | | | | | | | | | Summary: Use symbol index to populate completion results for qualfified IDs e.g. "nx::A^". Reviewers: ilya-biryukov, sammccall Reviewed By: ilya-biryukov, sammccall Subscribers: rwols, klimek, mgorny, cfe-commits, sammccall Differential Revision: https://reviews.llvm.org/D41281 llvm-svn: 321083
* [clangd] Implemented logging using ContextIlya Biryukov2017-12-131-18/+20
| | | | | | | | | | | | Reviewers: sammccall, ioeric, hokein Reviewed By: sammccall Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D40486 llvm-svn: 320576
* [clangd] Split code-completion tests out of ClangdTests. NFC.Sam McCall2017-12-051-7/+4
| | | | | | | | | | | | | | Summary: Common parts are mostly FS related, so pulled out TestFS.h for the common stuff. Deliberately resisted cleaning up much here, so this is pretty mechanical. Reviewers: hokein Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D40784 llvm-svn: 319741
* [clangd] Split CodeComplete into a separate file. NFCSam McCall2017-12-041-0/+706
Summary: Shared details of ClangdUnit and CodeComplete moved to a new Compiler file. Reviewers: ilya-biryukov Subscribers: klimek, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D40719 llvm-svn: 319655
OpenPOWER on IntegriCloud