Author: sammccall Date: Wed Jun 19 00:29:10 2019 New Revision: 363766 URL: http://llvm.org/viewvc/llvm-project?rev=363766&view=rev Log: Revert "[clangd] Return vector<TextEdit> from applyTweak. NFC"
This reverts commit r363691. Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/ClangdServer.cpp clang-tools-extra/trunk/clangd/ClangdServer.h Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=363766&r1=363765&r2=363766&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Jun 19 00:29:10 2019 @@ -491,14 +491,14 @@ void ClangdLSPServer::onCommand(const Ex 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) { Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=363766&r1=363765&r2=363766&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Jun 19 00:29:10 2019 @@ -329,7 +329,7 @@ void ClangdServer::enumerateTweaks(PathR } 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 Fi *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, Modified: clang-tools-extra/trunk/clangd/ClangdServer.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=363766&r1=363765&r2=363766&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/ClangdServer.h (original) +++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Jun 19 00:29:10 2019 @@ -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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits