Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Trofimov
2013-01-16 20:46:31 +01:00
50 changed files with 222 additions and 119 deletions
@@ -57,7 +57,7 @@ public class PythonFacetType extends FacetType<PythonFacet, PythonFacetConfigura
@Override
public Icon getIcon() {
return PythonIcons.Python.Icons.Python;
return PythonIcons.Python.Python;
}
public static class PythonFrameworkDetector extends FacetBasedFrameworkDetector<PythonFacet, PythonFacetConfiguration> {
@@ -22,7 +22,7 @@ public class PythonFrameworkSupportProvider extends FrameworkSupportProvider {
@Override
public Icon getIcon() {
return PythonIcons.Python.Icons.Python;
return PythonIcons.Python.Python;
}
@NotNull
+1
View File
@@ -4,6 +4,7 @@
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B

@@ -3,10 +3,10 @@ package com.jetbrains.python;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.openapi.vfs.VirtualFile;
import icons.PythonPsiApiIcons;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,15 +27,12 @@ public class PythonFileType extends LanguageFileType {
public static PythonFileType INSTANCE = new PythonFileType();
private final Icon _icon;
public PythonFileType() {
this(new PythonLanguage());
}
public PythonFileType(Language language) {
super(language);
_icon = IconLoader.getIcon("/com/jetbrains/python/icons/pythonFile.png");
}
@NotNull
@@ -55,7 +52,7 @@ public class PythonFileType extends LanguageFileType {
@NotNull
public Icon getIcon() {
return _icon;
return PythonPsiApiIcons.PythonFile;
}
@Override
@@ -0,0 +1,17 @@
package icons;
import com.intellij.openapi.util.IconLoader;
import javax.swing.*;
/**
* NOTE THIS FILE IS AUTO-GENERATED by the build/scripts/icons.gant
* Don't repeat mistakes of others ;-)
*/
public class PythonPsiApiIcons {
private static Icon load(String path) {
return IconLoader.getIcon(path, PythonPsiApiIcons.class);
}
public static final Icon PythonFile = load("/icons/com/jetbrains/python/pythonFile.png"); // 16x16
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

+1 -1
View File
@@ -13,5 +13,5 @@ public class RestIcons {
return IconLoader.getIcon(path, RestIcons.class);
}
public static final Icon Rst = load("/com/jetbrains/rest/res/rst.png"); // 16x16
public static final Icon Rst = load("/icons/com/jetbrains/rest/rst.png"); // 16x16
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 B

@@ -26,10 +26,10 @@ public abstract class PythonModuleTypeBase<T extends ModuleBuilder> extends Modu
}
public Icon getBigIcon() {
return PythonIcons.Python.Icons.Python_24;
return PythonIcons.Python.Python_24;
}
public Icon getNodeIcon(final boolean isOpened) {
return PythonIcons.Python.Icons.PythonClosed;
return PythonIcons.Python.PythonClosed;
}
}
@@ -123,17 +123,15 @@ public class ExecuteInConsoleAction extends AnAction {
selectConsole(project, editor, consumer);
}
else {
startConsole(project, editor, consumer, e.getData(LangDataKeys.MODULE));
startConsole(project, consumer, e.getData(LangDataKeys.MODULE));
}
}
}
private static void startConsole(final Project project,
final Editor editor,
final Consumer<PyCodeExecutor> consumer,
Module context) {
PydevConsoleRunner runner = RunPythonConsoleAction.runPythonConsole(project, context);
assert runner != null;
runner.addConsoleListener(new PydevConsoleRunner.ConsoleListener() {
@Override
public void handleConsoleInitialized(LanguageConsoleViewImpl consoleView) {
@@ -50,6 +50,6 @@ public class BuildoutFacetType extends FacetType<BuildoutFacet, BuildoutFacetCon
@Override
public Icon getIcon() {
return PythonIcons.Python.Icons.Buildout.Buildout;
return PythonIcons.Python.Buildout.Buildout;
}
}
@@ -38,7 +38,7 @@ public class BuildoutCfgFileType extends LanguageFileType {
@Nullable
public Icon getIcon() {
return PythonIcons.Python.Icons.Buildout.Buildout;
return PythonIcons.Python.Buildout.Buildout;
}
}
@@ -51,7 +51,7 @@ public class PySpecialMethodNamesCompletionContributor extends CompletionContrib
.create(entry.getKey() + entry.getValue().getSignature())
.bold()
.withTypeText("predefined")
.withIcon(PythonIcons.Python.Icons.Nodes.Cyan_dot)
.withIcon(PythonIcons.Python.Nodes.Cyan_dot)
;
result.addElement(TailTypeDecorator.withTail(item, TailType.CASE_COLON));
}
@@ -95,16 +95,8 @@ public class PyConvertTripleQuotedStringIntention extends BaseIntentionAction {
subString = convertToValidSubString(trimmed.substring(0, trimmed.length() - 3), firstQuote);
}
else {
s = StringUtil.escapeStringCharacters(s);
StringBuilder stringBuilder = new StringBuilder();
for (Character ch : s.toCharArray()) {
if (ch == firstQuote) {
stringBuilder.append("\\").append(firstQuote);
}
else {
stringBuilder.append(ch);
}
}
stringBuilder = StringUtil.escapeStringCharacters(s.length(), s, String.valueOf(firstQuote), true, stringBuilder);
subString = stringBuilder.toString();
}
return subString;
@@ -218,7 +218,7 @@ public class PythonDebugLanguageConsoleView extends JPanel implements ConsoleVie
public ShowDebugConsoleAction(final PythonDebugLanguageConsoleView console) {
super(ExecutionBundle.message("run.configuration.show.command.line.action.name"), null,
PythonIcons.Python.Icons.Debug.CommandLine);
PythonIcons.Python.Debug.CommandLine);
myConsole = console;
}
@@ -23,7 +23,6 @@ import com.jetbrains.python.run.PythonCommandLineState;
import com.jetbrains.python.sdk.PythonSdkType;
import icons.PythonIcons;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
@@ -34,7 +33,7 @@ public class RunPythonConsoleAction extends AnAction implements DumbAware {
public RunPythonConsoleAction() {
super();
getTemplatePresentation().setIcon(PythonIcons.Python.Icons.Python);
getTemplatePresentation().setIcon(PythonIcons.Python.Python);
}
@Override
@@ -6,9 +6,8 @@ import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.jetbrains.python.psi.PyFile;
import com.jetbrains.python.psi.PyFunction;
import com.jetbrains.python.psi.PyReferenceExpression;
import com.intellij.psi.util.PsiTreeUtil;
import com.jetbrains.python.psi.*;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -39,6 +38,11 @@ public class PyDeprecationInspection extends PyInspection {
@Override
public void visitPyReferenceExpression(PyReferenceExpression node) {
final PyExceptPart exceptPart = PsiTreeUtil.getParentOfType(node, PyExceptPart.class);
if (exceptPart != null) {
final PyExpression exceptClass = exceptPart.getExceptClass();
if (exceptClass != null && "ImportError".equals(exceptClass.getText())) return;
}
PsiElement resolveResult = node.getReference(resolveWithoutImplicits()).resolve();
String deprecationMessage = null;
if (resolveResult instanceof PyFunction) {
@@ -13,6 +13,8 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import com.jetbrains.django.model.DjangoMeta;
import com.jetbrains.django.model.DjangoModel;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PyNames;
import com.jetbrains.python.documentation.*;
@@ -68,7 +70,9 @@ public class PyDocstringInspection extends PyInspection {
@Override
public void visitPyClass(PyClass node) {
final String name = node.getName();
if (name != null && !name.startsWith("_")) checkDocString(node);
final PyClass outerClass = PsiTreeUtil.getParentOfType(node, PyClass.class);
final boolean isDjangoMeta = DjangoModel.isDjangoModelDescendant(outerClass) && DjangoMeta.isMetaClass(node);
if (name != null && !name.startsWith("_") && !isDjangoMeta) checkDocString(node);
}
private void checkDocString(PyDocStringOwner node) {
@@ -123,7 +123,9 @@ public class PyMissingConstructorInspection extends PyInspection {
PyExpression[] args = ((PyCallExpression)qualifier).getArguments();
if (args.length > 0) {
String firstArg = args[0].getText();
if (firstArg.equals(cl.getName()) || firstArg.equals(CANONICAL_SELF+"."+ CLASS))
final String qualifiedName = cl.getQualifiedName();
if (firstArg.equals(cl.getName()) || firstArg.equals(CANONICAL_SELF+"."+ CLASS) ||
(qualifiedName != null && qualifiedName.endsWith(firstArg)))
return true;
for (PyClass s : cl.iterateAncestorClasses()) {
if (firstArg.equals(s.getName()))
@@ -5,14 +5,10 @@ import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiComment;
import com.intellij.psi.PsiElement;
import com.intellij.psi.tree.TokenSet;
import com.intellij.psi.util.PsiTreeUtil;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PyTokenTypes;
import com.jetbrains.python.psi.*;
import com.jetbrains.python.psi.impl.PyAugAssignmentStatementImpl;
import com.jetbrains.python.psi.types.PyType;
import com.jetbrains.python.psi.types.TypeEvalContext;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -59,54 +55,21 @@ public class AugmentedAssignmentQuickFix implements LocalQuickFix {
if ((leftExpression instanceof PyReferenceExpression || leftExpression instanceof PySubscriptionExpression)) {
if (leftExpression.getText().equals(targetText)) {
if (rightExpression instanceof PyNumericLiteralExpression || rightExpression instanceof PyStringLiteralExpression ||
rightExpression instanceof PyCallExpression || rightExpression instanceof PyReferenceExpression
|| isPercentage(rightExpression) || isCompound(rightExpression) || isMathOperation(rightExpression, expression.getOperator())) {
final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project);
final StringBuilder stringBuilder = new StringBuilder();
final PsiElement psiOperator = expression.getPsiOperator();
if (psiOperator == null) return;
stringBuilder.append(targetText).append(" ").
append(psiOperator.getText()).append("= ").append(rightExpression.getText());
final PyAugAssignmentStatementImpl augAssignment = elementGenerator.createFromText(LanguageLevel.forElement(element),
PyAugAssignmentStatementImpl.class, stringBuilder.toString());
for (PsiComment comment : comments)
augAssignment.add(comment);
statement.replace(augAssignment);
}
final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project);
final StringBuilder stringBuilder = new StringBuilder();
final PsiElement psiOperator = expression.getPsiOperator();
if (psiOperator == null) return;
stringBuilder.append(targetText).append(" ").
append(psiOperator.getText()).append("= ").append(rightExpression.getText());
final PyAugAssignmentStatementImpl augAssignment = elementGenerator.createFromText(LanguageLevel.forElement(element),
PyAugAssignmentStatementImpl.class, stringBuilder.toString());
for (PsiComment comment : comments)
augAssignment.add(comment);
statement.replace(augAssignment);
}
}
}
}
}
private static boolean isCompound(final PyExpression rightExpression) {
if (rightExpression instanceof PyCallExpression) {
final PyType type = rightExpression.getType(TypeEvalContext.fast());
if (type != null && type.isBuiltin(TypeEvalContext.fast()) &&
("int".equals(type.getName()) || "str".equals(type.getName()))) return true;
}
return false;
}
private static boolean isPercentage(final PyExpression rightExpression) {
return (rightExpression instanceof PyBinaryExpression &&
((PyBinaryExpression)rightExpression).getLeftExpression() instanceof PyStringLiteralExpression &&
((PyBinaryExpression)rightExpression).getOperator() == PyTokenTypes.PERC);
}
private static boolean isMathOperation(final PyExpression rightExpression, final PyElementType mainOperator) {
final TokenSet first = TokenSet.create(PyTokenTypes.EXP, PyTokenTypes.FLOORDIV);
final TokenSet second = TokenSet.create(PyTokenTypes.MULT, PyTokenTypes.DIV, PyTokenTypes.PERC);
final TokenSet third = TokenSet.create(PyTokenTypes.PLUS, PyTokenTypes.MINUS);
if (rightExpression instanceof PyBinaryExpression){
final PyElementType operator = ((PyBinaryExpression)rightExpression).getOperator();
if (third.contains(mainOperator))
return true;
else if (second.contains(mainOperator) && (second.contains(operator) || first.contains(operator)))
return true;
}
return false;
}
}
@@ -89,13 +89,13 @@ public class PyFunctionImpl extends PyPresentableElementImpl<PyFunctionStub> imp
final Property property = getProperty();
if (property != null) {
if (property.getGetter().valueOrNull() == this) {
return PythonIcons.Python.Icons.PropertyGetter;
return PythonIcons.Python.PropertyGetter;
}
if (property.getSetter().valueOrNull() == this) {
return PythonIcons.Python.Icons.PropertySetter;
return PythonIcons.Python.PropertySetter;
}
if (property.getDeleter().valueOrNull() == this) {
return PythonIcons.Python.Icons.PropertyDeleter;
return PythonIcons.Python.PropertyDeleter;
}
return PlatformIcons.PROPERTY_ICON;
}
@@ -2,6 +2,7 @@ package com.jetbrains.python.refactoring.introduce.parameter;
import com.intellij.codeInsight.CodeInsightUtilBase;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.PsiReference;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.introduce.inplace.InplaceVariableIntroducer;
@@ -61,32 +62,55 @@ public class PyIntroduceParameterHandler extends IntroduceHandler {
protected boolean isValidIntroduceContext(PsiElement element) {
if (element != null) {
final PyFunction function = PsiTreeUtil.getParentOfType(element, PyFunction.class);
final ScopeOwner scopeOwner = ScopeUtil.getScopeOwner(element);
final boolean[] isValid = {true};
if (scopeOwner != null) {
new PyRecursiveElementVisitor() {
@Override
public void visitPyReferenceExpression(PyReferenceExpression node) {
super.visitPyReferenceExpression(node);
if (ControlFlowCache.getScope(scopeOwner).containsDeclaration(node.getName())) {
isValid[0] = false;
}
}
}.visitElement(element);
}
final PyStatement nonlocalStatement =
PsiTreeUtil.getParentOfType(element, PyNonlocalStatement.class, PyGlobalStatement.class);
final PyStatementList statementList =
PsiTreeUtil.getParentOfType(element, PyStatementList.class);
PyImportStatement importStatement = PsiTreeUtil.getParentOfType(element, PyImportStatement.class);
return function != null && !isResolvedToParameter(element) && isValid[0] && nonlocalStatement == null &&
statementList != null && importStatement == null;
if (!isValidPlace(element)) return false;
return isNotDeclared(element);
}
return false;
}
private boolean isResolvedToParameter(PsiElement element) {
private static boolean isNotDeclared(PsiElement element) {
final ScopeOwner scopeOwner = ScopeUtil.getScopeOwner(element);
final boolean[] isValid = {true};
if (scopeOwner != null) {
final String name = element instanceof PsiNamedElement? ((PsiNamedElement)element).getName() : element.getText();
if (name != null && ControlFlowCache.getScope(scopeOwner).containsDeclaration(name)) {
return false;
}
new PyRecursiveElementVisitor() {
@Override
public void visitPyReferenceExpression(PyReferenceExpression node) {
super.visitPyReferenceExpression(node);
final String name = node.getName();
if (name != null && ControlFlowCache.getScope(scopeOwner).containsDeclaration(name)) {
isValid[0] = false;
}
}
}.visitElement(element);
}
return !isResolvedToParameter(element) && isValid[0];
}
private static boolean isValidPlace(PsiElement element) {
final PyFunction function = PsiTreeUtil.getParentOfType(element, PyFunction.class);
final PyForPart forPart = PsiTreeUtil.getParentOfType(element, PyForPart.class);
if (forPart != null) {
final PyExpression target = forPart.getTarget();
if (target instanceof PyTargetExpression && element.getText().equals(target.getName()))
return false;
}
final PyStatement nonlocalStatement =
PsiTreeUtil.getParentOfType(element, PyNonlocalStatement.class, PyGlobalStatement.class);
final PyStatementList statementList =
PsiTreeUtil.getParentOfType(element, PyStatementList.class);
PyImportStatement importStatement = PsiTreeUtil.getParentOfType(element, PyImportStatement.class);
return nonlocalStatement == null && importStatement == null &&
statementList != null && function != null;
}
private static boolean isResolvedToParameter(PsiElement element) {
while (element instanceof PyReferenceExpression) {
final PsiReference reference = element.getReference();
if (reference != null && reference.resolve() instanceof PyNamedParameter)
@@ -48,7 +48,7 @@ public class PythonConfigurationType implements ConfigurationType {
}
public Icon getIcon() {
return PythonIcons.Python.Icons.Python;
return PythonIcons.Python.Python;
}
public ConfigurationFactory[] getConfigurationFactories() {
@@ -94,7 +94,7 @@ public class PythonSdkType extends SdkType {
}
public Icon getIcon() {
return PythonIcons.Python.Icons.Python;
return PythonIcons.Python.Python;
}
@NotNull
@@ -84,6 +84,6 @@ public class IronPythonSdkFlavor extends PythonSdkFlavor {
@Override
public Icon getIcon() {
return PythonIcons.Python.Icons.Dotnet;
return PythonIcons.Python.Dotnet;
}
}
@@ -66,6 +66,6 @@ public class JythonSdkFlavor extends PythonSdkFlavor {
@Override
public Icon getIcon() {
return PythonIcons.Python.Icons.Jython;
return PythonIcons.Python.Jython;
}
}
@@ -77,6 +77,6 @@ public class PyPySdkFlavor extends PythonSdkFlavor {
@Override
public Icon getIcon() {
return PythonIcons.Python.Icons.Pypy;
return PythonIcons.Python.Pypy;
}
}
@@ -229,6 +229,6 @@ public abstract class PythonSdkFlavor {
}
public Icon getIcon() {
return PythonIcons.Python.Icons.Python;
return PythonIcons.Python.Python;
}
}
@@ -118,6 +118,6 @@ public class VirtualEnvSdkFlavor extends CPythonSdkFlavor {
@Override
public Icon getIcon() {
return PythonIcons.Python.Icons.Virtualenv;
return PythonIcons.Python.Virtualenv;
}
}
@@ -275,13 +275,13 @@ public class PyStructureViewElement implements StructureViewTreeElement {
icon.setIcon(normal_icon, 0);
Icon overlay = null;
if (myVisibility == Visibility.PRIVATE || myVisibility == Visibility.PROTECTED) {
overlay = PythonIcons.Python.Icons.Nodes.Lock;
overlay = PythonIcons.Python.Nodes.Lock;
}
else if (myVisibility == Visibility.PREDEFINED) {
overlay = PythonIcons.Python.Icons.Nodes.Cyan_dot;
overlay = PythonIcons.Python.Nodes.Cyan_dot;
}
else if (myVisibility == Visibility.INVISIBLE) {
overlay = PythonIcons.Python.Icons.Nodes.Red_inv_triangle;
overlay = PythonIcons.Python.Nodes.Red_inv_triangle;
}
if (overlay != null) {
icon.setIcon(overlay, 1);
@@ -121,7 +121,7 @@ public class PythonTestConfigurationType implements ConfigurationType {
@Override
public Icon getIcon() {
return PythonIcons.Python.Icons.PythonTests;
return PythonIcons.Python.PythonTests;
}
@NotNull
@@ -0,0 +1,4 @@
try:
from urlparse import parse_qs, parse_qsl
except ImportError:
from cgi import parse_qs, parse_qsl
@@ -0,0 +1,3 @@
current_sum = 1
numbers = [1, 2, 3]
<weak_warning descr="Assignment can be replaced with augmented assignment">current_sum = current_sum + numbers[0]</weak_warning>
@@ -0,0 +1,3 @@
current_sum = 1
numbers = [1, 2, 3]
current_sum += numbers[0]
@@ -0,0 +1,18 @@
class Base(object):
def __init__(self, param):
print "Base", param
class Wrapper(object):
class Child(Base):
def __init__(self, param1, param2):
# Here PyCharm claims no super call
super(Wrapper.Child, self).__init__(param2)
print "Child", param1
def __init__(self):
self.child = self.Child("aaa", "bbb")
wrapper = Wrapper()
@@ -0,0 +1,3 @@
s = ("\n"
"my quote\" some text after it\n"
)
@@ -0,0 +1,3 @@
s = """
my q<caret>uote" some text after it
"""
@@ -0,0 +1,2 @@
def f(b=<caret>"myValue"):
pass
@@ -0,0 +1,4 @@
def f2():
param = 1
def f():
global <selection>param</selection>
@@ -0,0 +1,3 @@
def f():
a = 1
print <caret>a + 3
@@ -0,0 +1,2 @@
for <caret>item in range(100):
pass
@@ -0,0 +1,2 @@
def f(b=1):
return <caret>b + 1
@@ -0,0 +1,4 @@
def f2():
param = 1
def f():
nonlocal <selection>param</selection>
@@ -27,6 +27,12 @@ public class PyDeprecationTest extends PyTestCase {
assertNotParsed((PyFile) myFixture.getFile());
}
public void testDeprecatedAsFallback() {
myFixture.enableInspections(PyDeprecationInspection.class);
myFixture.configureByFile("deprecation/deprecatedAsFallback.py");
myFixture.checkHighlighting(true, false, false);
}
public void testDeprecatedProperty() {
myFixture.enableInspections(PyDeprecationInspection.class);
myFixture.configureByFile("deprecation/deprecatedProperty.py");
@@ -237,10 +237,15 @@ public class PyIntentionTest extends PyTestCase {
public void testConvertVariadicParam() { //PY-2264
doTest(PyBundle.message("INTN.convert.variadic.param"));
}
public void testConvertTripleQuotedString() { //PY-2697
doTest(PyBundle.message("INTN.triple.quoted.string"));
}
public void testConvertTripleQuotedString1() { //PY-7774
doTest(PyBundle.message("INTN.triple.quoted.string"));
}
public void testTransformConditionalExpression() { //PY-3094
doTest(PyBundle.message("INTN.transform.into.if.else.statement"));
}
@@ -241,6 +241,11 @@ public class PyQuickFixTest extends PyTestCase {
PyBundle.message("QFIX.augment.assignment"), true, true);
}
public void testAugmentAssignmentSubscription() { // PY-7715
doInspectionTest("AugmentAssignmentFunction.py", PyAugmentAssignmentInspection.class,
PyBundle.message("QFIX.augment.assignment"), true, true);
}
public void testChainedComparisons() { // PY-1020
doInspectionTest("ChainedComparisons.py", PyChainedComparisonsInspection.class,
PyBundle.message("QFIX.chained.comparison"), true, true);
@@ -33,8 +33,11 @@ public class PyMissingConstructorTest extends PyTestCase {
doTest();
}
// PY-7176
public void testException() {
public void testException() { // PY-7176
doTest();
}
public void testInnerClass() { //PY-7699
doTest();
}
@@ -3,6 +3,7 @@ package com.jetbrains.python.refactoring;
import com.intellij.refactoring.util.CommonRefactoringUtil;
import com.intellij.testFramework.TestDataPath;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.psi.LanguageLevel;
import com.jetbrains.python.refactoring.introduce.IntroduceHandler;
import com.jetbrains.python.refactoring.introduce.parameter.PyIntroduceParameterHandler;
@@ -35,6 +36,27 @@ public class PyIntroduceParameterTest extends PyIntroduceTestCase {
doTestCannotPerform(PyBundle.message("refactoring.introduce.selection.error"));
}
public void testLocalVariable1() {
doTestCannotPerform(PyBundle.message("refactoring.introduce.selection.error"));
}
public void testLocalVariableParam() {
doTestCannotPerform(PyBundle.message("refactoring.introduce.selection.error"));
}
public void testNonLocal() {
doTestCannotPerform(PyBundle.message("refactoring.introduce.selection.error"), LanguageLevel.PYTHON32);
}
public void testGlobal() {
doTestCannotPerform(PyBundle.message("refactoring.introduce.selection.error"));
}
public void testFunctionDef() {
doTestCannotPerform(PyBundle.message("refactoring.introduce.selection.error"));
}
@Override
protected String getTestDataPath() {
return super.getTestDataPath() + "/refactoring/introduceParameter";
@@ -52,4 +74,14 @@ public class PyIntroduceParameterTest extends PyIntroduceTestCase {
assertEquals(expected, e.getMessage());
}
}
private void doTestCannotPerform(String expected, LanguageLevel languageLevel) {
setLanguageLevel(languageLevel);
try {
doTestCannotPerform(expected);
}
finally {
setLanguageLevel(null);
}
}
}