summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd')
-rw-r--r--clang-tools-extra/clangd/ClangdLSPServer.cpp4
-rw-r--r--clang-tools-extra/clangd/ClangdServer.cpp10
-rw-r--r--clang-tools-extra/clangd/ClangdServer.h10
3 files changed, 5 insertions, 19 deletions
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 7eaacd26e55..353d387d132 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -491,14 +491,14 @@ void ClangdLSPServer::onCommand(const ExecuteCommandParams &Params,
auto Action = [this, ApplyEdit](decltype(Reply) Reply, URIForFile File,
std::string Code,
- llvm::Expected<ResolvedEffect> R) {
+ llvm::Expected<Tweak::Effect> R) {
if (!R)
return Reply(R.takeError());
if (R->ApplyEdit) {
WorkspaceEdit WE;
WE.changes.emplace();
- (*WE.changes)[File.uri()] = *R->ApplyEdit;
+ (*WE.changes)[File.uri()] = replacementsToEdits(Code, *R->ApplyEdit);
ApplyEdit(std::move(WE));
}
if (R->ShowMessage) {
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp
index fce0cc3720b..1b882048385 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -329,7 +329,7 @@ void ClangdServer::enumerateTweaks(PathRef File, Range Sel,
}
void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
- Callback<ResolvedEffect> CB) {
+ Callback<Tweak::Effect> CB) {
auto Action = [Sel](decltype(CB) CB, std::string File, std::string TweakID,
Expected<InputsAndAST> InpAST) {
if (!InpAST)
@@ -352,13 +352,7 @@ void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
*Effect->ApplyEdit, Style))
Effect->ApplyEdit = std::move(*Formatted);
}
-
- ResolvedEffect R;
- R.ShowMessage = std::move(Effect->ShowMessage);
- if (Effect->ApplyEdit)
- R.ApplyEdit =
- replacementsToEdits(InpAST->Inputs.Contents, *Effect->ApplyEdit);
- return CB(std::move(R));
+ return CB(std::move(*Effect));
};
WorkScheduler.runWithAST(
"ApplyTweak", File,
diff --git a/clang-tools-extra/clangd/ClangdServer.h b/clang-tools-extra/clangd/ClangdServer.h
index 2fe9e9bcdfd..576334795c3 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -57,14 +57,6 @@ public:
using ClangTidyOptionsBuilder = std::function<tidy::ClangTidyOptions(
llvm::vfs::FileSystem &, llvm::StringRef /*File*/)>;
-/// Like Tweak::Effect, but stores TextEdits instead of tooling::Replacements.
-/// Slightly nicer to embedders of ClangdServer.
-/// FIXME: figure out how to remove this duplication.
-struct ResolvedEffect {
- llvm::Optional<std::string> ShowMessage;
- llvm::Optional<std::vector<TextEdit>> ApplyEdit;
-};
-
/// Manages a collection of source files and derived data (ASTs, indexes),
/// and provides language-aware features such as code completion.
///
@@ -250,7 +242,7 @@ public:
/// Apply the code tweak with a specified \p ID.
void applyTweak(PathRef File, Range Sel, StringRef ID,
- Callback<ResolvedEffect> CB);
+ Callback<Tweak::Effect> CB);
/// Only for testing purposes.
/// Waits until all requests to worker thread are finished and dumps AST for
OpenPOWER on IntegriCloud