diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java index 2d130fa4faa..cb9fa86166f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java @@ -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 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... 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 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); }