From 0cb3f450f595cb669acb1c98aa9a3dd7686b715e Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Tue, 18 Sep 2012 16:15:08 +0400 Subject: [PATCH 1/9] fixed PY-7599 Conflict with bin/pycharm64.exe.vmoptions upgrading from PyCharm 2.6.1 to 2.6.2 --- python/build/pycharm_build.gant | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/build/pycharm_build.gant b/python/build/pycharm_build.gant index 3d6ed3ed91e6..0fd9b19b748b 100644 --- a/python/build/pycharm_build.gant +++ b/python/build/pycharm_build.gant @@ -383,7 +383,7 @@ private layoutWin(Map args, String target) { } winScripts(target, "$home/community", "pycharm.bat", args) - winVMOptions(target, args.system_selector, "pycharm.exe", "pycharm64.exe") + winVMOptions(target, args.system_selector, "pycharm.exe") ant.copy(file: "$home/python/help/pycharmhelp.jar", todir: "$target/help", failonerror: false) } From 981c7a0021f34e25e2f82f1fe4ca08958a4e8710 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Tue, 18 Sep 2012 17:43:20 +0400 Subject: [PATCH 2/9] fixed PY-7599 Conflict with bin/pycharm64.exe.vmoptions upgrading from PyCharm 2.6.1 to 2.6.2 --- .../com/jetbrains/python/editor/PythonCopyPasteProcessor.java | 2 +- python/testData/copyPaste/BeginningOfFile.after.py | 3 +++ python/testData/copyPaste/BeginningOfFile.dst.py | 2 ++ python/testData/copyPaste/BeginningOfFile.src.py | 3 +++ python/testSrc/com/jetbrains/python/PyCopyPasteTest.java | 4 ++++ 5 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 python/testData/copyPaste/BeginningOfFile.after.py create mode 100644 python/testData/copyPaste/BeginningOfFile.dst.py create mode 100644 python/testData/copyPaste/BeginningOfFile.src.py diff --git a/python/src/com/jetbrains/python/editor/PythonCopyPasteProcessor.java b/python/src/com/jetbrains/python/editor/PythonCopyPasteProcessor.java index 137d87eea46a..8ae2ade549b6 100644 --- a/python/src/com/jetbrains/python/editor/PythonCopyPasteProcessor.java +++ b/python/src/com/jetbrains/python/editor/PythonCopyPasteProcessor.java @@ -113,7 +113,7 @@ public class PythonCopyPasteProcessor implements CopyPastePreProcessor { newText = new String(text); // to indent correctly (see PasteHandler) } - if (element instanceof PsiWhiteSpace && + if ((element instanceof PsiWhiteSpace || element.getTextOffset() == 0) && (StringUtil.countChars(element.getText(), '\n') <= 2 && !StringUtil.isEmptyOrSpaces(text))) { newText += "\n"; } diff --git a/python/testData/copyPaste/BeginningOfFile.after.py b/python/testData/copyPaste/BeginningOfFile.after.py new file mode 100644 index 000000000000..663a4618bbc9 --- /dev/null +++ b/python/testData/copyPaste/BeginningOfFile.after.py @@ -0,0 +1,3 @@ +a = 1 +b = 2 +a = 1 \ No newline at end of file diff --git a/python/testData/copyPaste/BeginningOfFile.dst.py b/python/testData/copyPaste/BeginningOfFile.dst.py new file mode 100644 index 000000000000..991d8ef2dab4 --- /dev/null +++ b/python/testData/copyPaste/BeginningOfFile.dst.py @@ -0,0 +1,2 @@ +b = 2 +a = 1 \ No newline at end of file diff --git a/python/testData/copyPaste/BeginningOfFile.src.py b/python/testData/copyPaste/BeginningOfFile.src.py new file mode 100644 index 000000000000..9f58dbcebdbf --- /dev/null +++ b/python/testData/copyPaste/BeginningOfFile.src.py @@ -0,0 +1,3 @@ +b = 2 +a = 1 + \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyCopyPasteTest.java b/python/testSrc/com/jetbrains/python/PyCopyPasteTest.java index 30e63e9a6b01..2c515b000a74 100644 --- a/python/testSrc/com/jetbrains/python/PyCopyPasteTest.java +++ b/python/testSrc/com/jetbrains/python/PyCopyPasteTest.java @@ -255,6 +255,10 @@ public class PyCopyPasteTest extends PyTestCase { doTest(); } + public void testBeginningOfFile() { //PY-7524 + doTest(); + } + private void doTest() { String name = getTestName(false); From d8668c573b908fa0439cd33e9c5379d5c13755b5 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 19 Sep 2012 12:12:04 +0400 Subject: [PATCH 3/9] xml mappings for configurables --- python/src/META-INF/python-plugin-common.xml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/python/src/META-INF/python-plugin-common.xml b/python/src/META-INF/python-plugin-common.xml index ae814f9b2c22..adfb70852c8d 100644 --- a/python/src/META-INF/python-plugin-common.xml +++ b/python/src/META-INF/python-plugin-common.xml @@ -400,9 +400,15 @@ - - - + + + From 115299e8e765313b988c2c7f5116895b1d262569 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 19 Sep 2012 15:40:46 +0400 Subject: [PATCH 4/9] fixed PY-7591 Unclear naming for unittest run configurations --- .../testing/AbstractPythonTestRunConfiguration.java | 12 +++++++----- .../testing/attest/PythonAtTestRunConfiguration.java | 8 +++++++- .../doctest/PythonDocTestRunConfiguration.java | 8 +++++++- .../nosetest/PythonNoseTestRunConfiguration.java | 8 +++++++- .../testing/pytest/PyTestRunConfiguration.java | 11 ++++++++++- .../unittest/PythonUnitTestRunConfiguration.java | 8 +++++++- 6 files changed, 45 insertions(+), 10 deletions(-) diff --git a/python/src/com/jetbrains/python/testing/AbstractPythonTestRunConfiguration.java b/python/src/com/jetbrains/python/testing/AbstractPythonTestRunConfiguration.java index 87164c84ff6c..7b327e7ce78a 100644 --- a/python/src/com/jetbrains/python/testing/AbstractPythonTestRunConfiguration.java +++ b/python/src/com/jetbrains/python/testing/AbstractPythonTestRunConfiguration.java @@ -214,19 +214,19 @@ public abstract class AbstractPythonTestRunConfiguration extends AbstractPythonR public String suggestedName() { switch (myTestType) { case TEST_CLASS: - return getTitle() + " in " + myClassName; + return getPluralTitle() + " in " + myClassName; case TEST_METHOD: - return getTitle() + " in " + myClassName + "." + myMethodName; + return getTitle() + " " + myClassName + "." + myMethodName; case TEST_SCRIPT: String name = new File(getScriptName()).getName(); if (name.endsWith(".py")) { name = name.substring(0, name.length() - 3); } - return getTitle() + " in " + name; + return getPluralTitle() + " in " + name; case TEST_FOLDER: - return getTitle() + " in " + FileUtil.toSystemDependentName(myFolderName); + return getPluralTitle() + " in " + FileUtil.toSystemDependentName(myFolderName); case TEST_FUNCTION: - return getTitle() + " in " + myMethodName; + return getTitle() + " " + myMethodName; default: throw new IllegalStateException("Unknown test type: " + myTestType); } @@ -234,6 +234,8 @@ public abstract class AbstractPythonTestRunConfiguration extends AbstractPythonR protected abstract String getTitle(); + protected abstract String getPluralTitle(); + @Override public RefactoringElementListener getRefactoringElementListener(PsiElement element) { if (element instanceof PsiDirectory) { diff --git a/python/src/com/jetbrains/python/testing/attest/PythonAtTestRunConfiguration.java b/python/src/com/jetbrains/python/testing/attest/PythonAtTestRunConfiguration.java index ebcb25ae4382..f5064f1be4d5 100644 --- a/python/src/com/jetbrains/python/testing/attest/PythonAtTestRunConfiguration.java +++ b/python/src/com/jetbrains/python/testing/attest/PythonAtTestRunConfiguration.java @@ -18,7 +18,8 @@ import org.jetbrains.annotations.NotNull; */ public class PythonAtTestRunConfiguration extends AbstractPythonTestRunConfiguration implements PythonAtTestRunConfigurationParams { - protected String myTitle = "Attests"; + protected String myTitle = "Attest"; + protected String myPluralTitle = "Attests"; public PythonAtTestRunConfiguration(RunConfigurationModule module, ConfigurationFactory configurationFactory, String name) { @@ -55,6 +56,11 @@ public class PythonAtTestRunConfiguration extends AbstractPythonTestRunConfigura return myTitle; } + @Override + protected String getPluralTitle() { + return myPluralTitle; + } + public static void copyParams(PythonAtTestRunConfigurationParams source, PythonAtTestRunConfigurationParams target) { copyParams(source.getTestRunConfigurationParams(), target.getTestRunConfigurationParams()); } diff --git a/python/src/com/jetbrains/python/testing/doctest/PythonDocTestRunConfiguration.java b/python/src/com/jetbrains/python/testing/doctest/PythonDocTestRunConfiguration.java index cc905e6fa4d1..6f1793d906a8 100644 --- a/python/src/com/jetbrains/python/testing/doctest/PythonDocTestRunConfiguration.java +++ b/python/src/com/jetbrains/python/testing/doctest/PythonDocTestRunConfiguration.java @@ -16,7 +16,8 @@ import org.jetbrains.annotations.NotNull; */ public class PythonDocTestRunConfiguration extends AbstractPythonTestRunConfiguration implements PythonDocTestRunConfigurationParams { - protected String myTitle = "Doctests"; + protected String myPluralTitle = "Doctests"; + protected String myTitle = "Doctest"; public PythonDocTestRunConfiguration(RunConfigurationModule module, ConfigurationFactory configurationFactory, String name) { @@ -53,6 +54,11 @@ public class PythonDocTestRunConfiguration extends AbstractPythonTestRunConfigur return myTitle; } + @Override + protected String getPluralTitle() { + return myPluralTitle; + } + public static void copyParams(PythonDocTestRunConfigurationParams source, PythonDocTestRunConfigurationParams target) { copyParams(source.getTestRunConfigurationParams(), target.getTestRunConfigurationParams()); } diff --git a/python/src/com/jetbrains/python/testing/nosetest/PythonNoseTestRunConfiguration.java b/python/src/com/jetbrains/python/testing/nosetest/PythonNoseTestRunConfiguration.java index b9ffdc472e45..7fe92734df32 100644 --- a/python/src/com/jetbrains/python/testing/nosetest/PythonNoseTestRunConfiguration.java +++ b/python/src/com/jetbrains/python/testing/nosetest/PythonNoseTestRunConfiguration.java @@ -20,7 +20,8 @@ import org.jetbrains.annotations.NotNull; public class PythonNoseTestRunConfiguration extends AbstractPythonTestRunConfiguration implements PythonNoseTestRunConfigurationParams { private String myParams = ""; // parameters for nosetests - protected String myTitle = "Nosetests"; + protected String myTitle = "Nosetest"; + protected String myPluralTitle = "Nosetests"; private boolean useParam = false; public PythonNoseTestRunConfiguration(RunConfigurationModule module, @@ -58,6 +59,11 @@ public class PythonNoseTestRunConfiguration extends AbstractPythonTestRunConfigu return myTitle; } + @Override + protected String getPluralTitle() { + return myPluralTitle; + } + public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException { return new PythonNoseTestCommandLineState(this, env); } diff --git a/python/src/com/jetbrains/python/testing/pytest/PyTestRunConfiguration.java b/python/src/com/jetbrains/python/testing/pytest/PyTestRunConfiguration.java index f9abbd379ecc..82e3f6bd6369 100644 --- a/python/src/com/jetbrains/python/testing/pytest/PyTestRunConfiguration.java +++ b/python/src/com/jetbrains/python/testing/pytest/PyTestRunConfiguration.java @@ -25,6 +25,10 @@ public class PyTestRunConfiguration extends AbstractPythonTestRunConfiguration i private boolean useParam = false; private boolean useKeyword = false; + protected String myTitle = "py.test"; + protected String myPluralTitle = "py.tests"; + + private static final String TEST_TO_RUN_FIELD = "testToRun"; private static final String KEYWORDS_FIELD = "keywords"; private static final String PARAMS_FIELD = "params"; @@ -126,6 +130,11 @@ public class PyTestRunConfiguration extends AbstractPythonTestRunConfiguration i @Override protected String getTitle() { - return "py.tests"; + return myTitle; + } + + @Override + protected String getPluralTitle() { + return myPluralTitle; } } diff --git a/python/src/com/jetbrains/python/testing/unittest/PythonUnitTestRunConfiguration.java b/python/src/com/jetbrains/python/testing/unittest/PythonUnitTestRunConfiguration.java index 59e83dfd8b22..3a50c45ce83a 100644 --- a/python/src/com/jetbrains/python/testing/unittest/PythonUnitTestRunConfiguration.java +++ b/python/src/com/jetbrains/python/testing/unittest/PythonUnitTestRunConfiguration.java @@ -19,7 +19,8 @@ public class PythonUnitTestRunConfiguration extends AbstractPythonTestRunConfiguration implements PythonUnitTestRunConfigurationParams { private boolean myIsPureUnittest = true; - protected String myTitle = "Unittests"; + protected String myTitle = "Unittest"; + protected String myPluralTitle = "Unittests"; public PythonUnitTestRunConfiguration(RunConfigurationModule module, ConfigurationFactory configurationFactory, @@ -59,6 +60,11 @@ public class PythonUnitTestRunConfiguration extends return myTitle; } + @Override + protected String getPluralTitle() { + return myPluralTitle; + } + public static void copyParams(PythonUnitTestRunConfigurationParams source, PythonUnitTestRunConfigurationParams target) { copyParams(source.getTestRunConfigurationParams(), target.getTestRunConfigurationParams()); target.setPureUnittest(source.isPureUnittest()); From dff5f05835e9545af1443d85f1cdebf0615b2d8d Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 19 Sep 2012 16:02:31 +0400 Subject: [PATCH 5/9] refactored tests for PyAugmentedAssignment Inspection --- .../PyAugmentAssignmentInspection/add.py | 1 + .../differentOperations.py | 8 +++ .../PyAugmentAssignmentInspection/list.py | 2 + .../PyAugmentAssignmentInspection/mult.py | 1 + .../PyAugmentAssignmentInspection/negative.py | 2 + .../negativeAssignment.py | 5 ++ .../negativeMinus.py | 3 + .../negativeString.py | 8 +++ .../PyAugmentAssignmentInspection/numeric.py | 8 +++ .../PyAugmentAssignmentInspection/string.py | 7 +++ .../PyAugmentAssignmentInspection/test.py | 39 ------------- .../python/PythonInspectionsTest.java | 4 -- .../PyAugmentAssignmentInspectionTest.java | 55 +++++++++++++++++++ 13 files changed, 100 insertions(+), 43 deletions(-) create mode 100644 python/testData/inspections/PyAugmentAssignmentInspection/add.py create mode 100644 python/testData/inspections/PyAugmentAssignmentInspection/differentOperations.py create mode 100644 python/testData/inspections/PyAugmentAssignmentInspection/list.py create mode 100644 python/testData/inspections/PyAugmentAssignmentInspection/mult.py create mode 100644 python/testData/inspections/PyAugmentAssignmentInspection/negative.py create mode 100644 python/testData/inspections/PyAugmentAssignmentInspection/negativeAssignment.py create mode 100644 python/testData/inspections/PyAugmentAssignmentInspection/negativeMinus.py create mode 100644 python/testData/inspections/PyAugmentAssignmentInspection/negativeString.py create mode 100644 python/testData/inspections/PyAugmentAssignmentInspection/numeric.py create mode 100644 python/testData/inspections/PyAugmentAssignmentInspection/string.py delete mode 100644 python/testData/inspections/PyAugmentAssignmentInspection/test.py create mode 100644 python/testSrc/com/jetbrains/python/inspections/PyAugmentAssignmentInspectionTest.java diff --git a/python/testData/inspections/PyAugmentAssignmentInspection/add.py b/python/testData/inspections/PyAugmentAssignmentInspection/add.py new file mode 100644 index 000000000000..b3b61d9c4f91 --- /dev/null +++ b/python/testData/inspections/PyAugmentAssignmentInspection/add.py @@ -0,0 +1 @@ +var_1 = var_1 + 1 diff --git a/python/testData/inspections/PyAugmentAssignmentInspection/differentOperations.py b/python/testData/inspections/PyAugmentAssignmentInspection/differentOperations.py new file mode 100644 index 000000000000..ab2a26b03a2f --- /dev/null +++ b/python/testData/inspections/PyAugmentAssignmentInspection/differentOperations.py @@ -0,0 +1,8 @@ +# PY-2488 +a = a ** 1 + +x = x % 3 +x = x | 3 +x = x & 3 +x = x ^ 3 + diff --git a/python/testData/inspections/PyAugmentAssignmentInspection/list.py b/python/testData/inspections/PyAugmentAssignmentInspection/list.py new file mode 100644 index 000000000000..bec79b1f9616 --- /dev/null +++ b/python/testData/inspections/PyAugmentAssignmentInspection/list.py @@ -0,0 +1,2 @@ +# PY-2483 +list[0] = list[0] + 1 diff --git a/python/testData/inspections/PyAugmentAssignmentInspection/mult.py b/python/testData/inspections/PyAugmentAssignmentInspection/mult.py new file mode 100644 index 000000000000..87d44d6dae24 --- /dev/null +++ b/python/testData/inspections/PyAugmentAssignmentInspection/mult.py @@ -0,0 +1 @@ +var = var * 2 diff --git a/python/testData/inspections/PyAugmentAssignmentInspection/negative.py b/python/testData/inspections/PyAugmentAssignmentInspection/negative.py new file mode 100644 index 000000000000..dcd2ea209984 --- /dev/null +++ b/python/testData/inspections/PyAugmentAssignmentInspection/negative.py @@ -0,0 +1,2 @@ +var_7 += 2 + diff --git a/python/testData/inspections/PyAugmentAssignmentInspection/negativeAssignment.py b/python/testData/inspections/PyAugmentAssignmentInspection/negativeAssignment.py new file mode 100644 index 000000000000..bdf3d768d756 --- /dev/null +++ b/python/testData/inspections/PyAugmentAssignmentInspection/negativeAssignment.py @@ -0,0 +1,5 @@ +str = "string" + +var_3 = var_3 + +var_4 = 1 diff --git a/python/testData/inspections/PyAugmentAssignmentInspection/negativeMinus.py b/python/testData/inspections/PyAugmentAssignmentInspection/negativeMinus.py new file mode 100644 index 000000000000..10ebeee1f4e3 --- /dev/null +++ b/python/testData/inspections/PyAugmentAssignmentInspection/negativeMinus.py @@ -0,0 +1,3 @@ + +#PY-2514 +dy = 1 - dy diff --git a/python/testData/inspections/PyAugmentAssignmentInspection/negativeString.py b/python/testData/inspections/PyAugmentAssignmentInspection/negativeString.py new file mode 100644 index 000000000000..d9d0df18b5e1 --- /dev/null +++ b/python/testData/inspections/PyAugmentAssignmentInspection/negativeString.py @@ -0,0 +1,8 @@ +#PY-6331 +var = "string" +var = "some " + var + +#PY-6490 +foo = "a" +bar = "b" +foo = bar + foo \ No newline at end of file diff --git a/python/testData/inspections/PyAugmentAssignmentInspection/numeric.py b/python/testData/inspections/PyAugmentAssignmentInspection/numeric.py new file mode 100644 index 000000000000..320ad7841bc4 --- /dev/null +++ b/python/testData/inspections/PyAugmentAssignmentInspection/numeric.py @@ -0,0 +1,8 @@ + +var_3 = var_3 +var_4 = 1 +var_6 = var_6 + var_4 + +#PY-2482 +var = 2 + var + diff --git a/python/testData/inspections/PyAugmentAssignmentInspection/string.py b/python/testData/inspections/PyAugmentAssignmentInspection/string.py new file mode 100644 index 000000000000..17a99ffd3b9c --- /dev/null +++ b/python/testData/inspections/PyAugmentAssignmentInspection/string.py @@ -0,0 +1,7 @@ +str = "string" + +var_2 = var_2 + str + +var_3 = var_3 +var_4 = 1 +var_5 = var_5 + "string" diff --git a/python/testData/inspections/PyAugmentAssignmentInspection/test.py b/python/testData/inspections/PyAugmentAssignmentInspection/test.py deleted file mode 100644 index e5348ee73018..000000000000 --- a/python/testData/inspections/PyAugmentAssignmentInspection/test.py +++ /dev/null @@ -1,39 +0,0 @@ -var = var * 2 -var_1 = var_1 + 1 - -str = "string" - -var_2 = var_2 + str - -var_3 = var_3 -var_4 = 1 -var_5 = var_5 + "string" -var_6 = var_6 + var_4 - -var_7 += 2 - -#PY-2482 -var = 2 + var - -# PY-2483 -list[0] = list[0] + 1 - -# PY-2488 -a = a ** 1 - -x = x % 3 -x = x | 3 -x = x & 3 -x = x ^ 3 - -#PY-2514 -dy = 1 - dy - -#PY-6331 -var = "string" -var = "some " + var - -#PY-6490 -foo = "a" -bar = "b" -foo = bar + foo \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java b/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java index 1c475fbe8e1a..e67beab8c461 100644 --- a/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java +++ b/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java @@ -259,10 +259,6 @@ public class PythonInspectionsTest extends PyTestCase { doHighlightingTest(PyBroadExceptionInspection.class); } - public void testPyAugmentAssignmentInspection() { - doHighlightingTest(PyAugmentAssignmentInspection.class); - } - public void testPyDictDuplicateKeysInspection() { doHighlightingTest(PyDictDuplicateKeysInspection.class); } diff --git a/python/testSrc/com/jetbrains/python/inspections/PyAugmentAssignmentInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyAugmentAssignmentInspectionTest.java new file mode 100644 index 000000000000..3ad5432d4543 --- /dev/null +++ b/python/testSrc/com/jetbrains/python/inspections/PyAugmentAssignmentInspectionTest.java @@ -0,0 +1,55 @@ +package com.jetbrains.python.inspections; + +import com.jetbrains.python.fixtures.PyTestCase; + +/** + * User: ktisha + */ +public class PyAugmentAssignmentInspectionTest extends PyTestCase { + + public void testMult() { + doTest(); + } + + public void testAdd() { + doTest(); + } + + public void testNegativeAssignment() { + doTest(); + } + + public void testNegative() { + doTest(); + } + + public void testNegativeMinus() { + doTest(); + } + + public void testNegativeString() { + doTest(); + } + + public void testString() { + doTest(); + } + + public void testNumeric() { + doTest(); + } + + public void testList() { + doTest(); + } + + public void testDifferentOperations() { + doTest(); + } + + private void doTest() { + myFixture.configureByFile("inspections/PyAugmentAssignmentInspection/" + getTestName(true) + ".py"); + myFixture.enableInspections(PyAugmentAssignmentInspection.class); + myFixture.checkHighlighting(true, false, true); + } +} From f9ebaf112b656cefd97914ef261ac4852e426b87 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Thu, 20 Sep 2012 14:59:13 +0400 Subject: [PATCH 6/9] fixed PY-5927 Make search in the "Available Packages" dialog box more convenient --- .../python/packaging/ui/ManagePackagesDialog.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/python/src/com/jetbrains/python/packaging/ui/ManagePackagesDialog.java b/python/src/com/jetbrains/python/packaging/ui/ManagePackagesDialog.java index 77409ad9b173..91e7c335c0bf 100644 --- a/python/src/com/jetbrains/python/packaging/ui/ManagePackagesDialog.java +++ b/python/src/com/jetbrains/python/packaging/ui/ManagePackagesDialog.java @@ -12,12 +12,10 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.ui.AnActionButton; -import com.intellij.ui.CollectionListModel; -import com.intellij.ui.FilterComponent; -import com.intellij.ui.ToolbarDecorator; +import com.intellij.ui.*; import com.intellij.ui.components.JBList; import com.intellij.ui.table.JBTable; +import com.intellij.util.Function; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.update.UiNotifyConnector; import com.jetbrains.python.packaging.*; @@ -82,6 +80,7 @@ public class ManagePackagesDialog extends DialogWrapper { private final PyPackagesPanel myPackageListPanel; private Set currentlyInstalling = new HashSet(); + protected final ListSpeedSearch myListSpeedSearch; public ManagePackagesDialog(@NotNull Project project, @NotNull final Sdk sdk, @NotNull final PyPackagesPanel packageListPanel) { super(false); @@ -125,6 +124,14 @@ public class ManagePackagesDialog extends DialogWrapper { }); } }; + myListSpeedSearch = new ListSpeedSearch(this.myPackages, new Function() { + @Override + public String fun(Object o) { + if (o instanceof ComparablePair) + return ((ComparablePair)o).getFirst(); + return ""; + } + }); myPackagesPanel = ToolbarDecorator.createDecorator(this.myPackages).disableAddAction(). disableUpDownActions().disableRemoveAction().addExtraAction(reloadButton).createPanel(); myPackagesPanel.setPreferredSize(new Dimension(400, -1)); From b48f0896d31b403f646432b4cbd0b253f5f4c844 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Thu, 20 Sep 2012 16:10:49 +0400 Subject: [PATCH 7/9] fixed PY-6282 Move statement: adds newline between parts of compound statement --- .../codeInsight/editorActions/moveUpDown/StatementMover.java | 3 +++ python/testData/mover/removePass.py | 5 +++++ python/testData/mover/removePass_afterDown.py | 4 ++++ python/testData/mover/removePass_afterUp.py | 5 +++++ .../testSrc/com/jetbrains/python/PyStatementMoverTest.java | 4 ++++ 5 files changed, 21 insertions(+) create mode 100644 python/testData/mover/removePass.py create mode 100644 python/testData/mover/removePass_afterDown.py create mode 100644 python/testData/mover/removePass_afterUp.py diff --git a/python/src/com/jetbrains/python/codeInsight/editorActions/moveUpDown/StatementMover.java b/python/src/com/jetbrains/python/codeInsight/editorActions/moveUpDown/StatementMover.java index 08879b0d222b..eb01b9900107 100644 --- a/python/src/com/jetbrains/python/codeInsight/editorActions/moveUpDown/StatementMover.java +++ b/python/src/com/jetbrains/python/codeInsight/editorActions/moveUpDown/StatementMover.java @@ -495,6 +495,9 @@ public class StatementMover extends LineMover { PyStatementList statementList = myStatementPartToRemovePass.getStatementList(); if (statementList != null) { PyPsiUtils.removeRedundantPass(statementList); + final PsiElement whitespace = myStatementPartToRemovePass.getNextSibling(); + if (whitespace instanceof PsiWhiteSpace) + whitespace.delete(); } } } diff --git a/python/testData/mover/removePass.py b/python/testData/mover/removePass.py new file mode 100644 index 000000000000..e2e577bb5759 --- /dev/null +++ b/python/testData/mover/removePass.py @@ -0,0 +1,5 @@ +a = 1 # <- move statement down here +if True: + pass +else: + b = 2 \ No newline at end of file diff --git a/python/testData/mover/removePass_afterDown.py b/python/testData/mover/removePass_afterDown.py new file mode 100644 index 000000000000..802fa82e459e --- /dev/null +++ b/python/testData/mover/removePass_afterDown.py @@ -0,0 +1,4 @@ +if True: + a = 1 # <- move statement down here +else: + b = 2 \ No newline at end of file diff --git a/python/testData/mover/removePass_afterUp.py b/python/testData/mover/removePass_afterUp.py new file mode 100644 index 000000000000..1b19556d5c95 --- /dev/null +++ b/python/testData/mover/removePass_afterUp.py @@ -0,0 +1,5 @@ +a = 1 # <- move statement down here +if True: + pass +else: + b = 2 \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyStatementMoverTest.java b/python/testSrc/com/jetbrains/python/PyStatementMoverTest.java index c633d21e389d..4ff89028390d 100644 --- a/python/testSrc/com/jetbrains/python/PyStatementMoverTest.java +++ b/python/testSrc/com/jetbrains/python/PyStatementMoverTest.java @@ -173,6 +173,10 @@ public class PyStatementMoverTest extends PyTestCase { doTest(); } + public void testRemovePass() { // PY-6282 + doTest(); + } + public void testWith() { // PY-5202 try { setLanguageLevel(LanguageLevel.PYTHON27); From 26652dbb59e102491dabb2bdd4216ce3c8986240 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 21 Sep 2012 12:57:06 +0200 Subject: [PATCH 8/9] Deprecate and replace some TokenSet methods --- .../PythonFormattingModelBuilder.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java b/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java index ccc1c132a79c..99a5e9b3ab90 100644 --- a/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java +++ b/python/src/com/jetbrains/python/formatter/PythonFormattingModelBuilder.java @@ -8,6 +8,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; +import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.IFileElementType; import com.intellij.psi.tree.TokenSet; import com.jetbrains.python.PythonDialectsTokenSetProvider; @@ -20,6 +21,7 @@ import static com.jetbrains.python.PyTokenTypes.*; /** * @author yole */ +@SuppressWarnings("UseOfSystemOutOrSystemErr") public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, CustomFormattingModelBuilder { private static final boolean DUMP_FORMATTING_AST = false; @@ -50,12 +52,12 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C protected SpacingBuilder createSpacingBuilder(CodeStyleSettings settings) { final IFileElementType file = LanguageParserDefinitions.INSTANCE.forLanguage(PythonLanguage.getInstance()).getFileNodeType(); final PyCodeStyleSettings pySettings = settings.getCustomSettings(PyCodeStyleSettings.class); - final TokenSet STATEMENT_OR_DECLARATION = TokenSet.orSet(PythonDialectsTokenSetProvider.INSTANCE.getStatementTokens(), - CLASS_OR_FUNCTION); + final TokenSet STATEMENT_OR_DECLARATION = + TokenSet.orSet(PythonDialectsTokenSetProvider.INSTANCE.getStatementTokens(), CLASS_OR_FUNCTION); final CommonCodeStyleSettings commonSettings = settings.getCommonSettings(PythonLanguage.getInstance()); return new SpacingBuilder(settings) - .between(IMPORT_STATEMENTS, STATEMENT_OR_DECLARATION.minus(IMPORT_STATEMENTS)).blankLines(commonSettings.BLANK_LINES_AFTER_IMPORTS) + .between(IMPORT_STATEMENTS, TokenSet.andNot(STATEMENT_OR_DECLARATION, IMPORT_STATEMENTS)).blankLines(commonSettings.BLANK_LINES_AFTER_IMPORTS) .betweenInside(CLASS_OR_FUNCTION, CLASS_OR_FUNCTION, file).blankLines(pySettings.BLANK_LINES_BETWEEN_TOP_LEVEL_CLASSES_FUNCTIONS) .between(CLASS_DECLARATION, STATEMENT_OR_DECLARATION).blankLines(commonSettings.BLANK_LINES_AROUND_CLASS) .between(STATEMENT_OR_DECLARATION, CLASS_DECLARATION).blankLines(commonSettings.BLANK_LINES_AROUND_CLASS) @@ -71,9 +73,9 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C .afterInside(GT, ANNOTATION).spaces(1) .betweenInside(MINUS, GT, ANNOTATION).none() .beforeInside(ANNOTATION, FUNCTION_DECLARATION).spaces(1) - - .between(TokenSet.not(TokenSet.create(LAMBDA_KEYWORD)), PARAMETER_LIST).spaceIf(commonSettings.SPACE_BEFORE_METHOD_PARENTHESES) - + + .between(allButLambda(), PARAMETER_LIST).spaceIf(commonSettings.SPACE_BEFORE_METHOD_PARENTHESES) + .before(COLON).spaceIf(pySettings.SPACE_BEFORE_PY_COLON) .after(COMMA).spaceIf(commonSettings.SPACE_AFTER_COMMA) .before(COMMA).spaceIf(commonSettings.SPACE_BEFORE_COMMA) @@ -103,6 +105,16 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C .around(IN_KEYWORD).spaces(1); } + private static TokenSet allButLambda() { + final PythonLanguage pythonLanguage = PythonLanguage.getInstance(); + return TokenSet.create(IElementType.enumerate(new IElementType.Predicate() { + @Override + public boolean matches(IElementType type) { + return type != LAMBDA_KEYWORD && type.getLanguage().isKindOf(pythonLanguage); + } + })); + } + public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) { return null; } From a94b5805f334f8bb7300dcfc5ed432713dbfe498 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 21 Sep 2012 18:43:46 +0200 Subject: [PATCH 9/9] Drop usages of now-unneeded HtmlListCellRenderer --- .../python/facet/PythonSdkComboBox.java | 2 +- .../packaging/PyManagePackagesDialog.java | 2 +- .../python/run/PyPluginCommonOptionsForm.java | 4 ++-- .../ModuleAwareProjectConfigurable.java | 2 +- .../python/run/PyModuleRenderer.java | 15 ++++-------- .../python/sdk/CreateVirtualEnvDialog.java | 4 +--- .../python/sdk/PySdkListCellRenderer.java | 24 ++++++++++--------- 7 files changed, 24 insertions(+), 29 deletions(-) diff --git a/python/pluginSrc/com/jetbrains/python/facet/PythonSdkComboBox.java b/python/pluginSrc/com/jetbrains/python/facet/PythonSdkComboBox.java index 7f8bb9794116..d15dc5fe8000 100644 --- a/python/pluginSrc/com/jetbrains/python/facet/PythonSdkComboBox.java +++ b/python/pluginSrc/com/jetbrains/python/facet/PythonSdkComboBox.java @@ -21,7 +21,7 @@ public class PythonSdkComboBox extends ComboboxWithBrowseButton { private Project myProject; public PythonSdkComboBox() { - getComboBox().setRenderer(new SdkListCellRenderer("", getComboBox().getRenderer())); + getComboBox().setRenderer(new SdkListCellRenderer("")); addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Sdk selectedSdk = getSelectedSdk(); diff --git a/python/pluginSrc/com/jetbrains/python/packaging/PyManagePackagesDialog.java b/python/pluginSrc/com/jetbrains/python/packaging/PyManagePackagesDialog.java index 3440226b445b..4da9d0c1c5e2 100644 --- a/python/pluginSrc/com/jetbrains/python/packaging/PyManagePackagesDialog.java +++ b/python/pluginSrc/com/jetbrains/python/packaging/PyManagePackagesDialog.java @@ -27,7 +27,7 @@ public class PyManagePackagesDialog extends DialogWrapper { setTitle("Manage Python Packages"); final JComboBox sdkComboBox = new JComboBox(new CollectionComboBoxModel(PythonSdkType.getAllSdks(), sdk)); - sdkComboBox.setRenderer(new PySdkListCellRenderer(sdkComboBox.getRenderer(), null)); + sdkComboBox.setRenderer(new PySdkListCellRenderer(null)); PyPackagesNotificationPanel notificationPanel = new PyPackagesNotificationPanel(project); final PyPackagesPanel packagesPanel = new PyPackagesPanel(project, notificationPanel); diff --git a/python/pluginSrc/com/jetbrains/python/run/PyPluginCommonOptionsForm.java b/python/pluginSrc/com/jetbrains/python/run/PyPluginCommonOptionsForm.java index 706cba7f24a7..d36f7ae00385 100644 --- a/python/pluginSrc/com/jetbrains/python/run/PyPluginCommonOptionsForm.java +++ b/python/pluginSrc/com/jetbrains/python/run/PyPluginCommonOptionsForm.java @@ -43,9 +43,9 @@ public class PyPluginCommonOptionsForm implements AbstractPyCommonOptionsForm { final List validModules = data.getValidModules(); Module selection = validModules.size() > 0 ? validModules.get(0) : null; myModuleComboBox.setModel(new CollectionComboBoxModel(validModules, selection)); - myModuleComboBox.setRenderer(new PyModuleRenderer(PyPluginCommonOptionsForm.this.myModuleComboBox.getRenderer())); + myModuleComboBox.setRenderer(new PyModuleRenderer()); - myInterpreterComboBox.setRenderer(new SdkListCellRenderer("", myInterpreterComboBox.getRenderer())); + myInterpreterComboBox.setRenderer(new SdkListCellRenderer("")); myWorkingDirectoryTextField.addBrowseFolderListener("Select Working Directory", "", data.getProject(), FileChooserDescriptorFactory.createSingleFolderDescriptor()); diff --git a/python/src/com/jetbrains/python/configuration/ModuleAwareProjectConfigurable.java b/python/src/com/jetbrains/python/configuration/ModuleAwareProjectConfigurable.java index 85bdce6ad9c7..0eeacec435ee 100644 --- a/python/src/com/jetbrains/python/configuration/ModuleAwareProjectConfigurable.java +++ b/python/src/com/jetbrains/python/configuration/ModuleAwareProjectConfigurable.java @@ -68,7 +68,7 @@ public abstract class ModuleAwareProjectConfigurable(modules)); moduleList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - moduleList.setCellRenderer(new PyModuleRenderer(moduleList.getCellRenderer())); + moduleList.setCellRenderer(new PyModuleRenderer()); splitter.setFirstComponent(new JBScrollPane(moduleList)); final CardLayout layout = new CardLayout(); final JPanel cardPanel = new JPanel(layout); diff --git a/python/src/com/jetbrains/python/run/PyModuleRenderer.java b/python/src/com/jetbrains/python/run/PyModuleRenderer.java index 2f33de12ed8c..4c489709affe 100644 --- a/python/src/com/jetbrains/python/run/PyModuleRenderer.java +++ b/python/src/com/jetbrains/python/run/PyModuleRenderer.java @@ -2,27 +2,22 @@ package com.jetbrains.python.run; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleType; -import com.intellij.ui.HtmlListCellRenderer; -import com.intellij.ui.SimpleTextAttributes; +import com.intellij.ui.ListCellRendererWrapper; import javax.swing.*; /** * @author yole */ -public class PyModuleRenderer extends HtmlListCellRenderer { - public PyModuleRenderer(final ListCellRenderer renderer) { - super(); - } - +public class PyModuleRenderer extends ListCellRendererWrapper { @Override - protected void doCustomize(JList list, Module module, int index, boolean selected, boolean hasFocus) { + public void customize(JList list, Module module, int index, boolean selected, boolean hasFocus) { if (module == null) { - append("[none]", SimpleTextAttributes.REGULAR_ATTRIBUTES); + setText("[none]"); } else { setIcon(ModuleType.get(module).getIcon()); - append(module.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES); + setText(module.getName()); } } } diff --git a/python/src/com/jetbrains/python/sdk/CreateVirtualEnvDialog.java b/python/src/com/jetbrains/python/sdk/CreateVirtualEnvDialog.java index 1891c7bd602b..3c2c83425e23 100644 --- a/python/src/com/jetbrains/python/sdk/CreateVirtualEnvDialog.java +++ b/python/src/com/jetbrains/python/sdk/CreateVirtualEnvDialog.java @@ -10,7 +10,6 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.platform.LocationNameFieldsBinding; import com.intellij.ui.CollectionComboBoxModel; import com.intellij.ui.DocumentAdapter; -import com.intellij.ui.HtmlListCellRenderer; import com.intellij.ui.components.JBCheckBox; import com.intellij.util.PathUtil; import com.jetbrains.python.packaging.PyPackageService; @@ -158,8 +157,7 @@ public class CreateVirtualEnvDialog extends IdeaDialog { } private void updateSdkList(Sdk sdk, final List allSdks) { - final HtmlListCellRenderer sdkListCellRenderer = new PySdkListCellRenderer(mySdkCombo.getRenderer(), null); - mySdkCombo.setRenderer(sdkListCellRenderer); + mySdkCombo.setRenderer(new PySdkListCellRenderer(null)); List baseSdks = new ArrayList(); for (Sdk s : allSdks) { if (!PythonSdkType.isInvalid(s) && !PythonSdkType.isVirtualEnv(s) && !PythonRemoteSdkAdditionalData.isRemoteSdk(s.getHomePath())) { diff --git a/python/src/com/jetbrains/python/sdk/PySdkListCellRenderer.java b/python/src/com/jetbrains/python/sdk/PySdkListCellRenderer.java index 863244918eeb..09c8e52d31a5 100644 --- a/python/src/com/jetbrains/python/sdk/PySdkListCellRenderer.java +++ b/python/src/com/jetbrains/python/sdk/PySdkListCellRenderer.java @@ -4,34 +4,36 @@ import com.intellij.icons.AllIcons; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.projectRoots.SdkModificator; import com.intellij.openapi.projectRoots.SdkType; -import com.intellij.ui.HtmlListCellRenderer; import com.intellij.ui.LayeredIcon; +import com.intellij.ui.ListCellRendererWrapper; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.Map; -public class PySdkListCellRenderer extends HtmlListCellRenderer { - private final Map mySdkModificators; +public class PySdkListCellRenderer extends ListCellRendererWrapper { + private final Map mySdkModifiers; - public PySdkListCellRenderer(ListCellRenderer listCellRenderer, Map sdkModificators) { - super(); - mySdkModificators = sdkModificators; + public PySdkListCellRenderer(@Nullable Map sdkModifiers) { + mySdkModifiers = sdkModifiers; } @Override - protected void doCustomize(final JList list, final Sdk sdk, final int index, final boolean selected, final boolean hasFocus) { + public void customize(JList list, Sdk sdk, int index, boolean selected, boolean hasFocus) { if (sdk != null) { final PythonSdkFlavor flavor = PythonSdkFlavor.getPlatformIndependentFlavor(sdk.getHomePath()); final Icon icon = flavor != null ? flavor.getIcon() : ((SdkType) sdk.getSdkType()).getIcon(); + final String name; - if (mySdkModificators != null && mySdkModificators.containsKey(sdk)) { - name = mySdkModificators.get(sdk).getName(); + if (mySdkModifiers != null && mySdkModifiers.containsKey(sdk)) { + name = mySdkModifiers.get(sdk).getName(); } else { name = sdk.getName(); } + if (PythonSdkType.isInvalid(sdk)) { - append("[invalid] " + name); + setText("[invalid] " + name); final LayeredIcon layered = new LayeredIcon(2); layered.setIcon(icon, 0); // TODO: Create a separate invalid SDK overlay icon @@ -40,7 +42,7 @@ public class PySdkListCellRenderer extends HtmlListCellRenderer { setIcon(layered); } else { - append(name); + setText(name); setIcon(icon); } }