summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/unittests/TweakTests.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Add new helpers to make tweak tests scale better. Convert most ↵Sam McCall2019-08-021-365/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tests. NFC Summary: TweakTests.cpp has some pretty good helpers added for the first few tweaks, but they have some limitations: - many assertion failures point at the wrong line - need lots of input/output tests, setup code is duplicated across both - local helpers make it hard to split the file as it grows The new helpers in TweakTests.h are based on old ones (same operations) but try to address these issues and generally make tests more terse while improving error messages. This patch converts everything except ExtractVariable (which is complex and has changes in flight, so will be converted later). It's LOC-neutral, despite not being able to get rid of the old helpers until ExtractVariable is done. Reviewers: ilya-biryukov Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65525 llvm-svn: 367667
* [Clangd] NFC: Added FIXME in ExtractVariable testsShaurya Gupta2019-07-311-2/+7
| | | | llvm-svn: 367406
* [clangd] Fix a regression in rL366996.Haojian Wu2019-07-301-0/+11
| | | | | | | | | | | | | | Summary: That patch made the tweak always annotate the whole file by accident. Reviewers: jvikstrom Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65443 llvm-svn: 367313
* [clangd] Support extraction of binary "subexpressions" like a + [[b + c]].Sam McCall2019-07-261-1/+70
| | | | | | | | | | | | | | | | | | | | | Summary: These aren't formally subexpressions in C++, in this case + is left-associative. However informally +, *, etc are usually (mathematically) associative and users consider these subexpressions. We detect these and in simple cases support extracting the partial expression. As well as builtin associative operators, we assume that overloads of them are associative and support those too. Reviewers: SureYeaah Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65139 llvm-svn: 367121
* [Clangd] Disable ExtractVariable for all types of assignmentsShaurya Gupta2019-07-261-0/+2
| | | | | | | | | | | | Reviewers: sammccall, kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65332 llvm-svn: 367113
* [clangd] Fix the annotate tweak after rL366893Haojian Wu2019-07-251-0/+11
| | | | | | | | | | | | | | | | | | Summary: After rL366893, the annoate tweak is not activated when we select the whole file (the commonAncestor is TUDecl but we intend to return null). This patch fixes this, and also avoid traversing the TUDecl. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65210 llvm-svn: 366996
* [clangd] SelectionTree treats TranslationUnitDecl (mostly) consistently with ↵Sam McCall2019-07-241-8/+8
| | | | | | | | | | | | | | | | | | | | | | | other containers. Summary: Previously TranslationUnitDecl would never be selected. This means root() is never null, and returns a reference. commonAncestor() is in principle never null also, but returning TUDecl here requires tweaks to be careful not to traverse it (this was already possible when selecting multiple top-level decls, and there are associated bugs!) Instead, never allow commonAncestor() to return TUDecl, return null instead. Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65101 llvm-svn: 366893
* [Clangd] Fixed ExtractVariable for certain types of ExprsShaurya Gupta2019-07-241-30/+64
| | | | | | | | | | | | | | | | | | Summary: - Modified ExtractVariable for extraction of MemberExpr, DeclRefExpr and Assignment Expr - Removed extraction from label statements. - Fixed unittests Reviewers: sammccall, kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64717 llvm-svn: 366869
* [Clangd] Fixed ExtractVariable testShaurya Gupta2019-07-191-9/+15
| | | | llvm-svn: 366568
* [Clangd] Fixed SelectionTree bug for macrosShaurya Gupta2019-07-191-2/+13
| | | | | | | | | | | | | | | | | | Summary: Fixed SelectionTree bug for macros - Fixed SelectionTree claimRange for macros and template instantiations - Fixed SelectionTree unit tests - Changed a breaking test in TweakTests Reviewers: sammccall, kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64329 llvm-svn: 366566
* [Clangd] Changed ExtractVariable to only work on non empty selectionsShaurya Gupta2019-07-181-33/+36
| | | | | | | | | | | | | | | | Summary: - For now, we don't trigger in any case if it's an empty selection - Fixed unittests Reviewers: kadircet, sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64912 llvm-svn: 366451
* [clangd] Suppress unwritten scopes when expanding auto.Haojian Wu2019-07-181-0/+14
| | | | | | | | | | | | | | Summary: otherwise the replacement will break the code. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64627 llvm-svn: 366446
* [clangd] Fix error message in tweaktests to be useful. NFCSam McCall2019-07-171-4/+4
| | | | llvm-svn: 366311
* [clangd] Implementation of auto type expansion.Sam McCall2019-07-111-0/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add a tweak for clangd to replace an auto keyword to the deduced type. This way a user can declare something with auto and then have the IDE/clangd replace auto with whatever type clangd thinks it is. In case of long/complext types this makes is reduces writing effort for the user. The functionality is similar to the hover over the auto keyword. Example (from the header): ``` /// Before: /// auto x = Something(); /// ^^^^ /// After: /// MyClass x = Something(); /// ^^^^^^^ ``` Patch by kuhnel! (Christian Kühnel) Differential Revision: https://reviews.llvm.org/D62855 llvm-svn: 365792
* [clangd] Fix an assertion crash in "ExtractVariable" tweakHaojian Wu2019-07-111-0/+8
| | | | | | | | | | | | | | | | Summary: GetTypePtr requires that the type should not be null, otherwise we hit an assertion, we should use getTypePtrOrNull instead. Reviewers: sammccall, SureYeaah Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64556 llvm-svn: 365763
* dummy variable extraction on a function scopeShaurya Gupta2019-07-091-6/+136
| | | | | | | | | | | | | | | | | | | Summary: - Added extraction to a dummy variable - using auto for the dummy variable type for now - Works on a function scope - Adding braces to create a compound statement not supported yet - added unit tests Reviewers: sammccall, kadircet Subscribers: mgorny, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63773 llvm-svn: 365453
* [clangd] A code tweak to expand a macroIlya Biryukov2019-07-081-0/+93
| | | | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61681 llvm-svn: 365331
* [clangd] Add a hidden tweak to annotate all highlighting tokens of the file.Haojian Wu2019-07-041-0/+8
| | | | | | | | | | | | Reviewers: sammccall, jvikstrom Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64137 llvm-svn: 365130
* [TEST] Fix test on Windows by looking for substrings rather than a regexDouglas Yung2019-06-191-4/+7
| | | | | | since the escaping of special characters appears to break on Windows. llvm-svn: 363761
* [clangd] Add hidden tweaks to dump AST/selection.Sam McCall2019-06-181-6/+65
| | | | | | | | | | | | | | | | | | | | | | | Summary: This introduces a few new concepts: - tweaks have an Intent (they don't all advertise as refactorings) - tweaks may produce messages (for ShowMessage notification). Generalized Replacements -> Effect. - tweaks (and other features) may be hidden (clangd -hidden-features flag). We may choose to promote these one day. I'm not sure they're worth their own feature flags though. Verified it in vim-clangd (not yet open source), curious if the UI is ok in VSCode. Reviewers: ilya-biryukov Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62538 llvm-svn: 363680
* [clangd] Minor cleanup. NFCIlya Biryukov2019-06-041-1/+0
| | | | | | Removed unused using declaration from TweakTests.cpp llvm-svn: 362517
* [clangd] Add tweak to convert normal to raw string literal, when it contains ↵Sam McCall2019-05-211-3/+35
| | | | | | | | | | | | | | escapes. Reviewers: ilya-biryukov Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62151 llvm-svn: 361252
* [clangd] Move clangd tests to clangd directory. check-clangd is no longer ↵Sam McCall2019-04-291-0/+190
part of check-clang-tools. Summary: Motivation: - this layout is a pain to work with - without a common root, it's painful to express things like "disable clangd" (D61122) - CMake/lit configs are a maintenance hazard, and the more the one-off hacks for various tools are entangled, the more we see apathy and non-ownership. This attempts to use the bare-minimum configuration needed (while still supporting the difficult cases: windows, standalone clang build, dynamic libs). In particular the lit.cfg.py and lit.site.cfg.py.in are merged into lit.cfg.in. The logic in these files is now minimal. (Much of clang-tools-extra's lit configs can probably be cleaned up by reusing lit.llvm.llvm_config.use_clang(), and every llvm project does its own version of LDPATH mangling. I haven't attempted to fix any of those). Docs are still in clang-tools-extra/docs, I don't have any plans to touch those. Reviewers: gribozavr Subscribers: mgorny, javed.absar, MaskRay, jkorous, arphaman, kadircet, jfb, cfe-commits, ilya-biryukov, thakis Tags: #clang Differential Revision: https://reviews.llvm.org/D61187 llvm-svn: 359424
OpenPOWER on IntegriCloud