kadircet created this revision. kadircet added a reviewer: sammccall. Herald added subscribers: usaxena95, arphaman. kadircet requested review of this revision. Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov. Herald added a project: clang-tools-extra.
Some tweaks might edit file types not supported by clang-format. This patch gives them a way to signal that they do not require formatting. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D105039 Files: clang-tools-extra/clangd/ClangdServer.cpp clang-tools-extra/clangd/refactor/Tweak.h Index: clang-tools-extra/clangd/refactor/Tweak.h =================================================================== --- clang-tools-extra/clangd/refactor/Tweak.h +++ clang-tools-extra/clangd/refactor/Tweak.h @@ -78,6 +78,9 @@ /// A message to be displayed to the user. llvm::Optional<std::string> ShowMessage; FileEdits ApplyEdits; + /// Whether the edits should be formatted before presenting to the client. + /// Note that it applies to all files. + bool FormatEdits = true; static Effect showMessage(StringRef S) { Effect E; Index: clang-tools-extra/clangd/ClangdServer.cpp =================================================================== --- clang-tools-extra/clangd/ClangdServer.cpp +++ clang-tools-extra/clangd/ClangdServer.cpp @@ -637,8 +637,8 @@ Effect = T.takeError(); } assert(Effect.hasValue() && "Expected at least one selection"); - if (*Effect) { - // Tweaks don't apply clang-format, do that centrally here. + if (*Effect && (*Effect)->FormatEdits) { + // Format tweaks that require it centrally here. for (auto &It : (*Effect)->ApplyEdits) { Edit &E = It.second; format::FormatStyle Style =
Index: clang-tools-extra/clangd/refactor/Tweak.h =================================================================== --- clang-tools-extra/clangd/refactor/Tweak.h +++ clang-tools-extra/clangd/refactor/Tweak.h @@ -78,6 +78,9 @@ /// A message to be displayed to the user. llvm::Optional<std::string> ShowMessage; FileEdits ApplyEdits; + /// Whether the edits should be formatted before presenting to the client. + /// Note that it applies to all files. + bool FormatEdits = true; static Effect showMessage(StringRef S) { Effect E; Index: clang-tools-extra/clangd/ClangdServer.cpp =================================================================== --- clang-tools-extra/clangd/ClangdServer.cpp +++ clang-tools-extra/clangd/ClangdServer.cpp @@ -637,8 +637,8 @@ Effect = T.takeError(); } assert(Effect.hasValue() && "Expected at least one selection"); - if (*Effect) { - // Tweaks don't apply clang-format, do that centrally here. + if (*Effect && (*Effect)->FormatEdits) { + // Format tweaks that require it centrally here. for (auto &It : (*Effect)->ApplyEdits) { Edit &E = It.second; format::FormatStyle Style =
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits