From 13a800ec863973ecf12225b2bcff63d1bfcee4b0 Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Fri, 3 Feb 2012 16:59:18 +0400 Subject: [PATCH] @Nullable annotations --- python/src/com/jetbrains/python/psi/PyFunction.java | 1 + .../src/com/jetbrains/python/psi/impl/PyFunctionImpl.java | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/psi/PyFunction.java b/python/src/com/jetbrains/python/psi/PyFunction.java index 51512d11faae..2e7ddefce097 100644 --- a/python/src/com/jetbrains/python/psi/PyFunction.java +++ b/python/src/com/jetbrains/python/psi/PyFunction.java @@ -61,6 +61,7 @@ extends * * @return the deprecation message or null if the function is not deprecated. */ + @Nullable String getDeprecationMessage(); /** diff --git a/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java b/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java index 399b4d82d2d6..6a7fba37b020 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java @@ -77,7 +77,10 @@ public class PyFunctionImpl extends PyPresentableElementImpl imp public PsiElement setName(@NotNull String name) throws IncorrectOperationException { final ASTNode nameElement = PyElementGenerator.getInstance(getProject()).createNameIdentifier(name); - getNode().replaceChild(getNameNode(), nameElement); + final ASTNode nameNode = getNameNode(); + if (nameNode != null) { + getNode().replaceChild(nameNode, nameElement); + } return this; } @@ -281,6 +284,7 @@ public class PyFunctionImpl extends PyPresentableElementImpl imp return PyTypeParser.getTypeByName(this, typeName); } + @Nullable @Override public String getDeprecationMessage() { PyFunctionStub stub = getStub(); @@ -290,6 +294,7 @@ public class PyFunctionImpl extends PyPresentableElementImpl imp return extractDeprecationMessage(); } + @Nullable public String extractDeprecationMessage() { PyStatementList statementList = getStatementList(); if (statementList == null) { @@ -298,6 +303,7 @@ public class PyFunctionImpl extends PyPresentableElementImpl imp return extractDeprecationMessage(Arrays.asList(statementList.getStatements())); } + @Nullable public static String extractDeprecationMessage(List statements) { for (PyStatement statement : statements) { if (statement instanceof PyExpressionStatement) {