diff --git a/python/python-psi-impl/resources/META-INF/PythonPsiImpl.xml b/python/python-psi-impl/resources/META-INF/PythonPsiImpl.xml index 0157ce0cf716..3dd876927b5e 100644 --- a/python/python-psi-impl/resources/META-INF/PythonPsiImpl.xml +++ b/python/python-psi-impl/resources/META-INF/PythonPsiImpl.xml @@ -164,7 +164,6 @@ - diff --git a/python/python-psi-impl/resources/inspectionDescriptions/PyStringExceptionInspection.html b/python/python-psi-impl/resources/inspectionDescriptions/PyStringExceptionInspection.html deleted file mode 100644 index bd79d31cac85..000000000000 --- a/python/python-psi-impl/resources/inspectionDescriptions/PyStringExceptionInspection.html +++ /dev/null @@ -1,5 +0,0 @@ - - -This inspection detects when a string exception is raised. - - \ No newline at end of file diff --git a/python/python-psi-impl/resources/messages/PyPsiBundle.properties b/python/python-psi-impl/resources/messages/PyPsiBundle.properties index 55a0da744518..21eb7a600742 100644 --- a/python/python-psi-impl/resources/messages/PyPsiBundle.properties +++ b/python/python-psi-impl/resources/messages/PyPsiBundle.properties @@ -344,7 +344,6 @@ QFIX.remove.trailing.semicolon=Remove trailing semicolon QFIX.introduce.variable=Introduce variable for statement QFIX.NAME.make.list=Replace tuple with list QFIX.NAME.add.specifier=Add format specifier character -QFIX.NAME.wrap.in.exception=Wrap with Exception call QFIX.add.global=Add global statement QFIX.create.property=Create property QFIX.add.property=Add property for the field @@ -462,7 +461,6 @@ INSP.abstract.class.add.to.superclasses=Add ''{0}'' to superclasses INSP.named.tuple=Namedtuple definition INSP.shadows.name.from.outer.scope=Shadows name ''{0}'' from outer scope INSP.trailing.semicolon=Trailing semicolon in the statement -INSP.raising.string.exception=Raising a string exception INSP.protected.member.ignore.annotations=Ignore annotations INSP.protected.member.ignore.test.functions=Ignore test functions INSP.docstring.types.fix.docstring=Fix docstring @@ -626,9 +624,6 @@ INSP.NAME.statement.effect=Statement has no effect INSP.statement.effect.statement.seems.to.have.no.effect=Statement seems to have no effect INSP.statement.effect.statement.having.no.effect.can.be.replaced.with.function.call=Statement seems to have no effect and can be replaced with a function call to have effect -# PyStringExceptionInspection -INSP.NAME.raising.string.exception=Raising a string exception - # PySuperArgumentsInspection INSP.NAME.wrong.super.arguments=Wrong arguments to call super INSP.class.is.not.subtype.of.class=''{0}'' is not an instance or a subclass of ''{1}'' diff --git a/python/python-psi-impl/src/com/jetbrains/python/inspections/PyStringExceptionInspection.java b/python/python-psi-impl/src/com/jetbrains/python/inspections/PyStringExceptionInspection.java deleted file mode 100644 index 7d21a6f4e9f1..000000000000 --- a/python/python-psi-impl/src/com/jetbrains/python/inspections/PyStringExceptionInspection.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2000-2014 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.inspections; - -import com.intellij.codeInspection.LocalInspectionToolSession; -import com.intellij.codeInspection.ProblemsHolder; -import com.intellij.psi.PsiElementVisitor; -import com.jetbrains.python.PyPsiBundle; -import com.jetbrains.python.inspections.quickfix.PyWrapInExceptionQuickFix; -import com.jetbrains.python.psi.PyExpression; -import com.jetbrains.python.psi.PyRaiseStatement; -import com.jetbrains.python.psi.PyStringLiteralExpression; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Alexey.Ivanov - */ -public class PyStringExceptionInspection extends PyInspection { - - @NotNull - @Override - public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, - boolean isOnTheFly, - @NotNull LocalInspectionToolSession session) { - return new Visitor(holder, session); - } - - private static class Visitor extends PyInspectionVisitor { - Visitor(@Nullable ProblemsHolder holder, @NotNull LocalInspectionToolSession session) { - super(holder, session); - } - - @Override - public void visitPyRaiseStatement(@NotNull PyRaiseStatement node) { - PyExpression[] expressions = node.getExpressions(); - if (expressions.length > 0) { - PyExpression expression = expressions[0]; - if (expression instanceof PyStringLiteralExpression) { - registerProblem(expression, PyPsiBundle.message("INSP.raising.string.exception"), new PyWrapInExceptionQuickFix()); - } - } - } - } -} diff --git a/python/python-psi-impl/src/com/jetbrains/python/inspections/quickfix/PyWrapInExceptionQuickFix.java b/python/python-psi-impl/src/com/jetbrains/python/inspections/quickfix/PyWrapInExceptionQuickFix.java deleted file mode 100644 index 89837bbaf23b..000000000000 --- a/python/python-psi-impl/src/com/jetbrains/python/inspections/quickfix/PyWrapInExceptionQuickFix.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2000-2014 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.inspections.quickfix; - -import com.intellij.codeInspection.LocalQuickFix; -import com.intellij.codeInspection.ProblemDescriptor; -import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiElement; -import com.jetbrains.python.PyPsiBundle; -import com.jetbrains.python.psi.*; -import org.jetbrains.annotations.NotNull; - -public class PyWrapInExceptionQuickFix implements LocalQuickFix { - @NotNull - @Override - public String getFamilyName() { - return PyPsiBundle.message("QFIX.NAME.wrap.in.exception"); - } - - @Override - public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { - final PsiElement string = descriptor.getPsiElement(); - if (string instanceof PyStringLiteralExpression) { - final PyCallExpression callExpression = - PyElementGenerator.getInstance(project).createCallExpression(LanguageLevel.forElement(string), "Exception"); - final PyArgumentList list = callExpression.getArgumentList(); - assert list != null; - list.addArgument((PyExpression)string); - string.replace(callExpression); - } - } -} diff --git a/python/testData/inspections/PyStringExceptionInspection/expected.xml b/python/testData/inspections/PyStringExceptionInspection/expected.xml deleted file mode 100644 index 431157f30240..000000000000 --- a/python/testData/inspections/PyStringExceptionInspection/expected.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - test.py - 1 - Raising a string exception - - \ No newline at end of file diff --git a/python/testData/inspections/PyStringExceptionInspection/src/test.py b/python/testData/inspections/PyStringExceptionInspection/src/test.py deleted file mode 100644 index 854cafd42435..000000000000 --- a/python/testData/inspections/PyStringExceptionInspection/src/test.py +++ /dev/null @@ -1,2 +0,0 @@ -raise "exception" -raise Exception() \ No newline at end of file diff --git a/python/testData/quickFixes/PyWrapInExceptionQuickFixTest/inFunction.py b/python/testData/quickFixes/PyWrapInExceptionQuickFixTest/inFunction.py deleted file mode 100644 index 9ec2f14cced1..000000000000 --- a/python/testData/quickFixes/PyWrapInExceptionQuickFixTest/inFunction.py +++ /dev/null @@ -1,2 +0,0 @@ -def foo(): - raise "String" "String1" \ No newline at end of file diff --git a/python/testData/quickFixes/PyWrapInExceptionQuickFixTest/inFunction_after.py b/python/testData/quickFixes/PyWrapInExceptionQuickFixTest/inFunction_after.py deleted file mode 100644 index dbfcf874e54f..000000000000 --- a/python/testData/quickFixes/PyWrapInExceptionQuickFixTest/inFunction_after.py +++ /dev/null @@ -1,2 +0,0 @@ -def foo(): - raise Exception("String" "String1") \ No newline at end of file diff --git a/python/testData/quickFixes/PyWrapInExceptionQuickFixTest/simple.py b/python/testData/quickFixes/PyWrapInExceptionQuickFixTest/simple.py deleted file mode 100644 index ceda0bc91669..000000000000 --- a/python/testData/quickFixes/PyWrapInExceptionQuickFixTest/simple.py +++ /dev/null @@ -1 +0,0 @@ -raise "Some String" \ No newline at end of file diff --git a/python/testData/quickFixes/PyWrapInExceptionQuickFixTest/simple_after.py b/python/testData/quickFixes/PyWrapInExceptionQuickFixTest/simple_after.py deleted file mode 100644 index 9c7ddbf2b3f1..000000000000 --- a/python/testData/quickFixes/PyWrapInExceptionQuickFixTest/simple_after.py +++ /dev/null @@ -1 +0,0 @@ -raise Exception("Some String") \ 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 8bdb0c6b8667..97efa335c722 100644 --- a/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java +++ b/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java @@ -137,11 +137,6 @@ public class PythonInspectionsTest extends PyTestCase { doTest(getTestName(false), inspection); } - public void testPyStringExceptionInspection() { - LocalInspectionTool inspection = new PyStringExceptionInspection(); - doTest(getTestName(false), inspection); - } - public void testPySuperArgumentsInspection() { LocalInspectionTool inspection = new PySuperArgumentsInspection(); doTest(getTestName(false), inspection); diff --git a/python/testSrc/com/jetbrains/python/quickFixes/PyWrapInExceptionQuickFixTest.java b/python/testSrc/com/jetbrains/python/quickFixes/PyWrapInExceptionQuickFixTest.java deleted file mode 100644 index 9543d25188bb..000000000000 --- a/python/testSrc/com/jetbrains/python/quickFixes/PyWrapInExceptionQuickFixTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2000-2013 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.quickFixes; - -import com.intellij.testFramework.TestDataPath; -import com.jetbrains.python.PyPsiBundle; -import com.jetbrains.python.PyQuickFixTestCase; -import com.jetbrains.python.inspections.PyStringExceptionInspection; - -@TestDataPath("$CONTENT_ROOT/../testData/quickFixes/PyWrapInExceptionQuickFixTest/") -public class PyWrapInExceptionQuickFixTest extends PyQuickFixTestCase { - - public void testSimple() { - doQuickFixTest(PyStringExceptionInspection.class, PyPsiBundle.message("QFIX.NAME.wrap.in.exception")); - } - - public void testInFunction() { - doQuickFixTest(PyStringExceptionInspection.class, PyPsiBundle.message("QFIX.NAME.wrap.in.exception")); - } -}