mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
Java: fix false positive "Redundant suppression" on "CloneDoesntCallSuperClone" (IDEA-355945)
GitOrigin-RevId: a6a8dc2ace656f221b3de93ac17e522836baca51
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2d8b0ca142
commit
7cd75fdbe4
@@ -0,0 +1,10 @@
|
||||
// "Remove 'CloneDoesntCallSuperClone' suppression" "false"
|
||||
|
||||
class NoSuperCall {
|
||||
@SuppressWarnings("CloneDoesntCa<caret>llSuperClone")
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight.daemon.impl;
|
||||
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
@@ -285,11 +285,19 @@ class InspectionRunner {
|
||||
});
|
||||
}
|
||||
|
||||
private void registerSuppressedElements(@NotNull PsiElement element, @NotNull String id, @Nullable String alternativeID) {
|
||||
private void registerSuppressedElements(@NotNull PsiElement element, @NotNull LocalInspectionToolWrapper tool) {
|
||||
String id = tool.getID();
|
||||
mySuppressedElements.computeIfAbsent(id, __ -> new HashSet<>()).add(element);
|
||||
String alternativeID = tool.getAlternativeID();
|
||||
if (alternativeID != null && !alternativeID.equals(id)) {
|
||||
mySuppressedElements.computeIfAbsent(alternativeID, __ -> new HashSet<>()).add(element);
|
||||
}
|
||||
InspectionElementsMerger elementsMerger = InspectionElementsMerger.getMerger(tool.getShortName());
|
||||
if (elementsMerger != null) {
|
||||
for (String suppressId : elementsMerger.getSuppressIds()) {
|
||||
mySuppressedElements.computeIfAbsent(suppressId, __ -> new HashSet<>()).add(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addRedundantSuppressions(@NotNull List<? extends InspectionContext> init,
|
||||
@@ -304,7 +312,7 @@ class InspectionRunner {
|
||||
for (ProblemDescriptor descriptor : context.holder.getResults()) {
|
||||
PsiElement element = descriptor.getPsiElement();
|
||||
if (element != null && tool.isSuppressedFor(element)) {
|
||||
registerSuppressedElements(element, toolWrapper.getID(), toolWrapper.getAlternativeID());
|
||||
registerSuppressedElements(element, toolWrapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -466,7 +474,7 @@ class InspectionRunner {
|
||||
isSuppressedForHost = wrapper.getTool().isSuppressedFor(host);
|
||||
}
|
||||
if (isSuppressedForHost || descriptorPsiElement != null && wrapper.getTool().isSuppressedFor(descriptorPsiElement)) {
|
||||
registerSuppressedElements(host, wrapper.getID(), wrapper.getAlternativeID());
|
||||
registerSuppressedElements(host, wrapper);
|
||||
// remove descriptor at index i from applying
|
||||
descriptors = ContainerUtil.concat(descriptors.subList(0, i), descriptors.subList(i+1, descriptors.size()));
|
||||
if (LOG.isTraceEnabled()) {
|
||||
|
||||
Reference in New Issue
Block a user