Add nullability annotations

This commit is contained in:
Alexey Sedunov
2013-04-30 16:52:32 +04:00
parent d2f3dd1629
commit 4ab816a888
@@ -158,13 +158,14 @@ public class JetPsiUtil {
}
}
public static FqName getFQName(JetFile file) {
@NotNull
public static FqName getFQName(@NotNull JetFile file) {
JetNamespaceHeader header = file.getNamespaceHeader();
return header != null ? header.getFqName() : FqName.ROOT;
}
@Nullable
public static FqName getFQName(JetNamedDeclaration namedDeclaration) {
public static FqName getFQName(@NotNull JetNamedDeclaration namedDeclaration) {
if (namedDeclaration instanceof JetObjectDeclarationName) {
JetNamedDeclaration objectDeclaration = PsiTreeUtil.getParentOfType(namedDeclaration, JetObjectDeclaration.class);
if (objectDeclaration == null) {
@@ -233,7 +234,7 @@ public class JetPsiUtil {
}
@Nullable
public static Name getShortName(JetAnnotationEntry annotation) {
public static Name getShortName(@NotNull JetAnnotationEntry annotation) {
JetTypeReference typeReference = annotation.getTypeReference();
assert typeReference != null : "Annotation entry hasn't typeReference " + annotation.getText();
JetTypeElement typeElement = typeReference.getTypeElement();
@@ -247,7 +248,7 @@ public class JetPsiUtil {
return null;
}
public static boolean isDeprecated(JetModifierListOwner owner) {
public static boolean isDeprecated(@NotNull JetModifierListOwner owner) {
JetModifierList modifierList = owner.getModifierList();
if (modifierList != null) {
List<JetAnnotationEntry> annotationEntries = modifierList.getAnnotationEntries();
@@ -263,7 +264,7 @@ public class JetPsiUtil {
@Nullable
@IfNotParsed
public static ImportPath getImportPath(JetImportDirective importDirective) {
public static ImportPath getImportPath(@NotNull JetImportDirective importDirective) {
if (PsiTreeUtil.hasErrorElements(importDirective)) {
return null;
}
@@ -410,7 +411,7 @@ public class JetPsiUtil {
return callOperationNode != null && callOperationNode.getElementType() == JetTokens.SAFE_ACCESS;
}
public static boolean isFunctionLiteralWithoutDeclaredParameterTypes(JetExpression expression) {
public static boolean isFunctionLiteralWithoutDeclaredParameterTypes(@Nullable JetExpression expression) {
if (!(expression instanceof JetFunctionLiteralExpression)) return false;
JetFunctionLiteralExpression functionLiteral = (JetFunctionLiteralExpression) expression;
for (JetParameter parameter : functionLiteral.getValueParameters()) {
@@ -462,6 +463,7 @@ public class JetPsiUtil {
return null;
}
@Nullable
public static PsiElement getTopmostParentOfTypes(@Nullable PsiElement element, @NotNull Class<? extends PsiElement>... parentTypes) {
if (element == null) {
return null;
@@ -568,6 +570,7 @@ public class JetPsiUtil {
}
}
@Nullable
private static IElementType getOperation(@NotNull JetExpression expression) {
if (expression instanceof JetQualifiedExpression) {
return ((JetQualifiedExpression) expression).getOperationSign();
@@ -683,6 +686,7 @@ public class JetPsiUtil {
return false;
}
@NotNull
public static <C extends Collection<JetVariableDeclaration>> C getBlockVariableDeclarations(@NotNull JetBlockExpression block, @NotNull C collection) {
for (JetElement element : block.getStatements()) {
if (element instanceof JetVariableDeclaration) {
@@ -693,7 +697,7 @@ public class JetPsiUtil {
return collection;
}
public static boolean checkWhenExpressionHasSingleElse(JetWhenExpression whenExpression) {
public static boolean checkWhenExpressionHasSingleElse(@NotNull JetWhenExpression whenExpression) {
int elseCount = 0;
for (JetWhenEntry entry : whenExpression.getEntries()) {
if (entry.isElse()) {
@@ -703,7 +707,8 @@ public class JetPsiUtil {
return (elseCount == 1);
}
public static PsiElement skipTrailingWhitespacesAndComments(PsiElement element) {
@Nullable
public static PsiElement skipTrailingWhitespacesAndComments(@Nullable PsiElement element) {
return PsiTreeUtil.skipSiblingsForward(element, PsiWhiteSpace.class, PsiComment.class);
}