From a5441cb403c46a5064fdb404555d7563e3de8cbb Mon Sep 17 00:00:00 2001 From: Oleg Shpynov Date: Tue, 9 Feb 2010 18:24:41 +0300 Subject: [PATCH] PY-509 Extract Method wants to pass a class as a method parameter --- .../codeInsight/codeFragment/PyCodeFragmentBuilder.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/codeInsight/codeFragment/PyCodeFragmentBuilder.java b/python/src/com/jetbrains/python/codeInsight/codeFragment/PyCodeFragmentBuilder.java index 4ded0747bb0b..356551fd3180 100644 --- a/python/src/com/jetbrains/python/codeInsight/codeFragment/PyCodeFragmentBuilder.java +++ b/python/src/com/jetbrains/python/codeInsight/codeFragment/PyCodeFragmentBuilder.java @@ -74,9 +74,12 @@ public class PyCodeFragmentBuilder extends PyRecursiveElementVisitor { if (position == Position.INSIDE) { for (ResolveResult result : element.multiResolve(false)) { final PsiElement declaration = result.getElement(); - if (declaration == null || !PsiTreeUtil.isAncestor(myOwner, declaration, false)){ + // Ignore outer elements or import statements + if (declaration == null || !PsiTreeUtil.isAncestor(myOwner, declaration, false) || + declaration instanceof PyImportElement){ continue; } + final Position pos = CodeFragmentUtil.getPosition(declaration, startOffset, endOffset); // If declaration is before add it to input if (pos == Position.BEFORE) {