@Nullable

This commit is contained in:
Roman Shevchenko
2012-10-19 22:41:40 +02:00
parent 1576ff1b3b
commit 5f55338962
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,6 @@ import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.HashSet;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -47,6 +46,7 @@ import java.util.Set;
public class AnnotationsHighlightUtil {
private static final Logger LOG = Logger.getInstance("com.intellij.codeInsight.daemon.impl.analysis.AnnotationsHighlightUtil");
@Nullable
public static HighlightInfo checkNameValuePair(PsiNameValuePair pair) {
PsiReference ref = pair.getReference();
if (ref == null) return null;
@@ -142,6 +142,7 @@ public class AnnotationsHighlightUtil {
return null;
}
@Nullable
public static HighlightInfo checkDuplicateAnnotations(PsiAnnotation annotationToCheck) {
PsiAnnotationOwner owner = annotationToCheck.getOwner();
if (owner == null) {
@@ -225,6 +226,7 @@ public class AnnotationsHighlightUtil {
return null;
}
@Nullable
public static HighlightInfo checkValidAnnotationType(final PsiTypeElement typeElement) {
PsiType type = typeElement.getType();
if (type.accept(AnnotationReturnTypeVisitor.INSTANCE).booleanValue()) {
@@ -233,6 +235,7 @@ public class AnnotationsHighlightUtil {
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, typeElement, JavaErrorMessages.message("annotation.invalid.annotation.member.type"));
}
@Nullable
public static HighlightInfo checkApplicability(final PsiAnnotation annotation) {
PsiAnnotationOwner owner = annotation.getOwner();
if (!(owner instanceof PsiModifierList || owner instanceof PsiTypeElement || owner instanceof PsiMethodReceiver || owner instanceof PsiTypeParameter)) return null;
@@ -280,17 +283,7 @@ public class AnnotationsHighlightUtil {
return infos[0];
}
private static PsiField[] getFields(final PsiClass elementTypeClass, @NonNls final String... names) {
PsiField[] result = new PsiField[names.length];
for (int i = 0; i < names.length; i++) {
final PsiField field = elementTypeClass.findFieldByName(names[i], false);
if (field == null) return null;
result[i] = field;
}
return result;
}
@Nullable
public static HighlightInfo checkAnnotationType(PsiAnnotation annotation) {
PsiJavaCodeReferenceElement nameReferenceElement = annotation.getNameReferenceElement();
if (nameReferenceElement != null) {
@@ -302,6 +295,7 @@ public class AnnotationsHighlightUtil {
return null;
}
@Nullable
public static HighlightInfo checkCyclicMemberType(PsiTypeElement typeElement, PsiClass aClass) {
LOG.assertTrue(aClass.isAnnotationType());
PsiType type = typeElement.getType();
@@ -311,6 +305,7 @@ public class AnnotationsHighlightUtil {
return null;
}
@Nullable
public static HighlightInfo checkAnnotationDeclaration(final PsiElement parent, final PsiReferenceList list) {
if (PsiUtil.isAnnotationMethod(parent)) {
PsiAnnotationMethod method = (PsiAnnotationMethod)parent;
@@ -327,6 +322,7 @@ public class AnnotationsHighlightUtil {
}
@Nullable
public static HighlightInfo checkPackageAnnotationContainingFile(final PsiPackageStatement statement) {
if (statement.getAnnotationList() == null) {
return null;
@@ -341,6 +337,7 @@ public class AnnotationsHighlightUtil {
return null;
}
@Nullable
public static HighlightInfo checkTargetAnnotationDuplicates(PsiAnnotation annotation) {
PsiJavaCodeReferenceElement nameRef = annotation.getNameReferenceElement();
if (nameRef == null) return null;