From 93dfb452567588ea73988e6becdf7e37bb368b69 Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Tue, 19 Feb 2019 16:50:37 +0000 Subject: [PATCH] [clangd] Add an option in the code to not display number of fixes Summary: Only to the APIs, which are used by our embedders. We do not plan to add a user-facing option for this. Reviewers: sammccall, ioeric Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58387 llvm-svn: 354349 --- clang-tools-extra/clangd/Diagnostics.cpp | 6 +++--- clang-tools-extra/clangd/Diagnostics.h | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/clang-tools-extra/clangd/Diagnostics.cpp b/clang-tools-extra/clangd/Diagnostics.cpp index 83876217b09e..186ab0661c71 100644 --- a/clang-tools-extra/clangd/Diagnostics.cpp +++ b/clang-tools-extra/clangd/Diagnostics.cpp @@ -161,11 +161,11 @@ std::string capitalize(std::string Message) { /// /// dir1/dir2/dir3/../../dir4/header.h:12:23 /// note: candidate function not viable: requires 3 arguments -std::string mainMessage(const Diag &D) { +std::string mainMessage(const Diag &D, bool DisplayFixesCount) { std::string Result; llvm::raw_string_ostream OS(Result); OS << D.Message; - if (!D.Fixes.empty()) + if (DisplayFixesCount && !D.Fixes.empty()) OS << " (" << (D.Fixes.size() > 1 ? "fixes" : "fix") << " available)"; for (auto &Note : D.Notes) { OS << "\n\n"; @@ -252,7 +252,7 @@ void toLSPDiags( { clangd::Diagnostic Main = FillBasicFields(D); - Main.message = mainMessage(D); + Main.message = mainMessage(D, Opts.DisplayFixesCount); if (Opts.EmbedFixesInDiagnostics) { Main.codeActions.emplace(); for (const auto &Fix : D.Fixes) diff --git a/clang-tools-extra/clangd/Diagnostics.h b/clang-tools-extra/clangd/Diagnostics.h index 9130ad5644c5..095590b9a865 100644 --- a/clang-tools-extra/clangd/Diagnostics.h +++ b/clang-tools-extra/clangd/Diagnostics.h @@ -32,6 +32,10 @@ struct ClangdDiagnosticOptions { /// stage during which the issue was produced, e.g. "Semantic Issue" or "Parse /// Issue". bool SendDiagnosticCategory = false; + + /// If true, Clangd will add a number of available fixes to the diagnostic's + /// message. + bool DisplayFixesCount = true; }; /// Contains basic information about a diagnostic.