diff --git a/python/src/META-INF/python-plugin-common.xml b/python/src/META-INF/python-plugin-common.xml index eb6cdba56fa9..2dccb8ef8349 100644 --- a/python/src/META-INF/python-plugin-common.xml +++ b/python/src/META-INF/python-plugin-common.xml @@ -224,6 +224,8 @@ + + diff --git a/python/src/com/jetbrains/python/codeInsight/PyDunderAllReference.java b/python/src/com/jetbrains/python/codeInsight/PyDunderAllReference.java new file mode 100644 index 000000000000..76b59b4ade92 --- /dev/null +++ b/python/src/com/jetbrains/python/codeInsight/PyDunderAllReference.java @@ -0,0 +1,38 @@ +package com.jetbrains.python.codeInsight; + +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiReferenceBase; +import com.intellij.util.ArrayUtil; +import com.jetbrains.python.psi.PyFile; +import com.jetbrains.python.psi.PyStringLiteralExpression; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * @author yole + */ +public class PyDunderAllReference extends PsiReferenceBase { + public PyDunderAllReference(@NotNull PyStringLiteralExpression element) { + super(element); + final List ranges = element.getStringValueTextRanges(); + if (ranges.size() > 0) { + setRangeInElement(ranges.get(0)); + } + } + + @Override + public PsiElement resolve() { + final PyStringLiteralExpression element = getElement(); + final String name = element.getStringValue(); + PyFile containingFile = (PyFile) element.getContainingFile(); + return containingFile.getElementNamed(name); + } + + @NotNull + @Override + public Object[] getVariants() { + return ArrayUtil.EMPTY_OBJECT_ARRAY; + } +} diff --git a/python/src/com/jetbrains/python/codeInsight/PyDunderAllReferenceProvider.java b/python/src/com/jetbrains/python/codeInsight/PyDunderAllReferenceProvider.java new file mode 100644 index 000000000000..e6394e22e3d8 --- /dev/null +++ b/python/src/com/jetbrains/python/codeInsight/PyDunderAllReferenceProvider.java @@ -0,0 +1,19 @@ +package com.jetbrains.python.codeInsight; + +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiReference; +import com.intellij.psi.PsiReferenceProvider; +import com.intellij.util.ProcessingContext; +import com.jetbrains.python.psi.PyStringLiteralExpression; +import org.jetbrains.annotations.NotNull; + +/** + * @author yole + */ +public class PyDunderAllReferenceProvider extends PsiReferenceProvider { + @NotNull + @Override + public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { + return new PsiReference[] { new PyDunderAllReference((PyStringLiteralExpression) element) }; + } +} diff --git a/python/src/com/jetbrains/python/codeInsight/PyKeywordCompletionContributor.java b/python/src/com/jetbrains/python/codeInsight/PyKeywordCompletionContributor.java index 5f83b9bf8f5c..b463b3df1479 100644 --- a/python/src/com/jetbrains/python/codeInsight/PyKeywordCompletionContributor.java +++ b/python/src/com/jetbrains/python/codeInsight/PyKeywordCompletionContributor.java @@ -6,6 +6,7 @@ import com.intellij.codeInsight.lookup.TailTypeDecorator; import com.intellij.lang.ASTNode; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; +import com.intellij.patterns.ElementPattern; import com.intellij.patterns.PsiElementPattern; import com.intellij.patterns.StandardPatterns; import com.intellij.psi.*; @@ -608,17 +609,13 @@ public class PyKeywordCompletionContributor extends PySeeingOriginalCompletionCo ); } - // FIXME: conditions must be severely reworked - private void addExprElse() { extend( CompletionType.BASIC, psiElement() .withLanguage(PythonLanguage.getInstance()) - .and(INSIDE_EXPR_AFTER_IF) - .andNot(IN_IMPORT_STMT) // expressions there are not logical anyway - //.andNot(IN_PARAM_LIST) - .andNot(IN_DEFINITION) - .andNot(AFTER_QUALIFIER) + .afterLeafSkipping(psiElement().whitespace(), + psiElement().inside(psiElement(PyConditionalExpression.class)) + .and(psiElement().afterLeaf("if"))) , new CompletionProvider() { protected void addCompletions(@NotNull final CompletionParameters parameters, @@ -647,7 +644,7 @@ public class PyKeywordCompletionContributor extends PySeeingOriginalCompletionCo addImportInFrom(); addPy3kLiterals(); //addExprIf(); - //addExprElse(); + addExprElse(); } private static class PyKeywordCompletionProvider extends CompletionProvider { diff --git a/python/src/com/jetbrains/python/codeInsight/PyStdReferenceContributor.java b/python/src/com/jetbrains/python/codeInsight/PyStdReferenceContributor.java new file mode 100644 index 000000000000..8693b4721187 --- /dev/null +++ b/python/src/com/jetbrains/python/codeInsight/PyStdReferenceContributor.java @@ -0,0 +1,23 @@ +package com.jetbrains.python.codeInsight; + +import com.intellij.psi.PsiReferenceContributor; +import com.intellij.psi.PsiReferenceRegistrar; +import com.jetbrains.python.PyNames; +import com.jetbrains.python.psi.PyAssignmentStatement; +import com.jetbrains.python.psi.PyStringLiteralExpression; +import com.jetbrains.python.psi.PyTargetExpression; + +import static com.intellij.patterns.PlatformPatterns.psiElement; + +/** + * @author yole + */ +public class PyStdReferenceContributor extends PsiReferenceContributor { + @Override + public void registerReferenceProviders(PsiReferenceRegistrar registrar) { + registrar.registerReferenceProvider(psiElement(PyStringLiteralExpression.class).inside( + psiElement(PyAssignmentStatement.class).withFirstChild( + psiElement(PyTargetExpression.class).withName(PyNames.ALL))), + new PyDunderAllReferenceProvider()); + } +} diff --git a/python/src/com/jetbrains/python/codeInsight/PySuperMethodCompletionContributor.java b/python/src/com/jetbrains/python/codeInsight/PySuperMethodCompletionContributor.java new file mode 100644 index 000000000000..7e1812eefaaa --- /dev/null +++ b/python/src/com/jetbrains/python/codeInsight/PySuperMethodCompletionContributor.java @@ -0,0 +1,55 @@ +package com.jetbrains.python.codeInsight; + +import com.intellij.codeInsight.completion.*; +import com.intellij.codeInsight.lookup.LookupElementBuilder; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiWhiteSpace; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.util.ProcessingContext; +import com.jetbrains.python.PyTokenTypes; +import com.jetbrains.python.psi.PyClass; +import com.jetbrains.python.psi.PyFunction; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +import static com.intellij.patterns.PlatformPatterns.psiElement; + +/** + * @author yole + */ +public class PySuperMethodCompletionContributor extends CompletionContributor { + public PySuperMethodCompletionContributor() { + extend(CompletionType.BASIC, + psiElement().afterLeafSkipping(psiElement().whitespace(), psiElement().withElementType(PyTokenTypes.DEF_KEYWORD)), + new CompletionProvider() { + @Override + protected void addCompletions(@NotNull CompletionParameters parameters, + ProcessingContext context, + @NotNull CompletionResultSet result) { + PsiElement position = parameters.getOriginalPosition(); + PyClass containingClass = PsiTreeUtil.getParentOfType(position, PyClass.class); + if (containingClass == null && position instanceof PsiWhiteSpace) { + position = PsiTreeUtil.prevLeaf(position); + containingClass = PsiTreeUtil.getParentOfType(position, PyClass.class); + } + if (containingClass == null) { + return; + } + List seenNames = new ArrayList(); + for (PyFunction function : containingClass.getMethods()) { + seenNames.add(function.getName()); + } + for (PyClass ancestor : containingClass.iterateAncestors()) { + for (PyFunction superMethod : ancestor.getMethods()) { + if (!seenNames.contains(superMethod.getName())) { + result.addElement(LookupElementBuilder.create(superMethod.getName() + superMethod.getParameterList().getText() + ":")); + seenNames.add(superMethod.getName()); + } + } + } + } + }); + } +} diff --git a/python/src/com/jetbrains/python/findUsages/PythonFindUsagesProvider.java b/python/src/com/jetbrains/python/findUsages/PythonFindUsagesProvider.java index 1a9de3e17fa5..ae4f7dc6c3bd 100644 --- a/python/src/com/jetbrains/python/findUsages/PythonFindUsagesProvider.java +++ b/python/src/com/jetbrains/python/findUsages/PythonFindUsagesProvider.java @@ -39,7 +39,14 @@ public class PythonFindUsagesProvider implements FindUsagesProvider { return "function"; } if (element instanceof PyClass) return "class"; - if (element instanceof PyReferenceExpression || element instanceof PyTargetExpression) return "variable"; + if (element instanceof PyReferenceExpression) return "variable"; + if (element instanceof PyTargetExpression) { + final PyImportElement importElement = PsiTreeUtil.getParentOfType(element, PyImportElement.class); + if (importElement != null && importElement.getAsNameElement() == element) { + return "imported module alias"; + } + return "variable"; + } return ""; } diff --git a/python/src/com/jetbrains/python/psi/PyAnnotation.java b/python/src/com/jetbrains/python/psi/PyAnnotation.java index 5b4adccfb135..7d51bb73e9e1 100644 --- a/python/src/com/jetbrains/python/psi/PyAnnotation.java +++ b/python/src/com/jetbrains/python/psi/PyAnnotation.java @@ -1,7 +1,13 @@ package com.jetbrains.python.psi; +import org.jetbrains.annotations.Nullable; + /** * @author yole */ public interface PyAnnotation extends PyElement { + PyExpression getValue(); + + @Nullable + PyClass resolveToClass(); } diff --git a/python/src/com/jetbrains/python/psi/PyFunction.java b/python/src/com/jetbrains/python/psi/PyFunction.java index 7d75ffe59e50..a6dc2c95013a 100644 --- a/python/src/com/jetbrains/python/psi/PyFunction.java +++ b/python/src/com/jetbrains/python/psi/PyFunction.java @@ -73,4 +73,7 @@ extends */ @Nullable Property getProperty(); + + @Nullable + PyAnnotation getAnnotation(); } diff --git a/python/src/com/jetbrains/python/psi/PyNamedParameter.java b/python/src/com/jetbrains/python/psi/PyNamedParameter.java index 0e74c042ab43..bf18b9bbebe9 100644 --- a/python/src/com/jetbrains/python/psi/PyNamedParameter.java +++ b/python/src/com/jetbrains/python/psi/PyNamedParameter.java @@ -5,6 +5,7 @@ import com.intellij.psi.PsiNamedElement; import com.intellij.psi.StubBasedPsiElement; import com.jetbrains.python.psi.stubs.PyNamedParameterStub; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a named parameter, as opposed to a tuple parameter. @@ -20,5 +21,8 @@ public interface PyNamedParameter extends PyParameter, PsiNamedElement, PsiNameI */ @NotNull String getRepr(boolean includeDefaultValue); + + @Nullable + PyAnnotation getAnnotation(); } diff --git a/python/src/com/jetbrains/python/psi/impl/PyAnnotationImpl.java b/python/src/com/jetbrains/python/psi/impl/PyAnnotationImpl.java index 956ce5baa4f3..5dc05dc01a68 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyAnnotationImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyAnnotationImpl.java @@ -1,7 +1,12 @@ package com.jetbrains.python.psi.impl; import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiPolyVariantReference; import com.jetbrains.python.psi.PyAnnotation; +import com.jetbrains.python.psi.PyClass; +import com.jetbrains.python.psi.PyExpression; +import com.jetbrains.python.psi.PyReferenceExpression; /** * @author yole @@ -10,4 +15,22 @@ public class PyAnnotationImpl extends PyElementImpl implements PyAnnotation { public PyAnnotationImpl(ASTNode astNode) { super(astNode); } + + @Override + public PyExpression getValue() { + return findChildByClass(PyExpression.class); + } + + @Override + public PyClass resolveToClass() { + PyExpression expr = getValue(); + if (expr instanceof PyReferenceExpression) { + final PsiPolyVariantReference reference = ((PyReferenceExpression)expr).getReference(); + final PsiElement result = reference.resolve(); + if (result instanceof PyClass) { + return (PyClass) result; + } + } + return null; + } } diff --git a/python/src/com/jetbrains/python/psi/impl/PyElementGeneratorImpl.java b/python/src/com/jetbrains/python/psi/impl/PyElementGeneratorImpl.java index 4edd972cad29..6af5421c44b0 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyElementGeneratorImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyElementGeneratorImpl.java @@ -198,7 +198,11 @@ public class PyElementGeneratorImpl extends PyElementGenerator { public PyCallExpression createCallExpression(String functionName) { final PsiFile dummyFile = createDummyFile(LanguageLevel.getDefault(), functionName + "()"); - return (PyCallExpression)dummyFile.getFirstChild().getFirstChild(); + final PsiElement element = dummyFile.getFirstChild().getFirstChild(); + if (!(element instanceof PyCallExpression)) { + throw new IllegalArgumentException("Invalid call expression text " + functionName); + } + return (PyCallExpression)element; } public PyImportStatement createImportStatementFromText(final String text) { diff --git a/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java b/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java index 2dba7065dbc6..1cdb8a388f42 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java @@ -118,6 +118,14 @@ public class PyFunctionImpl extends PyPresentableElementImpl imp @Nullable public PyType getReturnType(TypeEvalContext typeEvalContext, @Nullable PyReferenceExpression callSite) { + PyAnnotation anno = getAnnotation(); + if (anno != null) { + PyClass pyClass = anno.resolveToClass(); + if (pyClass != null) { + return new PyClassType(pyClass, false); + } + } + for(PyTypeProvider typeProvider: Extensions.getExtensions(PyTypeProvider.EP_NAME)) { final PyType returnType = typeProvider.getReturnType(this, callSite, typeEvalContext); if (returnType != null) { @@ -382,4 +390,9 @@ public class PyFunctionImpl extends PyPresentableElementImpl imp } return null; } + + @Override + public PyAnnotation getAnnotation() { + return findChildByClass(PyAnnotation.class); + } } diff --git a/python/src/com/jetbrains/python/psi/impl/PyNamedParameterImpl.java b/python/src/com/jetbrains/python/psi/impl/PyNamedParameterImpl.java index 275fa2a642cc..e88e976dc5aa 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyNamedParameterImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyNamedParameterImpl.java @@ -3,6 +3,7 @@ package com.jetbrains.python.psi.impl; import com.intellij.lang.ASTNode; import com.intellij.openapi.extensions.Extensions; import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiPolyVariantReference; import com.intellij.psi.search.LocalSearchScope; import com.intellij.psi.search.SearchScope; import com.intellij.psi.util.PsiTreeUtil; @@ -120,6 +121,11 @@ public class PyNamedParameterImpl extends PyPresentableElementImpl nodeFilter, final Condition nameFilter) { + public VariantsProcessor(PsiElement context, @Nullable final Condition nodeFilter, @Nullable final Condition nameFilter) { myContext = context; myNodeFilter = nodeFilter; myNameFilter = nameFilter; @@ -60,6 +60,7 @@ public class VariantsProcessor implements PsiScopeProcessor { if (item.getObject() instanceof PyFunction && ((PyFunction) item.getObject()).getProperty() == null && !isSingleArgDecoratorCall(myContext, (PyFunction)item.getObject())) { item = item.setInsertHandler(PyFunctionInsertHandler.INSTANCE); + item = item.setTailText(((PyFunction) item.getObject()).getParameterList().getText()); } else if (item.getObject() instanceof PyClass) { item = item.setInsertHandler(PyClassInsertHandler.INSTANCE); diff --git a/python/src/com/jetbrains/python/run/PythonCommandLineState.java b/python/src/com/jetbrains/python/run/PythonCommandLineState.java index 40bd114b0615..871cdd5e6b52 100644 --- a/python/src/com/jetbrains/python/run/PythonCommandLineState.java +++ b/python/src/com/jetbrains/python/run/PythonCommandLineState.java @@ -74,7 +74,7 @@ public abstract class PythonCommandLineState extends CommandLineState { } public ExecutionResult execute(Executor executor, CommandLinePatcher... patchers) throws ExecutionException { - final ColoredProcessHandler processHandler = startProcess(patchers); + final ProcessHandler processHandler = startProcess(patchers); final ConsoleView console = createAndAttachConsole(getConfig().getProject(), processHandler, executor); List actions = Lists.newArrayList(createActions(console, processHandler)); @@ -104,7 +104,7 @@ public abstract class PythonCommandLineState extends CommandLineState { } } - protected ColoredProcessHandler startProcess() throws ExecutionException { + protected ProcessHandler startProcess() throws ExecutionException { return startProcess(null); } @@ -115,10 +115,10 @@ public abstract class PythonCommandLineState extends CommandLineState { * @return handler of the started process * @throws ExecutionException */ - protected ColoredProcessHandler startProcess(CommandLinePatcher... patchers) throws ExecutionException { + protected ProcessHandler startProcess(CommandLinePatcher... patchers) throws ExecutionException { GeneralCommandLine commandLine = generateCommandLine(patchers); - final ColoredProcessHandler processHandler = doCreateProcess(commandLine); + final ProcessHandler processHandler = doCreateProcess(commandLine); ProcessTerminatedListener.attach(processHandler); return processHandler; } @@ -133,7 +133,7 @@ public abstract class PythonCommandLineState extends CommandLineState { return commandLine; } - protected ColoredProcessHandler doCreateProcess(GeneralCommandLine commandLine) throws ExecutionException { + protected ProcessHandler doCreateProcess(GeneralCommandLine commandLine) throws ExecutionException { return PythonProcessHandler.createProcessHandler(commandLine); } diff --git a/python/src/com/jetbrains/python/run/PythonProcessHandler.java b/python/src/com/jetbrains/python/run/PythonProcessHandler.java index 5dfa9f886980..236346909287 100644 --- a/python/src/com/jetbrains/python/run/PythonProcessHandler.java +++ b/python/src/com/jetbrains/python/run/PythonProcessHandler.java @@ -4,6 +4,7 @@ import com.intellij.execution.ExecutionException; import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.execution.process.ColoredProcessHandler; import com.intellij.execution.process.RunnerMediator; +import com.intellij.execution.process.UnixProcessManager; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.ui.Messages; import org.jetbrains.annotations.NotNull; @@ -12,17 +13,14 @@ import org.jetbrains.annotations.NotNull; * @author traff */ public class PythonProcessHandler extends ColoredProcessHandler { - private final String myProcessUid; - - private PythonProcessHandler(@NotNull Process process, @NotNull GeneralCommandLine commandLine, @NotNull String processUid) { + private PythonProcessHandler(@NotNull Process process, @NotNull GeneralCommandLine commandLine) { super(process, commandLine.getCommandLineString()); - myProcessUid = processUid; } @Override protected void destroyProcessImpl() { super.destroyProcessImpl(); - if (RunnerMediator.canSendSignals()) { + if (RunnerMediator.isUnix()) { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { long millis = System.currentTimeMillis(); @@ -35,7 +33,7 @@ public class PythonProcessHandler extends ColoredProcessHandler { if (System.currentTimeMillis() - millis > 5000L) { if (Messages.showYesNoDialog("Do you want to terminate the process?", "Process is not responding", null) == 0) { - RunnerMediator.sendSigKill(getProcess()); + UnixProcessManager.sendSigKillToProcessTree(getProcess()); return; } else { @@ -60,10 +58,8 @@ public class PythonProcessHandler extends ColoredProcessHandler { public static PythonProcessHandler createProcessHandler(GeneralCommandLine commandLine) throws ExecutionException { - String processUid = RunnerMediator.injectUid(commandLine); - Process p = commandLine.createProcess(); - return new PythonProcessHandler(p, commandLine, processUid); + return new PythonProcessHandler(p, commandLine); } } diff --git a/python/testData/completion/elseInCondExpr.after.py b/python/testData/completion/elseInCondExpr.after.py new file mode 100644 index 000000000000..40cfc1f0de30 --- /dev/null +++ b/python/testData/completion/elseInCondExpr.after.py @@ -0,0 +1 @@ +a = 1 if True else \ No newline at end of file diff --git a/python/testData/completion/elseInCondExpr.py b/python/testData/completion/elseInCondExpr.py new file mode 100644 index 000000000000..647fb0fbd5bd --- /dev/null +++ b/python/testData/completion/elseInCondExpr.py @@ -0,0 +1 @@ +a = 1 if True el \ No newline at end of file diff --git a/python/testData/completion/superMethod.after.py b/python/testData/completion/superMethod.after.py new file mode 100644 index 000000000000..0fa016d3e9e0 --- /dev/null +++ b/python/testData/completion/superMethod.after.py @@ -0,0 +1,6 @@ +class Foo: + def xyzzy(self, *args, **kwargs): + pass + +class Bar(Foo): + def xyzzy(self, *args, **kwargs): \ No newline at end of file diff --git a/python/testData/completion/superMethod.py b/python/testData/completion/superMethod.py new file mode 100644 index 000000000000..fb4ecce615a4 --- /dev/null +++ b/python/testData/completion/superMethod.py @@ -0,0 +1,6 @@ +class Foo: + def xyzzy(self, *args, **kwargs): + pass + +class Bar(Foo): + def xy \ No newline at end of file diff --git a/python/testData/refactoring/rename/updateAll.py b/python/testData/refactoring/rename/updateAll.py new file mode 100644 index 000000000000..b22ade997a6c --- /dev/null +++ b/python/testData/refactoring/rename/updateAll.py @@ -0,0 +1,3 @@ +__all__ = ['foo'] + +def foo(): pass diff --git a/python/testData/refactoring/rename/updateAll_after.py b/python/testData/refactoring/rename/updateAll_after.py new file mode 100644 index 000000000000..a908dfc746d8 --- /dev/null +++ b/python/testData/refactoring/rename/updateAll_after.py @@ -0,0 +1,3 @@ +__all__ = ['bar'] + +def bar(): pass diff --git a/python/testSrc/com/jetbrains/python/PyTypeTest.java b/python/testSrc/com/jetbrains/python/PyTypeTest.java index 92be5220fa1c..64980204a386 100644 --- a/python/testSrc/com/jetbrains/python/PyTypeTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypeTest.java @@ -131,6 +131,29 @@ public class PyTypeTest extends PyLightFixtureTestCase { assertEquals("ImportError", type.getName()); } + public void testTypeAnno() { + PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), LanguageLevel.PYTHON30); + try { + PyClassType type = (PyClassType) doTest("def foo(x: str) -> list: expr = x"); + assertEquals("str", type.getName()); + } + finally { + PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), null); + } + } + + public void testReturnTypeAnno() { + PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), LanguageLevel.PYTHON30); + try { + PyClassType type = (PyClassType) doTest("def foo(x) -> list: return x\n" + + "expr = foo(None)"); + assertEquals("list", type.getName()); + } + finally { + PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), null); + } + } + private PyType doTest(final String text) { myFixture.configureByText(PythonFileType.INSTANCE, text); PyExpression expr = myFixture.findElementByText("expr", PyExpression.class); diff --git a/python/testSrc/com/jetbrains/python/PythonCompletionTest.java b/python/testSrc/com/jetbrains/python/PythonCompletionTest.java index ed819562b460..578906694157 100644 --- a/python/testSrc/com/jetbrains/python/PythonCompletionTest.java +++ b/python/testSrc/com/jetbrains/python/PythonCompletionTest.java @@ -239,7 +239,12 @@ public class PythonCompletionTest extends PyLightFixtureTestCase { PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), null); } } + + public void testSuperMethod() { // PY-170 + doTest(); + } + + public void testElseInCondExpr() { // PY-2397 + doTest(); + } } - - - diff --git a/python/testSrc/com/jetbrains/python/refactoring/PyRenameTest.java b/python/testSrc/com/jetbrains/python/refactoring/PyRenameTest.java index c1b0e2b2c656..c26cbb5fd134 100644 --- a/python/testSrc/com/jetbrains/python/refactoring/PyRenameTest.java +++ b/python/testSrc/com/jetbrains/python/refactoring/PyRenameTest.java @@ -49,6 +49,10 @@ public class PyRenameTest extends PyLightFixtureTestCase { doTest("bar"); } + public void testUpdateAll() { // PY-986 + doTest("bar"); + } + private void doTest(final String newName) { myFixture.configureByFile("refactoring/rename/" + getTestName(true) + ".py"); myFixture.renameElementAtCaret(newName);