diff --git a/python/src/com/jetbrains/python/inspections/PyAbstractClassInspection.java b/python/src/com/jetbrains/python/inspections/PyAbstractClassInspection.java index a781634f9c22..0b03eed5926a 100644 --- a/python/src/com/jetbrains/python/inspections/PyAbstractClassInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyAbstractClassInspection.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.jetbrains.python.inspections; import com.intellij.codeInspection.LocalInspectionToolSession; @@ -30,8 +16,7 @@ import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.HashSet; -import java.util.Set; +import java.util.List; import static com.jetbrains.python.psi.PyUtil.as; @@ -61,7 +46,7 @@ public class PyAbstractClassInspection extends PyInspection { if (isAbstract(pyClass)) { return; } - final Set toImplement = new HashSet<>(PyOverrideImplementUtil.getAllSuperAbstractMethods(pyClass, myTypeEvalContext)); + final List toImplement = PyOverrideImplementUtil.getAllSuperAbstractMethods(pyClass, myTypeEvalContext); final ASTNode nameNode = pyClass.getNameNode(); if (!toImplement.isEmpty() && nameNode != null) { registerProblem(nameNode.getPsi(), diff --git a/python/src/com/jetbrains/python/inspections/quickfix/PyImplementMethodsQuickFix.java b/python/src/com/jetbrains/python/inspections/quickfix/PyImplementMethodsQuickFix.java index e0c8358ecb64..4df920c84906 100644 --- a/python/src/com/jetbrains/python/inspections/quickfix/PyImplementMethodsQuickFix.java +++ b/python/src/com/jetbrains/python/inspections/quickfix/PyImplementMethodsQuickFix.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.jetbrains.python.inspections.quickfix; import com.intellij.codeInspection.LocalQuickFixOnPsiElement; @@ -30,14 +16,14 @@ import com.jetbrains.python.psi.PyFunction; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -import java.util.Set; +import java.util.Collection; public class PyImplementMethodsQuickFix extends LocalQuickFixOnPsiElement { @NotNull - private final Set myToImplement; + private final Collection myToImplement; - public PyImplementMethodsQuickFix(@NotNull PyClass cls, @NotNull Set toImplement) { + public PyImplementMethodsQuickFix(@NotNull PyClass cls, @NotNull Collection toImplement) { super(cls); myToImplement = toImplement; } diff --git a/python/testData/inspections/ImplementAbstractOrder.py b/python/testData/inspections/ImplementAbstractOrder.py new file mode 100644 index 000000000000..e784d21e52d2 --- /dev/null +++ b/python/testData/inspections/ImplementAbstractOrder.py @@ -0,0 +1,20 @@ +from abc import abstractmethod, ABCMeta + + +class Abstract: + __metaclass__ = ABCMeta + + @abstractmethod + def foo0(self): + pass + + @abstractmethod + def foo1(self): + pass + + def bar(self): + pass + + +class Foo(Abstract): + pass \ No newline at end of file diff --git a/python/testData/inspections/ImplementAbstractOrder_after.py b/python/testData/inspections/ImplementAbstractOrder_after.py new file mode 100644 index 000000000000..00db476eb27e --- /dev/null +++ b/python/testData/inspections/ImplementAbstractOrder_after.py @@ -0,0 +1,25 @@ +from abc import abstractmethod, ABCMeta + + +class Abstract: + __metaclass__ = ABCMeta + + @abstractmethod + def foo0(self): + pass + + @abstractmethod + def foo1(self): + pass + + def bar(self): + pass + + +class Foo(Abstract): + def foo0(self): + pass + + def foo1(self): + pass + diff --git a/python/testSrc/com/jetbrains/python/PyQuickFixTest.java b/python/testSrc/com/jetbrains/python/PyQuickFixTest.java index 90827c37e5df..3f755f3bacc7 100644 --- a/python/testSrc/com/jetbrains/python/PyQuickFixTest.java +++ b/python/testSrc/com/jetbrains/python/PyQuickFixTest.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 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. - */ +// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.jetbrains.python; import com.intellij.codeInsight.intention.IntentionAction; @@ -609,6 +595,14 @@ public class PyQuickFixTest extends PyTestCase { true, true); } + public void testImplementAbstractOrder() { + doInspectionTest("ImplementAbstractOrder.py", + PyAbstractClassInspection.class, + PyBundle.message("QFIX.NAME.implement.methods"), + true, + true); + } + public void testRemovingUnderscoresInNumericLiterals() { myFixture.configureByText(PythonFileType.INSTANCE, "1_0_0");