[clang-tools-extra] r354349 - [clangd] Add an option in the code to not display number of fixes
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 19 08:50:37 PST 2019
Author: ibiryukov
Date: Tue Feb 19 08:50:37 2019
New Revision: 354349
URL: http://llvm.org/viewvc/llvm-project?rev=354349&view=rev
Log:
[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
Modified:
clang-tools-extra/trunk/clangd/Diagnostics.cpp
clang-tools-extra/trunk/clangd/Diagnostics.h
Modified: clang-tools-extra/trunk/clangd/Diagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Diagnostics.cpp?rev=354349&r1=354348&r2=354349&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/Diagnostics.cpp (original)
+++ clang-tools-extra/trunk/clangd/Diagnostics.cpp Tue Feb 19 08:50:37 2019
@@ -161,11 +161,11 @@ std::string capitalize(std::string Messa
///
/// 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)
Modified: clang-tools-extra/trunk/clangd/Diagnostics.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Diagnostics.h?rev=354349&r1=354348&r2=354349&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/Diagnostics.h (original)
+++ clang-tools-extra/trunk/clangd/Diagnostics.h Tue Feb 19 08:50:37 2019
@@ -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.
More information about the cfe-commits
mailing list