From 8473dbb7846477f437b31033085309b7b1734e12 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Thu, 6 Sep 2012 11:22:19 -0400 Subject: [PATCH] fixed unused code (produced NPE) and tests --- .../intentions/SpecifyTypeInDocstringIntention.java | 5 ++--- python/testData/intentions/afterTypeInPy3Annotation.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInDocstringIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInDocstringIntention.java index 54a20eeceb26..3b2b9a71442f 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInDocstringIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInDocstringIntention.java @@ -49,9 +49,8 @@ public class SpecifyTypeInDocstringIntention implements IntentionAction { } public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { - PsiElement elementAt = file.findElementAt(editor.getCaretModel().getOffset() - 1); - if (elementAt != null && elementAt.getNode() != null && !(elementAt.getNode().getElementType() == PyTokenTypes.IDENTIFIER)) - elementAt = file.findElementAt(editor.getCaretModel().getOffset()); + myText = PyBundle.message("INTN.specify.type"); + PsiElement elementAt = PyUtil.findNonWhitespaceAtOffset(file, editor.getCaretModel().getOffset()); PyCallExpression callExpression = PsiTreeUtil.getParentOfType(elementAt, PyCallExpression.class); if (callExpression != null && callExpression.resolveCalleeFunction(PyResolveContext.defaultContext()) != null) { diff --git a/python/testData/intentions/afterTypeInPy3Annotation.py b/python/testData/intentions/afterTypeInPy3Annotation.py index 53a85344911b..3dca05f293e4 100644 --- a/python/testData/intentions/afterTypeInPy3Annotation.py +++ b/python/testData/intentions/afterTypeInPy3Annotation.py @@ -1,3 +1,3 @@ -def foo(a: object, b): +def foo(a : object, b): a. b = 1 \ No newline at end of file