mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
disable unused return value for @CanIgnoreReturnValue methods
IDEA-193647
This commit is contained in:
+9
@@ -16,6 +16,7 @@
|
||||
package com.intellij.codeInspection.unusedReturnValue;
|
||||
|
||||
import com.intellij.analysis.AnalysisScope;
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInsight.daemon.GroupNames;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.codeInspection.reference.*;
|
||||
@@ -30,6 +31,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
@@ -60,6 +62,7 @@ public class UnusedReturnValue extends GlobalJavaBatchInspectionTool{
|
||||
final boolean isNative = psiMethod.hasModifierProperty(PsiModifier.NATIVE);
|
||||
if (refMethod.isExternalOverride() && !isNative) return null;
|
||||
if (RefUtil.isImplicitRead(psiMethod)) return null;
|
||||
if (canIgnoreReturnValue(psiMethod)) return null;
|
||||
return new ProblemDescriptor[]{createProblemDescriptor(psiMethod, manager, processor, isNative)};
|
||||
}
|
||||
}
|
||||
@@ -67,6 +70,12 @@ public class UnusedReturnValue extends GlobalJavaBatchInspectionTool{
|
||||
return null;
|
||||
}
|
||||
|
||||
static boolean canIgnoreReturnValue(PsiMethod psiMethod) {
|
||||
return AnnotationUtil.isAnnotated(psiMethod,
|
||||
Collections.singleton("com.google.errorprone.annotations.CanIgnoreReturnValue"),
|
||||
AnnotationUtil.CHECK_HIERARCHY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSettings(@NotNull Element node) throws WriteExternalException {
|
||||
if (IGNORE_BUILDER_PATTERN) {
|
||||
|
||||
+1
@@ -52,6 +52,7 @@ public class UnusedReturnValueLocalInspection extends AbstractBaseJavaLocalInspe
|
||||
method.hasModifierProperty(PsiModifier.NATIVE) ||
|
||||
MethodUtils.hasSuper(method) ||
|
||||
RefUtil.isImplicitRead(method) ||
|
||||
UnusedReturnValue.canIgnoreReturnValue(method) ||
|
||||
UnusedDeclarationInspectionBase.isDeclaredAsEntryPoint(method)) return null;
|
||||
|
||||
final boolean[] atLeastOneUsageExists = new boolean[]{false};
|
||||
|
||||
Reference in New Issue
Block a user