Author: ibiryukov Date: Wed Jun 19 10:25:24 2019 New Revision: 363843 URL: http://llvm.org/viewvc/llvm-project?rev=363843&view=rev Log: [clangd] Format changes produced by rename
Reviewers: hokein, kadircet, sammccall Reviewed By: kadircet Subscribers: MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63562 Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=363843&r1=363842&r2=363843&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Jun 19 10:25:24 2019 @@ -285,6 +285,15 @@ void ClangdServer::rename(PathRef File, auto Changes = renameWithinFile(InpAST->AST, File, Pos, NewName); if (!Changes) return CB(Changes.takeError()); + + auto Style = getFormatStyleForFile(File, InpAST->Inputs.Contents, + InpAST->Inputs.FS.get()); + if (auto Formatted = + cleanupAndFormat(InpAST->Inputs.Contents, *Changes, Style)) + *Changes = std::move(*Formatted); + else + elog("Failed to format replacements: {0}", Formatted.takeError()); + std::vector<TextEdit> Edits; for (const auto &Rep : *Changes) Edits.push_back(replacementToEdit(InpAST->Inputs.Contents, Rep)); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits