From 8d3bdf1373f2f625a761bc3381d29784a5419cea Mon Sep 17 00:00:00 2001 From: Roland Grunberg Date: Thu, 16 Jan 2025 09:28:48 -0500 Subject: [PATCH] Avoid duplicate suppress warning suggestions through new API method. - Implement alreadyHasProposal to avoid duplicates Signed-off-by: Roland Grunberg --- .../corrections/SuppressWarningsSubProcessor.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/corrections/SuppressWarningsSubProcessor.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/corrections/SuppressWarningsSubProcessor.java index 42da67747c..f091e0311c 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/corrections/SuppressWarningsSubProcessor.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/corrections/SuppressWarningsSubProcessor.java @@ -60,4 +60,14 @@ protected ProposalKindWrapper createFixCorrectionProposal(IProposableFix fix, IC return CodeActionHandler.wrap(proposal, CodeActionKind.QuickFix); } + @Override + protected boolean alreadyHasProposal(Collection proposals, String warningToken) { + for (ProposalKindWrapper element : proposals) { + if (element.getProposal() instanceof SuppressWarningsProposalCore swp && warningToken.equals(swp.getWarningToken())) { + return true; // only one at a time + } + } + return false; + } + }