|
15 | 15 | #include "Format.h" |
16 | 16 | #include "HeaderSourceSwitch.h" |
17 | 17 | #include "InlayHints.h" |
| 18 | +#include "NoLintFixes.h" |
18 | 19 | #include "ParsedAST.h" |
19 | 20 | #include "Preamble.h" |
20 | 21 | #include "Protocol.h" |
@@ -62,8 +63,8 @@ namespace clangd { |
62 | 63 | namespace { |
63 | 64 |
|
64 | 65 | // Tracks number of times a tweak has been offered. |
65 | | -static constexpr trace::Metric TweakAvailable( |
66 | | - "tweak_available", trace::Metric::Counter, "tweak_id"); |
| 66 | +static constexpr trace::Metric |
| 67 | + TweakAvailable("tweak_available", trace::Metric::Counter, "tweak_id"); |
67 | 68 |
|
68 | 69 | // Update the FileIndex with new ASTs and plumb the diagnostics responses. |
69 | 70 | struct UpdateIndexCallbacks : public ParsingCallbacks { |
@@ -661,7 +662,7 @@ tryConvertToRename(const Diag *Diag, const Fix &Fix) { |
661 | 662 | bool IsClangTidyRename = Diag->Source == Diag::ClangTidy && |
662 | 663 | Diag->Name == "readability-identifier-naming" && |
663 | 664 | !Fix.Edits.empty(); |
664 | | - if (IsClangTidyRename && Diag->InsideMainFile) { |
| 665 | + if (IsClangTidyRename && !isNoLintFixes(Fix) && Diag->InsideMainFile) { |
665 | 666 | ClangdServer::CodeActionResult::Rename R; |
666 | 667 | R.NewName = Fix.Edits.front().newText; |
667 | 668 | R.FixMessage = Fix.Message; |
@@ -701,21 +702,14 @@ void ClangdServer::codeAction(const CodeActionInputs &Params, |
701 | 702 | return nullptr; |
702 | 703 | }; |
703 | 704 | for (const auto &DiagRef : Params.Diagnostics) { |
704 | | - if (const auto *Diag = FindMatchedDiag(DiagRef)) { |
705 | | - auto It = Diag->Fixes.begin(); |
706 | | - if (It != Diag->Fixes.end()) { |
707 | | - if (auto Rename = tryConvertToRename(Diag, *It)) { |
708 | | - // Only try to convert the first Fix to rename as subsequent Fixes |
709 | | - // might be "ignore [readability-identifier-naming] for this |
710 | | - // line". |
| 705 | + if (const auto *Diag = FindMatchedDiag(DiagRef)) |
| 706 | + for (const auto &Fix : Diag->Fixes) { |
| 707 | + if (auto Rename = tryConvertToRename(Diag, Fix)) { |
711 | 708 | Result.Renames.emplace_back(std::move(*Rename)); |
712 | | - It++; |
| 709 | + } else { |
| 710 | + Result.QuickFixes.push_back({DiagRef, Fix}); |
713 | 711 | } |
714 | 712 | } |
715 | | - for (; It != Diag->Fixes.end(); It++) { |
716 | | - Result.QuickFixes.push_back({DiagRef, *It}); |
717 | | - } |
718 | | - } |
719 | 713 | } |
720 | 714 | } |
721 | 715 |
|
|
0 commit comments