diff --git a/python/helpers/pycharm/_jb_runner_tools.py b/python/helpers/pycharm/_jb_runner_tools.py index cde91b21a047..d5e87a02141b 100644 --- a/python/helpers/pycharm/_jb_runner_tools.py +++ b/python/helpers/pycharm/_jb_runner_tools.py @@ -36,7 +36,7 @@ messages.TeamcityServiceMessages.message = __jb_message def jb_patch_separator(targets, fs_glue, python_glue, fs_to_python_glue): """ Targets are always dot separated according to manual. - How ever, some runners may need different separators. + However, some runners may need different separators. This function splits target to file/symbol parts and glues them using provided glues. :param targets: list of dot-separated targets diff --git a/python/src/com/jetbrains/python/PyFileChooserDescriptor.java b/python/src/com/jetbrains/python/PyFileChooserDescriptor.java deleted file mode 100644 index 962bbde1a2e2..000000000000 --- a/python/src/com/jetbrains/python/PyFileChooserDescriptor.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jetbrains.python; - -import com.intellij.openapi.fileChooser.FileChooserDescriptor; -import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.vfs.VirtualFile; - -/** - * Descriptor to choose only .py files and (probably) folders. - * @author Ilya.Kazakevich - */ -public final class PyFileChooserDescriptor extends FileChooserDescriptor { - public PyFileChooserDescriptor(final boolean chooseFolders) {super(true, chooseFolders, false, false, false, false);} - - @Override - public boolean isFileVisible(final VirtualFile file, final boolean showHiddenFiles) { - return file.isDirectory() || file.getExtension() == null || Comparing.equal(file.getExtension(), "py"); - } -} diff --git a/python/src/com/jetbrains/python/PythonHelper.java b/python/src/com/jetbrains/python/PythonHelper.java index 49a9f50f125c..4425967e6c84 100644 --- a/python/src/com/jetbrains/python/PythonHelper.java +++ b/python/src/com/jetbrains/python/PythonHelper.java @@ -49,18 +49,18 @@ public enum PythonHelper implements HelperPackage { LOAD_ENTRY_POINT("pycharm", "pycharm_load_entry_point"), // Test runners - UT("pycharm", "utrunner"), + UT_OLD("pycharm", "utrunner"), TOX("pycharm", "_jb_tox_runner"), SETUPPY("pycharm", "pycharm_setup_runner"), - NOSE("pycharm", "noserunner"), - PYTEST("pycharm", "pytestrunner"), + NOSE_OLD("pycharm", "noserunner"), + PYTEST_OLD("pycharm", "pytestrunner"), DOCSTRING("pycharm", "docrunner"), // Runners for new test runner API. - UNIVERSAL_UT("pycharm", "_jb_unittest_runner"), - UNIVERSAL_PYTEST("pycharm", "_jb_pytest_runner"), - UNIVERSAL_NOSE("pycharm", "_jb_nosetest_runner"), + UNITTEST("pycharm", "_jb_unittest_runner"), + PYTEST("pycharm", "_jb_pytest_runner"), + NOSE("pycharm", "_jb_nosetest_runner"), BEHAVE("pycharm", "behave_runner"), LETTUCE("pycharm", "lettuce_runner"), diff --git a/python/src/com/jetbrains/python/run/PythonRunConfigurationForm.java b/python/src/com/jetbrains/python/run/PythonRunConfigurationForm.java index b83aef4e59f0..bf9ca13ba021 100644 --- a/python/src/com/jetbrains/python/run/PythonRunConfigurationForm.java +++ b/python/src/com/jetbrains/python/run/PythonRunConfigurationForm.java @@ -28,7 +28,6 @@ import com.intellij.ui.PanelWithAnchor; import com.intellij.ui.RawCommandLineEditor; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; -import com.jetbrains.python.PyFileChooserDescriptor; import com.jetbrains.python.debugger.PyDebuggerOptionsProvider; import org.jetbrains.annotations.NotNull; @@ -58,7 +57,12 @@ public class PythonRunConfigurationForm implements PythonRunConfigurationParams, myProject = configuration.getProject(); - FileChooserDescriptor chooserDescriptor = new PyFileChooserDescriptor(false); + FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) { + @Override + public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { + return file.isDirectory() || file.getExtension() == null || Comparing.equal(file.getExtension(), "py"); + } + }; //chooserDescriptor.setRoot(s.getProject().getBaseDir()); ComponentWithBrowseButton.BrowseFolderActionListener listener = diff --git a/python/src/com/jetbrains/python/testing/nosetest/PythonNoseTestCommandLineState.java b/python/src/com/jetbrains/python/testing/nosetest/PythonNoseTestCommandLineState.java index e83027d88799..35e453becde2 100644 --- a/python/src/com/jetbrains/python/testing/nosetest/PythonNoseTestCommandLineState.java +++ b/python/src/com/jetbrains/python/testing/nosetest/PythonNoseTestCommandLineState.java @@ -42,7 +42,7 @@ public class PythonNoseTestCommandLineState extends PythonTestCommandLineStateBa @Override protected PythonHelper getRunner() { - return PythonHelper.NOSE; + return PythonHelper.NOSE_OLD; } @NotNull diff --git a/python/src/com/jetbrains/python/testing/pytest/PyTestCommandLineState.java b/python/src/com/jetbrains/python/testing/pytest/PyTestCommandLineState.java index 6af1e81e75a7..004463f60d48 100644 --- a/python/src/com/jetbrains/python/testing/pytest/PyTestCommandLineState.java +++ b/python/src/com/jetbrains/python/testing/pytest/PyTestCommandLineState.java @@ -52,7 +52,7 @@ public class PyTestCommandLineState extends PythonTestCommandLineStateBase { @Override protected HelperPackage getRunner() { - return PythonHelper.PYTEST; + return PythonHelper.PYTEST_OLD; } @NotNull diff --git a/python/src/com/jetbrains/python/testing/unittest/PythonUnitTestCommandLineState.java b/python/src/com/jetbrains/python/testing/unittest/PythonUnitTestCommandLineState.java index 540fd1b05ad6..c20281f6c4ac 100644 --- a/python/src/com/jetbrains/python/testing/unittest/PythonUnitTestCommandLineState.java +++ b/python/src/com/jetbrains/python/testing/unittest/PythonUnitTestCommandLineState.java @@ -48,7 +48,7 @@ public class PythonUnitTestCommandLineState extends PythonTestCommandLineStateBa if (myConfig.getTestType() == AbstractPythonOldTestRunConfiguration.TestType.TEST_SCRIPT && myConfig.getScriptName().endsWith(PyNames.SETUP_DOT_PY)) return PythonHelper.SETUPPY; - return PythonHelper.UT; + return PythonHelper.UT_OLD; } @NotNull diff --git a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalNoseTest.kt b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalNoseTest.kt index 831486ab15c3..614cac29560d 100644 --- a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalNoseTest.kt +++ b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalNoseTest.kt @@ -34,7 +34,7 @@ class PyUniversalNoseTestSettingsEditor(configuration: PyUniversalTestConfigurat class PyUniversalNoseTestExecutionEnvironment(configuration: PyUniversalNoseTestConfiguration, environment: ExecutionEnvironment) : PyUniversalTestExecutionEnvironment(configuration, environment) { - override fun getRunner() = PythonHelper.UNIVERSAL_NOSE + override fun getRunner() = PythonHelper.NOSE } diff --git a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalPyTest.kt b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalPyTest.kt index f47d30f42fc7..39256d07e854 100644 --- a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalPyTest.kt +++ b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalPyTest.kt @@ -32,7 +32,7 @@ class PyUniversalPyTestSettingsEditor(configuration: PyUniversalTestConfiguratio class PyUniversalPyTestExecutionEnvironment(configuration: PyUniversalPyTestConfiguration, environment: ExecutionEnvironment) : PyUniversalTestExecutionEnvironment(configuration, environment) { - override fun getRunner() = PythonHelper.UNIVERSAL_PYTEST + override fun getRunner() = PythonHelper.PYTEST } diff --git a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalTestForm.java b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalTestForm.java index e793752537f0..a4a6aee2952a 100644 --- a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalTestForm.java +++ b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalTestForm.java @@ -15,6 +15,8 @@ */ package com.jetbrains.python.testing.universalTests; +import com.intellij.openapi.fileChooser.FileChooserDescriptor; +import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.components.JBLabel; @@ -23,7 +25,7 @@ import com.intellij.ui.components.JBTextField; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.util.ArrayUtil; -import com.jetbrains.python.PyFileChooserDescriptor; +import com.jetbrains.python.PythonFileType; import com.jetbrains.python.run.AbstractPyCommonOptionsForm; import com.jetbrains.python.run.PyCommonOptionsFormFactory; import com.jetbrains.reflection.ReflectionUtilsKt; @@ -106,8 +108,9 @@ public final class PyUniversalTestForm implements SimplePropertiesProvider { final PyUniversalTestForm form = new PyUniversalTestForm(); + final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(PythonFileType.INSTANCE); form.myTargetText.addBrowseFolderListener("Choose File or Folder", null, configuration.getProject(), - new PyFileChooserDescriptor(true)); + descriptor); for (final TestTargetType testTargetType : TestTargetType.values()) { final JBRadioButton button = new JBRadioButton(StringUtil.capitalize(testTargetType.name().toLowerCase(Locale.getDefault()))); diff --git a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalTests.kt b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalTests.kt index 5c836a43db15..daa2330370f0 100644 --- a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalTests.kt +++ b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalTests.kt @@ -286,7 +286,7 @@ abstract class PyUniversalTestConfiguration(project: Project, } - private fun getConfigFields() = getProperties(this, ConfigField::class) + private fun getConfigFields() = getProperties(this, ConfigField::class.java) /** * Checks if element could be test target for this config. diff --git a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalUnitTest.kt b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalUnitTest.kt index 89f7862dc021..0ce0e5647fe8 100644 --- a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalUnitTest.kt +++ b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalUnitTest.kt @@ -34,7 +34,7 @@ class PyUniversalUnitTestSettingsEditor(configuration: PyUniversalTestConfigurat class PyUniversalUnitTestExecutionEnvironment(configuration: PyUniversalUnitTestConfiguration, environment: ExecutionEnvironment) : PyUniversalTestExecutionEnvironment(configuration, environment) { - override fun getRunner() = PythonHelper.UNIVERSAL_UT + override fun getRunner() = PythonHelper.UNITTEST } diff --git a/python/src/com/jetbrains/reflection/ReflectionUtils.kt b/python/src/com/jetbrains/reflection/ReflectionUtils.kt index 0b3508952fae..4ef38fef1247 100644 --- a/python/src/com/jetbrains/reflection/ReflectionUtils.kt +++ b/python/src/com/jetbrains/reflection/ReflectionUtils.kt @@ -100,11 +100,12 @@ private fun KProperty<*>.isAnnotated(annotation: KClass<*>): Boolean { /** * @param instance object with properties (see module doc) - * @param annotationToFilterBy optional annotation class to fetch only kotlin properties annotated with it. Only supported in Kotlin + * @param annotationToFilterByClass optional annotation class to fetch only kotlin properties annotated with it. Only supported in Kotlin * @param usePojoProperties search for java-style properties (kotlin otherwise) * @return properties of some object */ -fun getProperties(instance: Any, annotationToFilterBy: KClass<*>? = null, usePojoProperties: Boolean = false): Properties { +fun getProperties(instance: Any, annotationToFilterByClass: Class<*>? = null, usePojoProperties: Boolean = false): Properties { + val annotationToFilterBy = annotationToFilterByClass?.kotlin if (usePojoProperties) { // Java props @@ -121,7 +122,7 @@ fun getProperties(instance: Any, annotationToFilterBy: KClass<*>? = null, usePoj allKotlinProperties.filter { it.isAnnotated(DelegationProperty::class) }.forEach { val delegatedInstance = it.getter.call(instance) if (delegatedInstance != null) { - delegatedProperties = getProperties(delegatedInstance, annotationToFilterBy, false).properties + delegatedProperties = getProperties(delegatedInstance, annotationToFilterBy?.java, false).properties allKotlinProperties.remove(it) } }