mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 10:20:15 +07:00
[java-analysis] Use PsiUtil.getTypeByPsiElement where possible
GitOrigin-RevId: 0ac4f53d81d66a49202794c4300abfe3ebbbf042
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8795cc38d1
commit
f286fd9dba
@@ -163,7 +163,7 @@ public abstract class NullableNotNullManager {
|
||||
* @return effective nullability annotation info, or null if not found.
|
||||
*/
|
||||
public @Nullable NullabilityAnnotationInfo findEffectiveNullabilityInfo(@NotNull PsiModifierListOwner owner) {
|
||||
PsiType type = getOwnerType(owner);
|
||||
PsiType type = PsiUtil.getTypeByPsiElement(owner);
|
||||
if (type == null || TypeConversionUtil.isPrimitiveAndNotNull(type)) return null;
|
||||
|
||||
return CachedValuesManager.getCachedValue(owner, () -> CachedValueProvider.Result
|
||||
@@ -250,7 +250,7 @@ public abstract class NullableNotNullManager {
|
||||
PsiAnnotation annotation = findAnnotation(owner, annotations.qualifiedNames(), skipExternal);
|
||||
memberAnno = annotation == null ? null : new AnnotationAndOwner(owner, annotation);
|
||||
}
|
||||
PsiType type = getOwnerType(owner);
|
||||
PsiType type = PsiUtil.getTypeByPsiElement(owner);
|
||||
if (memberAnno != null && type instanceof PsiArrayType && !isInferredAnnotation(memberAnno.annotation) &&
|
||||
!isExternalAnnotation(memberAnno.annotation) && AnnotationTargetUtil.isTypeAnnotation(memberAnno.annotation)) {
|
||||
// Ambiguous TYPE_USE annotation on array type: we consider that it annotates an array component instead.
|
||||
@@ -306,12 +306,6 @@ public abstract class NullableNotNullManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static @Nullable PsiType getOwnerType(@NotNull PsiModifierListOwner owner) {
|
||||
if (owner instanceof PsiVariable) return ((PsiVariable)owner).getType();
|
||||
if (owner instanceof PsiMethod) return ((PsiMethod)owner).getReturnType();
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isNullable(@NotNull PsiModifierListOwner owner, boolean checkBases) {
|
||||
NullabilityAnnotationInfo info = findEffectiveNullabilityInfo(owner);
|
||||
return info != null && info.getNullability() == Nullability.NULLABLE && (checkBases || info.getInheritedFrom() == null);
|
||||
|
||||
Reference in New Issue
Block a user