diff options
| author | Ilya Biryukov <ibiryukov@google.com> | 2019-04-03 07:18:43 +0000 |
|---|---|---|
| committer | Ilya Biryukov <ibiryukov@google.com> | 2019-04-03 07:18:43 +0000 |
| commit | d9c24dca73d13d06f2a2ef8cd3abf50fcda14e4e (patch) | |
| tree | 28f6ee338b8bbd3a95235ef34b3a0b9421ce19f8 /clang-tools-extra/clangd/ClangdServer.cpp | |
| parent | 4178c1533020657d5ff965fe9d43fcf456a1d8d6 (diff) | |
| download | bcm5719-llvm-d9c24dca73d13d06f2a2ef8cd3abf50fcda14e4e.tar.gz bcm5719-llvm-d9c24dca73d13d06f2a2ef8cd3abf50fcda14e4e.zip | |
[clangd] Return clangd::TextEdit in ClangdServer::rename. NFC
Summary:
Instead of tooling::Replacement. To avoid the need to have contents of
the file at the caller site. This also aligns better with other methods
in ClangdServer, majority of those already return LSP-specific data
types.
Reviewers: hokein, ioeric, sammccall
Reviewed By: sammccall
Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D60179
llvm-svn: 357561
Diffstat (limited to 'clang-tools-extra/clangd/ClangdServer.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/ClangdServer.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp index a265f3722ec..907eb308f61 100644 --- a/clang-tools-extra/clangd/ClangdServer.cpp +++ b/clang-tools-extra/clangd/ClangdServer.cpp @@ -280,9 +280,9 @@ ClangdServer::formatOnType(llvm::StringRef Code, PathRef File, Position Pos) { } void ClangdServer::rename(PathRef File, Position Pos, llvm::StringRef NewName, - Callback<std::vector<tooling::Replacement>> CB) { + Callback<std::vector<TextEdit>> CB) { auto Action = [Pos](Path File, std::string NewName, - Callback<std::vector<tooling::Replacement>> CB, + Callback<std::vector<TextEdit>> CB, llvm::Expected<InputsAndAST> InpAST) { if (!InpAST) return CB(InpAST.takeError()); @@ -306,7 +306,7 @@ void ClangdServer::rename(PathRef File, Position Pos, llvm::StringRef NewName, if (!ResultCollector.Result.getValue()) return CB(ResultCollector.Result->takeError()); - std::vector<tooling::Replacement> Replacements; + std::vector<TextEdit> Replacements; for (const tooling::AtomicChange &Change : ResultCollector.Result->get()) { tooling::Replacements ChangeReps = Change.getReplacements(); for (const auto &Rep : ChangeReps) { @@ -320,7 +320,8 @@ void ClangdServer::rename(PathRef File, Position Pos, llvm::StringRef NewName, // * rename globally in project // * rename in open files if (Rep.getFilePath() == File) - Replacements.push_back(Rep); + Replacements.push_back( + replacementToEdit(InpAST->Inputs.Contents, Rep)); } } return CB(std::move(Replacements)); |

