summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/unittests/HoverTests.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [clangd] Fix early selection for non-vardecl declaratorsKadir Cetinkaya2020-06-101-1/+8
| | | | | | | | | | | | | | | | | | | | | | | Summary: Selection tree was performing an early claim only for VarDecls, but there are other cases where we can have declarators, e.g. FieldDecls. This patch extends the early claim logic to all types of declarators. Fixes https://github.com/clangd/clangd/issues/292 Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D75106 (cherry picked from commit e6b8181895b96740dbe54aca036aa237e0a8363d) Modified the cherry-picked test as diagnostics differ on the branch. Fixes https://github.com/clangd/clangd/issues/421
* [clangd][Hover] Handle uninstantiated default argsKadir Cetinkaya2020-06-101-0/+16
| | | | | | | | | | | | | | | | | | | Summary: Default args might exist but be unparsed or uninstantiated. getDefaultArg asserts on those. This patch makes sure we don't crash in such scenarios. Reviewers: sammccall, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73723 (cherry-picked from commit 9c903d0373ff940f9143efab8d948edf776de9f1) Fixes https://github.com/clangd/clangd/issues/424
* [clangd][Hover] Make tests hermetic by setting target tripletKadir Cetinkaya2020-01-291-43/+28
| | | | | | | | | | | | | | Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=44696 Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73613 (cherry picked from commit 55b0e9c9d5de7c5d70552ac9ca9ffc14097e983b)
* [clangd][Hover] Handle uninstantiated templatesKadir Cetinkaya2020-01-281-0/+19
| | | | | | | | | | | | | | Summary: Fixes https://github.com/clangd/clangd/issues/263 Reviewers: hokein, sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73344 (cherry picked from commit a31a61dafeaa9110687110fc127ea6f7c91dd3e6)
* [clangd][Hover] Change arrow in return type back to →Kadir Cetinkaya2020-01-271-1/+1
| | | | | | | | | | | | | | | | Summary: Currently 🡺 is used in hover response to represent return types, but it is not widely available. Changing this back to original to support more clients. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73336 (cherry picked from commit 1b996faa1575bda6b99e778aaabe14834c10d3ff)
* [clangd] Drop returntype/type when hovering over type-ish namesKadir Cetinkaya2020-01-271-2/+9
| | | | | | | | | | | | | | | | | | Summary: Some names, e.g. constructor/destructor/conversions, already contain the type info, no need to duplicate them in the hoverinfo. Fixes https://github.com/clangd/clangd/issues/252 Reviewers: sammccall, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73110 (cherry picked from commit 1fbb1d6df0113ca341f6d257bc72e07343dd861a)
* [clangd] Print underlying type for decltypes in hoverKadir Cetinkaya2020-01-271-0/+51
| | | | | | | | | | | | | | Summary: Fixes https://github.com/clangd/clangd/issues/249 Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72498 (cherry picked from commit 0474fe465d8feebcfd54a16d93ad8518b5625972)
* [clangd] Dont display `<unknown>` kinds in hover boardKadir Cetinkaya2020-01-271-1/+1
| | | | | | | | | | | | | | | | | | Summary: Currently when hovering over an `auto` or `decltype` that resolve to a builtin-type, clangd would display `<unknown>` as the kind of the symbol. Drop that to make rendering nicer. Reviewers: usaxena95 Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72777 (cherry picked from commit b08e8353a89f682861ef947fdb6e229b3de2e37d)
* [clangd] Extract string literals in macro arguments to unbreak gcc buildbotsKadir Cetinkaya2020-01-271-4/+7
| | | | (cherry picked from commit 041650da67051266eb92b5bb07223394fe1bdab1)
* [clangd] Fix windows buildbotsKadir Cetinkaya2020-01-271-20/+43
| | | | (cherry picked from commit 60adfb83cda883d9fc1079c89d2feaa681a41b90)
* [clangd] Rearrange type, returntype and parameters in hover cardKadir Cetinkaya2020-01-271-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Moves type/returntype into its own line as it is more readable in cases where the type is long. Also gives parameter lists a heading, `Parameters:` to make them stand out. Leaves the `right arrow` instead of `Returns: ` before Return Type to make output more symmetric. ``` function foo Returns: ret_type Parameters: - int x ``` vs ``` function foo 🡺 ret_type Parameters: - int x ``` Reviewers: sammccall, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72623 (cherry picked from commit 44f9c7a820c1e5fb949f441214a46b13588ff51a)
* [clangd] Add a ruler after header in hoverKadir Cetinkaya2020-01-271-0/+27
| | | | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72622 (cherry picked from commit d74a3d470c316f8fade90fe231fc0a51361c01e6)
* [clangd] Show hower info for expressionsKadir Cetinkaya2020-01-271-0/+33
| | | | | | | | | | | | | | | | | | Summary: This currently populates only the Name with the expression's type and Value if expression is evaluatable. Fixes https://github.com/clangd/clangd/issues/56 Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72500 (cherry picked from commit 4d14bfaa2cb1610104db6b0818fc7d74fad1bd8f)
* [clangd] Render header of hover card as a headingKadir Cetinkaya2020-01-131-0/+12
| | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72625
* [clangd] Improve type printing in hoverKadir Cetinkaya2020-01-101-2/+27
| | | | | | | | | | | | | | | | | | Summary: Do not include tag keywords when printing types for symbol names, as it will come from SymbolKind. Also suppress them while printing definitions to prevent them occuring in template arguments. Make use of `getAsString`, instead of `print` in all places to have a consistent style across the file. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72450
* [clangd] Refurbish HoverInfo::presentKadir Cetinkaya2020-01-091-0/+89
| | | | | | | | | | | | Summary: Improves basic hover presentation logic to include more info. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71555
* NFC: Fix trivial typos in commentsKazuaki Ishizaki2020-01-041-1/+1
|
* [clangd] targetDecl() returns only NamedDecls.Sam McCall2020-01-031-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: While it's perfectly reasonable for non-named decls such as static_assert to resolve to themselves: - nothing else ever resolves to them - features based on references (hover, highlight, find refs etc) tend to be uninteresting where only trivial references are possible - returning NamedDecl is a more convenient API (we cast to it in many places) - this aligns closer to findExplicitReferences/explicitReferenceTargets This fixes a crash in explicitReferenceTargets: if the target is a non-named decl then there's an invalid unchecked cast to NamedDecl. In practice this means when hovering over e.g. a static_assert: - before ac3f9e4842, we would show a (boring) hover card - after ac3f9e4842, we would crash - after this patch, we will show nothing Reviewers: kadircet, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72163
* [clangd] Reformat `HoverTests.cpp` NFCIlya Biryukov2019-12-271-500/+501
| | | | I accidentally broke formatting in the previous revision.
* [clangd] Fix crash in hoverIlya Biryukov2019-12-271-489/+506
|
* [clangd] Improve documentation for auto and implicit specsKadir Cetinkaya2019-12-191-27/+109
| | | | | | | | | | | | | | | | | | Summary: Clangd didn't fill documentation for `auto` when it wasn't available in index. Also it wasn't showing any documentations for implicit instantiations. This patch ensures auto and normal decl case behaves in the same way and also makes use of the explicit template specialization while fetching comments for implicit instantiations. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71596
* [clangd] Fix handling of inline/anon namespaces and names of deduced types ↵Kadir Cetinkaya2019-12-171-16/+54
| | | | | | | | | | | | | | | | | | | | | | | | in hover Summary: Clangd normally skips inline and anon namespaces while printing nested name specifiers. It also drops any tag specifiers since we make use of `HoverInfo::Kind` instead of some text in `HoverInfo::Name` There was a bug causing us to print innermost inline/anon namespace, this patch fixes that by skipping those. Also changes printing and kind detection of deduced types to be similar to decl case. Also improves printing for lambdas, currently clangd prints lambdas as `(anonymous class)`, we can improve it by at least printing `(lambda)` instead. Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71543
* [clangd][NFC] Make use of TagDecl inside type for hover on autoKadir Cetinkaya2019-12-171-0/+26
| | | | | | | | | | | | | | | Summary: We were traversing AST twice to get the Decl in case of sugared types(auto, decltype). They seem to be same in practice, so this patch gets rid of the second traversal and makes use of TagDecl inside QualType instead. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71597
* Revert "[clangd] Reapply b60896fad926 Fall back to selecting ↵Sam McCall2019-12-161-1/+1
| | | | | | | token-before-cursor if token-after-cursor fails." This reverts commit a0ff8cd631add513423fc2d8afa49e9650d01fe3. Buildbot failures I can't chase further tonight.
* [clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor if ↵Sam McCall2019-12-161-1/+1
| | | | | | token-after-cursor fails. This reverts commit 8f876d5105507f874c0fb86bc779c9853eab3fe2.
* Revert "[clangd] Reapply b60896fad926 Fall back to selecting ↵Sam McCall2019-12-161-1/+1
| | | | | | token-before-cursor if token-after-cursor fails." This reverts commit 2500a8d5d8813a3e31fc9ba8dd45e211439a1e3d.
* [clangd] Reapply b60896fad926 Fall back to selecting token-before-cursor if ↵Sam McCall2019-12-161-1/+1
| | | | | | | token-after-cursor fails. This reverts commit f0604e73a4daa35a10eb17a998657d6c4bd0e971 The issue with movability of Tweak::Selection was addressed in 7dc388bd9596bbf42633f8a8e450224e39740b60
* Revert "[clangd] Fall back to selecting token-before-cursor if ↵Nico Weber2019-12-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | token-after-cursor fails." This reverts commit b60896fad926754f715acc5d771555aaaa577e0f. Breaks building with gcc: /usr/include/c++/7/bits/stl_construct.h:75:7: error: use of deleted function ‘clang::clangd::Tweak::Selection::Selection(const clang::clangd::Tweak::Selection&)’ { ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); } ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/ClangdServer.h:28:0, from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/ClangdServer.cpp:9: /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/refactor/Tweak.h:49:10: note: ‘clang::clangd::Tweak::Selection::Selection(const clang::clangd::Tweak::Selection&)’ is implicitly deleted because the default definition would be ill-formed: struct Selection { ^~~~~~~~~ /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/refactor/Tweak.h:49:10: error: use of deleted function ‘clang::clangd::SelectionTree::SelectionTree(const clang::clangd::SelectionTree&)’ In file included from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/refactor/Tweak.h:25:0, from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/ClangdServer.h:28, from /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/ClangdServer.cpp:9: /home/buildslave/buildslave/clang-cmake-armv7-selfhost-neon/llvm/clang-tools-extra/clangd/Selection.h:96:3: note: declared here SelectionTree(const SelectionTree &) = delete; ^~~~~~~~~~~~~ e.g. here: http://lab.llvm.org:8011/builders/clang-cmake-armv7-selfhost-neon/builds/2714 http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/41866
* [clangd] Fall back to selecting token-before-cursor if token-after-cursor fails.Sam McCall2019-12-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The problem: LSP specifies that Positions are between characters. Therefore when a position (or an empty range) is used to target elements of the source code, there is an ambiguity - should we look left or right of the cursor? Until now, SelectionTree resolved this to the right except in trivial cases (where there's whitespace, semicolon, or eof on the right). This meant that it's unable to e.g. out-line `int foo^()` today. Complicating this, LSP notwithstanding the cursor is *on* a character in many editors (mostly terminal-based). In these cases there's no ambiguity - we must "look right" - but there's also no way to tell in LSP. (Several features currently resolve this by using getBeginningOfIdentifier, which tries to rewind and supports end-of-identifier. But this relies on raw lexing and is limited and buggy). Precedent: well - most other languages aren't so full of densely packed symbols that we might want to target. Bias-towards-identifier works well enough. MS C++ for vscode seems to mostly use bias-toward-identifier too. The problem with this solution is it doesn't provide any way to target some things such as the constructor call in Foo^(bar()); Presented solution: When an ambiguous selection is found, we generate *both* possible selection trees. We try to run the feature on the rightward tree first, and then on the leftward tree if it fails. This is basically do-what-I-mean, the main downside is the need to do this on a feature-by-feature basis (because each feature knows what "fail" means). The most complicated instance of this is Tweaks, where the preferred selection may vary tweak-by-tweak. Wrinkles: While production behavior is pretty consistent, this introduces some inconsistency in testing, depending whether the interface we're testing is inside or outside the "retry" wrapper. In particular, for many features like Hover, the unit tests will show production behavior, while for Tweaks the harness would have to run the loop itself if we want this. Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71345
* [clangd] Fix windows testsKadir Cetinkaya2019-12-121-0/+1
|
* [clangd] Fix hover crashing on null typesKadir Cetinkaya2019-12-121-0/+18
| | | | | | | | | | | | Summary: Fixes https://github.com/clangd/clangd/issues/225 Reviewers: sammccall, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71403
* [clangd] Switch Hover.All to structured testsKadir Cetinkaya2019-12-061-429/+486
| | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70911
* [clangd] Store index::SymbolKind in HoverInfoKadir Cetinkaya2019-12-061-30/+30
| | | | | | | | | | | | | | | | | | Summary: LSP's SymbolKind has some shortcomings when it comes to C++ types, index::SymbolKind has more detailed info like Destructor, Parameter, MACRO etc. We are planning to make use of that information in our new Hover response, and it would be nice to display the Symbol type in full detail, rather than some approximation. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70723
* [clangd] Show values of more expressions on hoverSam McCall2019-11-191-2/+31
| | | | | | | | | | Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70359
* [clangd] Untangle Hover from XRefs, move into own file.Sam McCall2019-11-191-0/+1339
Summary: This is mostly mechanical, with a few exceptions: - getDeducedType moved into AST.h where it belongs. It now takes ASTContext instead of ParsedAST, and avoids using the preprocessor. - hover now uses SelectionTree directly rather than via getDeclAtPosition helper - hover on 'auto' used to find the decl that contained the 'auto' and use that to set Kind and documentation for the hover result. Now we use targetDecl() to find the decl matching the deduced type instead. This changes tests, e.g. 'variable' -> class for auto on lambdas. I think this is better, but the motivation was to avoid depending on the internals of DeducedTypeVisitor. This functionality is removed from the visitor. Reviewers: kadircet Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70357
OpenPOWER on IntegriCloud