From 3ca71669d6dd51bc1f43dca4597a597c2d925235 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 31 May 2010 14:40:18 +0400 Subject: [PATCH] don't offer the callee of a call as a smart introduce variant (PY-1026) --- .../python/refactoring/introduce/IntroduceHandler.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/refactoring/introduce/IntroduceHandler.java b/python/src/com/jetbrains/python/refactoring/introduce/IntroduceHandler.java index 50120ac11604..3ee168f729c5 100644 --- a/python/src/com/jetbrains/python/refactoring/introduce/IntroduceHandler.java +++ b/python/src/com/jetbrains/python/refactoring/introduce/IntroduceHandler.java @@ -140,7 +140,7 @@ abstract public class IntroduceHandler implements RefactoringActionHandler { if (elementAtCaret instanceof PyStatement) { break; } - if (elementAtCaret instanceof PyExpression) { + if (elementAtCaret instanceof PyExpression && isValidIntroduceVariant(elementAtCaret)) { expressions.add((PyExpression)elementAtCaret); } elementAtCaret = elementAtCaret.getParent(); @@ -165,6 +165,14 @@ abstract public class IntroduceHandler implements RefactoringActionHandler { return false; } + private static boolean isValidIntroduceVariant(PsiElement element) { + final PyCallExpression call = PsiTreeUtil.getParentOfType(element, PyCallExpression.class); + if (call != null && PsiTreeUtil.isAncestor(call.getCallee(), element, false)) { + return false; + } + return true; + } + private void performActionOnElement(Editor editor, PsiElement element, String name,