summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests/clangd/CodeCompleteTests.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Fixes for #include insertion.Eric Liu2018-02-191-1/+4
| | | | | | | | | | | | | | | | | | Summary: o Avoid inserting a header include into the header itself. o Avoid inserting non-header files (by not indexing symbols in main files at all). o Canonicalize include paths for symbols in dynamic index. Reviewers: sammccall, ilya-biryukov Reviewed By: ilya-biryukov Subscribers: klimek, jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D43462 llvm-svn: 325523
* [clangd] Invert return value of fuzzyFind() (fix MemIndex's return value)Sam McCall2018-02-191-1/+1
| | | | | | | Have had way too many bugs by converting between "isComplete" and "isIncomplete". LSP is immovable, so use isIncomplete everywhere. llvm-svn: 325493
* [clangd] TestFS cleanup: getVirtualBlahBlah -> testPath/testRoot. Remove ↵Sam McCall2018-02-161-7/+7
| | | | | | SmallString micro-opt for more ergonomic tests. NFC llvm-svn: 325326
* [clangd] Make functions of ClangdServer callback-basedIlya Biryukov2018-02-151-1/+1
| | | | | | | | | | | | | | | | | | Summary: As a consequence, all LSP operations are now handled asynchronously, i.e. they never block the main processing thread. However, if -run-synchronously flag is specified, clangd still runs everything on the main thread. Reviewers: sammccall, ioeric, hokein Reviewed By: sammccall, ioeric Subscribers: klimek, jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D43227 llvm-svn: 325233
* [clangd] Stop exposing Futures from ClangdServer operations.Sam McCall2018-02-131-11/+16
| | | | | | | | | | | | | | | | | | | | Summary: LSP has asynchronous semantics, being able to block on an async operation completing is unneccesary and leads to tighter coupling with the threading. In practice only tests depend on this, so we add a general-purpose "block until idle" function to the scheduler which will work for all operations. To get this working, fix a latent condition-variable bug in ASTWorker, and make AsyncTaskRunner const-correct. Reviewers: ilya-biryukov Subscribers: klimek, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D43127 llvm-svn: 324990
* [clangd] Remove codeComplete that returns std::future<>Ilya Biryukov2018-02-121-10/+8
| | | | | | | | | | | | | | | | Summary: It was deprecated and callback version and is used everywhere. Only changes to the testing code were needed. Reviewers: hokein, ioeric, sammccall Reviewed By: sammccall Subscribers: mgorny, klimek, jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D43068 llvm-svn: 324883
* [clangd] Pass Context implicitly using TLS.Sam McCall2018-01-311-36/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Disable typo correction when doing code completion.Haojian Wu2018-01-251-0/+8
| | | | | | | | | | | | 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/+13
| | | | | | | | | | | | | | | | | | 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] add test for r323347 CodeComplete behavior we rely onSam McCall2018-01-241-2/+8
| | | | llvm-svn: 323350
* [clangd] Use accessible scopes to query indexes for global code completion.Haojian Wu2018-01-231-0/+118
| | | | | | | | | | | | | | | | | | | 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-1/+1
| | | | llvm-svn: 323149
* [clangd] Change index scope convention from "outer::inner" to "outer::inner::"Sam McCall2018-01-191-2/+2
| | | | | | | | | | | | | | | | | | | 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-2/+2
| | | | | | | | "outer::inner::"" This reverts commit r322996. llvm-svn: 322998
* [clangd] Change index scope convention from "outer::inner" to "outer::inner::"Sam McCall2018-01-191-2/+2
| | | | | | | | | | | | | | | | | 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-76/+100
| | | | | | | | | | | | | | | | | | | 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-5/+4
| | | | | | sema llvm-svn: 322856
* [clangd] CodeCompleteTests cleanup: naming, ordering, helpers. NFCSam McCall2018-01-181-164/+157
| | | | llvm-svn: 322824
* [clangd] Avoid combinatorial explosion in CodeCompleteTests.Sam McCall2018-01-161-20/+20
| | | | | | | | | | | | | | | | | Summary: This test dominates our unit test runtime, and the change speeds it up by 10x. We lose coverage of some combinations of flags, but I'm not sure that's finding many bugs. 3300 -> 300ms on my machine (3800 -> 800ms for the whole of CompletionTest). Reviewers: ilya-biryukov Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42063 llvm-svn: 322547
* [clangd] Merge results from static/dynamic index.Sam McCall2018-01-151-4/+5
| | | | | | | | | | | | | | | | 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-5/+41
| | | | | | | | | | | | | | | 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-16/+24
| | | | | | | | | | | | 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] Pass Context to onDiagnosticsReady callbackIlya Biryukov2018-01-101-2/+4
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D41907 llvm-svn: 322199
* [clangd] Add static index for the global code completion.Haojian Wu2018-01-101-13/+18
| | | | | | | | | | | | | | | | | | | | 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/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+12
| | | | | | | | | | | | Reviewers: hokein, sammccall Reviewed By: sammccall Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41345 llvm-svn: 322097
* [clangd] Properly set filterText for index-based completion itemsIlya Biryukov2017-12-291-4/+14
| | | | | | | 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] Use Builder for symbol slabs, and use sorted-vector for storageSam McCall2017-12-231-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This improves a few things: - the insert -> freeze -> read sequence is now enforced/communicated by the type system - SymbolSlab::const_iterator iterates over symbols, not over id-symbol pairs - we avoid permanently storing a second copy of the IDs, and the string map's hashtable The slab size is now down to 21.8MB for the LLVM project. Of this only 2.7MB is strings, the rest is #symbols * `sizeof(Symbol)`. `sizeof(Symbol)` is currently 96, which seems too big - I think SymbolInfo isn't efficiently packed. That's a topic for another patch! Also added simple API to see the memory usage/#symbols of a slab, since it seems likely we will continue to care about this. Reviewers: ilya-biryukov Subscribers: klimek, mgrang, cfe-commits Differential Revision: https://reviews.llvm.org/D41506 llvm-svn: 321412
* [clangd] Pull CodeCompletionString handling logic into its own file and add ↵Eric Liu2017-12-201-1/+1
| | | | | | | | | | | | unit test. Reviewers: sammccall Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41450 llvm-svn: 321193
* [clangd] Switch xrefs and documenthighlight to annotated-code unit tests. NFCSam McCall2017-12-201-37/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The goal here is again to make it easier to read and write the tests. I've extracted `parseTextMarker` from CodeCompleteTests into an `Annotations` class, adding features to it: - as well as points `^s` it allows ranges `[[...]]` - multiple points and ranges are supported - points and ranges may be named: `$name^` and `$name[[...]]` These features are used for the xrefs tests. This also paves the way for replacing the lit diagnostics.test with more readable unit tests, using named ranges. Alternative considered: `TestSelectionRange` in clang-refactor/TestSupport Main problems were: - delimiting the end of ranges is awkward, requiring counting - comment syntax is long and at least as cryptic for most cases - no separate syntax for point vs range, which keeps xrefs tests concise - Still need to convert to Position everywhere - Still need helpers for common case of expecting exactly one point/range (I'll probably promote the extra `PrintTo`s from some of the core Protocol types into `operator<<` in `Protocol.h` itself in a separate, prior patch...) Reviewers: ioeric Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41432 llvm-svn: 321184
* [clangd] Build dynamic index and use it for code completion.Eric Liu2017-12-191-0/+32
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41289 llvm-svn: 321092
* [clangd] Fix warnings/compiler pickiness after r321083Sam McCall2017-12-191-1/+1
| | | | llvm-svn: 321086
* [clangd] Index-based code completion.Eric Liu2017-12-191-0/+101
| | | | | | | | | | | | | | 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] Expose offset <-> LSP position functions, and fix bugsSam McCall2017-12-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | Summary: - Moved these functions to SourceCode.h - added unit tests - fix off by one in positionToOffset: Offset - 1 in final calculation was wrong - fixed formatOnType which had an equal and opposite off-by-one - positionToOffset and offsetToPosition both consistently clamp to beginning/end of file when input is out of range - gave variables more descriptive names - removed windows line ending fixmes where there is nothing to fix - elaborated on UTF-8 fixmes This will conflict with Eric's D41281, but in a pretty easy-to-resolve way. Reviewers: ioeric Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41351 llvm-svn: 321073
* [clangd] Add unit tests for signature help. SigHelp/CodeComplete lit tests ↵Sam McCall2017-12-191-1/+89
| | | | | | are smoke only. llvm-svn: 321065
* [clangd] clang-format the source code. NFCIlya Biryukov2017-12-131-1/+1
| | | | llvm-svn: 320577
* [clangd] Implemented logging using ContextIlya Biryukov2017-12-131-11/+11
| | | | | | | | | | | | Reviewers: sammccall, ioeric, hokein Reviewed By: sammccall Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D40486 llvm-svn: 320576
* [clangd] clang-format the code. NFCIlya Biryukov2017-12-121-2/+3
| | | | llvm-svn: 320476
* [clangd] Convert lit code completion tests to unit-tests. NFCSam McCall2017-12-081-66/+166
| | | | | | | | | | | | Summary: This improves readability of tests and error messages. Reviewers: ioeric Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D40952 llvm-svn: 320148
* [clangd] Clean up code complete unit tests. NFCSam McCall2017-12-051-282/+151
| | | | llvm-svn: 319820
* [clangd] Set completion options per-request.Ilya Biryukov2017-12-051-14/+17
| | | | | | | | | | | | | | | | | | | | Summary: Previously, completion options were set per ClangdServer instance. It will allow to change completion preferences during the lifetime of a single ClangdServer instance. Also rewrote ClangdCompletionTest.CompletionOptions to reuse single ClangdServer instance, the test now runs 2x faster on my machine. Reviewers: sammccall, ioeric, hokein Reviewed By: sammccall, ioeric Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D40654 llvm-svn: 319753
* [clangd] Remove unused test param. NFCSam McCall2017-12-051-4/+4
| | | | llvm-svn: 319742
* [clangd] Split code-completion tests out of ClangdTests. NFC.Sam McCall2017-12-051-0/+400
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
OpenPOWER on IntegriCloud