nullable/notnull

This commit is contained in:
Max Medvedev
2012-10-16 16:59:15 +04:00
parent e493d358a0
commit f2928303c9
3 changed files with 14 additions and 9 deletions
@@ -296,7 +296,7 @@ public class ArrayUtil extends ArrayUtilRt {
* @return new array
*/
@NotNull
public static <T> T[] append(@NotNull final T[] src, final T element) {
public static <T> T[] append(@NotNull final T[] src, @Nullable final T element) {
return append(src, element, (Class<T>)src.getClass().getComponentType());
}
@@ -323,7 +323,7 @@ public class ArrayUtil extends ArrayUtilRt {
}
@NotNull
public static <T> T[] append(@NotNull T[] src, final T element, @NotNull Class<T> componentType) {
public static <T> T[] append(@NotNull T[] src, @Nullable final T element, @NotNull Class<T> componentType) {
int length = src.length;
T[] result = (T[])Array.newInstance(componentType, length + 1);
System.arraycopy(src, 0, result, 0, length);
@@ -906,9 +906,12 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
}
else {
final PsiClass outerClass = clazz.getContainingClass();
if (com.intellij.psi.util.PsiUtil.isInnerClass(clazz) && !PsiUtil.hasEnclosingInstanceInScope(outerClass, newExpression, true)) {
Annotation annotation =
myHolder.createErrorAnnotation(refElement, GroovyBundle.message("cannot.reference.nonstatic", clazz.getQualifiedName()));
if (com.intellij.psi.util.PsiUtil.isInnerClass(clazz) &&
outerClass != null &&
!PsiUtil.hasEnclosingInstanceInScope(outerClass, newExpression, true)) {
String qname = clazz.getQualifiedName();
LOG.assertTrue(qname != null, clazz.getText());
Annotation annotation = myHolder.createErrorAnnotation(refElement, GroovyBundle.message("cannot.reference.nonstatic", qname));
annotation.setTextAttributes(DefaultHighlighter.UNRESOLVED_ACCESS);
}
}
@@ -650,7 +650,7 @@ public class PsiUtil {
return null;
}
public static boolean mightBeLValue(GrExpression expr) {
public static boolean mightBeLValue(@Nullable GrExpression expr) {
if (expr instanceof GrParenthesizedExpression) return mightBeLValue(((GrParenthesizedExpression)expr).getOperand());
if (expr instanceof GrTupleExpression) return true;
@@ -785,7 +785,7 @@ public class PsiUtil {
return false;
}
public static boolean isRawType(PsiType type, PsiSubstitutor substitutor) {
public static boolean isRawType(@Nullable PsiType type, @NotNull PsiSubstitutor substitutor) {
if (type instanceof PsiClassType) {
final PsiClass returnClass = ((PsiClassType)type).resolve();
if (returnClass instanceof PsiTypeParameter) {
@@ -857,7 +857,7 @@ public class PsiUtil {
return expression instanceof GrReferenceExpression && methodName.equals(expression.getText().trim());
}
public static boolean hasEnclosingInstanceInScope(PsiClass clazz, PsiElement scope, boolean isSuperClassAccepted) {
public static boolean hasEnclosingInstanceInScope(@NotNull PsiClass clazz, @Nullable PsiElement scope, boolean isSuperClassAccepted) {
PsiElement place = scope;
while (place != null && place != clazz && !(place instanceof PsiFile)) {
if (place instanceof PsiClass) {
@@ -1091,7 +1091,9 @@ public class PsiUtil {
private static String[] visibilityModifiers = new String[]{PsiModifier.PRIVATE, PsiModifier.PROTECTED, PsiModifier.PUBLIC};
public static void escalateVisibility(PsiMember owner, PsiElement place) {
final String visibilityModifier = VisibilityUtil.getVisibilityModifier(owner.getModifierList());
PsiModifierList modifierList = owner.getModifierList();
LOG.assertTrue(modifierList != null);
final String visibilityModifier = VisibilityUtil.getVisibilityModifier(modifierList);
int index;
for (index = 0; index < visibilityModifiers.length; index++) {
String modifier = visibilityModifiers[index];