mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJ-CR-188329 [java-inspections] IDEA-377682 JSpecify. Nullable incompatibilities. Calls with generics
- delete unused filters - simplify switch expression GitOrigin-RevId: 994435ac31851461cbb2b51144b734dd7a0b2c34
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6c34dc653c
commit
ccc1e2f2d7
+8
-10
@@ -557,16 +557,14 @@ public class NullableStuffInspectionBase extends AbstractBaseJavaLocalInspection
|
||||
context = JavaTypeNullabilityUtil.getNullabilityConflictInAssignment(expectedType, actualType,
|
||||
REPORT_NOT_NULL_TO_NULLABLE_CONFLICTS_IN_ASSIGNMENTS);
|
||||
JavaTypeNullabilityUtil.NullabilityConflict conflict = context.nullabilityConflict();
|
||||
String messageKey;
|
||||
switch (conflict) {
|
||||
case UNKNOWN -> {
|
||||
return false;
|
||||
}
|
||||
case NOT_NULL_TO_NULL -> messageKey = problem.notNullToNullProblem();
|
||||
case NULL_TO_NOT_NULL -> messageKey = problem.nullToNotNullProblem();
|
||||
case COMPLEX -> messageKey = problem.complexProblem();
|
||||
default -> throw new IllegalStateException("Unexpected value: " + conflict);
|
||||
}
|
||||
String messageKey = switch (conflict) {
|
||||
case UNKNOWN -> null;
|
||||
case NOT_NULL_TO_NULL -> problem.notNullToNullProblem();
|
||||
case NULL_TO_NOT_NULL -> problem.nullToNotNullProblem();
|
||||
case COMPLEX -> problem.complexProblem();
|
||||
};
|
||||
|
||||
if (messageKey == null) return false;
|
||||
|
||||
reportProblem(holder, errorElement, LocalQuickFix.EMPTY_ARRAY,
|
||||
messageKey, new Object[]{""},
|
||||
|
||||
-50
@@ -392,56 +392,6 @@ public class JSpecifyFilteredAnnotationTest extends LightJavaCodeInsightFixtureT
|
||||
}
|
||||
}
|
||||
|
||||
private static class CallWithParameterWithNestedGenericsFilter implements ErrorFilter {
|
||||
|
||||
@Override
|
||||
public boolean filterActual(@NotNull PsiFile file,
|
||||
@NotNull String strippedText,
|
||||
int lineNumber,
|
||||
int startLineOffset,
|
||||
@NotNull String errorMessage) {
|
||||
if (!errorMessage.contains("jspecify_nullness_mismatch")) return false;
|
||||
PsiElement element = findElement(file, strippedText, lineNumber, startLineOffset);
|
||||
PsiExpressionStatement statement = PsiTreeUtil.getParentOfType(element, PsiExpressionStatement.class, true);
|
||||
if (statement == null) return false;
|
||||
PsiExpression expression = statement.getExpression();
|
||||
if (!(expression instanceof PsiCallExpression callExpression)) return false;
|
||||
PsiMethod method = callExpression.resolveMethod();
|
||||
if (method == null) return false;
|
||||
return ContainerUtil.exists(method.getParameterList().getParameters(),
|
||||
parameter -> parameter.getType() instanceof PsiClassType classType && classType.hasParameters());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean filterExpected(@NotNull PsiElement psiElement, @NotNull String errorMessage) {
|
||||
//filter only actual file
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static class VariableWithNestedGenericsFilter implements ErrorFilter {
|
||||
|
||||
@Override
|
||||
public boolean filterActual(@NotNull PsiFile file,
|
||||
@NotNull String strippedText,
|
||||
int lineNumber,
|
||||
int startLineOffset,
|
||||
@NotNull String errorMessage) {
|
||||
if (!errorMessage.contains("jspecify_nullness_mismatch")) return false;
|
||||
PsiElement element = findElement(file, strippedText, lineNumber, startLineOffset);
|
||||
PsiVariable variable = PsiTreeUtil.getParentOfType(element, PsiVariable.class, true);
|
||||
if (variable == null) return false;
|
||||
return variable.getType() instanceof PsiClassType classType && classType.hasParameters();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean filterExpected(@NotNull PsiElement psiElement, @NotNull String errorMessage) {
|
||||
//filter only actual file
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class SkipIndividuallyFilter implements ErrorFilter {
|
||||
private final Set<Pair<String, Integer>> places;
|
||||
private final Set<Pair<String, Integer>> unusedPlaces;
|
||||
|
||||
Reference in New Issue
Block a user