mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
NPE protection for IDEA-117277, but actual NPE already fixed by Anna
This commit is contained in:
+4
-4
@@ -128,10 +128,7 @@ public class UnnecessaryExplicitNumericCastInspection extends BaseInspection {
|
||||
return;
|
||||
}
|
||||
final PsiType operandType = operand.getType();
|
||||
if (operandType == null || operandType.equals(castType)) {
|
||||
return;
|
||||
}
|
||||
if (isPrimitiveNumericCastNecessary(expression)) {
|
||||
if (castType.equals(operandType) || isPrimitiveNumericCastNecessary(expression)) {
|
||||
return;
|
||||
}
|
||||
final PsiTypeElement typeElement = expression.getCastType();
|
||||
@@ -151,6 +148,9 @@ public class UnnecessaryExplicitNumericCastInspection extends BaseInspection {
|
||||
return true;
|
||||
}
|
||||
final PsiType operandType = operand.getType();
|
||||
if (operandType == null) {
|
||||
return true;
|
||||
}
|
||||
PsiElement parent = expression.getParent();
|
||||
while (parent instanceof PsiParenthesizedExpression) {
|
||||
parent = parent.getParent();
|
||||
|
||||
+4
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2013 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package com.siyeh.ig.psiutils;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -148,7 +149,8 @@ public class ClassUtils {
|
||||
return inSamePackage(fieldClass, fromClass);
|
||||
}
|
||||
|
||||
public static boolean isPrimitiveNumericType(PsiType type) {
|
||||
@Contract("null -> false")
|
||||
public static boolean isPrimitiveNumericType(@Nullable PsiType type) {
|
||||
return primitiveNumericTypes.contains(type);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ public class TypeUtils {
|
||||
return getType(CommonClassNames.JAVA_LANG_STRING, context);
|
||||
}
|
||||
|
||||
public static boolean isNarrowingConversion(PsiType operandType, PsiType castType) {
|
||||
public static boolean isNarrowingConversion(@NotNull PsiType operandType, @NotNull PsiType castType) {
|
||||
final Integer operandPrecision = typePrecisions.get(operandType);
|
||||
final Integer castPrecision = typePrecisions.get(castType);
|
||||
return operandPrecision.intValue() > castPrecision.intValue();
|
||||
|
||||
+4
@@ -63,4 +63,8 @@ public class UnnecessaryExplicitNumericCast {
|
||||
int i() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
boolean redundantTypeCast(long l) {
|
||||
return 0L == (long)l;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user