ilya-biryukov created this revision.
ilya-biryukov added reviewers: hokein, kadircet, sammccall.
Herald added subscribers: arphaman, jkorous, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63562

Files:
  clang-tools-extra/clangd/ClangdServer.cpp


Index: clang-tools-extra/clangd/ClangdServer.cpp
===================================================================
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -285,6 +285,15 @@
     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));


Index: clang-tools-extra/clangd/ClangdServer.cpp
===================================================================
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -285,6 +285,15 @@
     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
  • [PATCH] D63562: [clangd] For... Ilya Biryukov via Phabricator via cfe-commits

Reply via email to