diff options
| author | Kadir Cetinkaya <kadircet@google.com> | 2019-10-18 14:57:11 +0200 |
|---|---|---|
| committer | Kadir Cetinkaya <kadircet@google.com> | 2019-10-25 12:15:20 +0200 |
| commit | 8aa84ad37db7ddbff5c1a2e4ef8ff2a616f1da57 (patch) | |
| tree | 901df33f96a42de24fee1acbac16983555d5ff63 /clang-tools-extra/clangd/unittests/TweakTesting.cpp | |
| parent | d62e3ed3f4b9e1c7492194d0c9997147bdfe6aa6 (diff) | |
| download | bcm5719-llvm-8aa84ad37db7ddbff5c1a2e4ef8ff2a616f1da57.tar.gz bcm5719-llvm-8aa84ad37db7ddbff5c1a2e4ef8ff2a616f1da57.zip | |
[clangd] Store Index in Tweak::Selection
Summary:
Incoming define out-of-line tweak requires access to index.
This patch simply propogates the index in ClangdServer to Tweak::Selection while
passing the AST. Also updates TweakTest to accommodate this change.
Reviewers: ilya-biryukov
Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D69165
Diffstat (limited to 'clang-tools-extra/clangd/unittests/TweakTesting.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/unittests/TweakTesting.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/clang-tools-extra/clangd/unittests/TweakTesting.cpp b/clang-tools-extra/clangd/unittests/TweakTesting.cpp index 4e7c14de6f0..e5b619639a5 100644 --- a/clang-tools-extra/clangd/unittests/TweakTesting.cpp +++ b/clang-tools-extra/clangd/unittests/TweakTesting.cpp @@ -14,6 +14,7 @@ #include "refactor/Tweak.h" #include "clang/Tooling/Core/Replacement.h" #include "llvm/Support/Error.h" +#include "gmock/gmock.h" #include "gtest/gtest.h" #include <string> @@ -62,7 +63,7 @@ std::pair<unsigned, unsigned> rangeOrPoint(const Annotations &A) { cantFail(positionToOffset(A.code(), SelectionRng.end))}; } -MATCHER_P4(TweakIsAvailable, TweakID, Ctx, Header, ExtraFiles, +MATCHER_P5(TweakIsAvailable, TweakID, Ctx, Header, ExtraFiles, Index, (TweakID + (negation ? " is unavailable" : " is available")).str()) { std::string WrappedCode = wrap(Ctx, arg); Annotations Input(WrappedCode); @@ -72,7 +73,7 @@ MATCHER_P4(TweakIsAvailable, TweakID, Ctx, Header, ExtraFiles, TU.Code = Input.code(); TU.AdditionalFiles = std::move(ExtraFiles); ParsedAST AST = TU.build(); - Tweak::Selection S(AST, Selection.first, Selection.second); + Tweak::Selection S(Index, AST, Selection.first, Selection.second); auto PrepareResult = prepareTweak(TweakID, S); if (PrepareResult) return true; @@ -94,7 +95,7 @@ std::string TweakTest::apply(llvm::StringRef MarkedCode, TU.Code = Input.code(); TU.ExtraArgs = ExtraArgs; ParsedAST AST = TU.build(); - Tweak::Selection S(AST, Selection.first, Selection.second); + Tweak::Selection S(Index.get(), AST, Selection.first, Selection.second); auto T = prepareTweak(TweakID, S); if (!T) { @@ -129,8 +130,8 @@ std::string TweakTest::apply(llvm::StringRef MarkedCode, } ::testing::Matcher<llvm::StringRef> TweakTest::isAvailable() const { - return TweakIsAvailable(llvm::StringRef(TweakID), Context, Header, - ExtraFiles); + return TweakIsAvailable(llvm::StringRef(TweakID), Context, Header, ExtraFiles, + Index.get()); } std::vector<std::string> TweakTest::expandCases(llvm::StringRef MarkedCode) { |

