コード例 #1
0
 private static boolean isAbstractMethodForClass(
     @NotNull PyFunction method, @NotNull PyClass cls) {
   final String methodName = method.getName();
   if (methodName == null
       || cls.findMethodByName(methodName, false) != null
       || cls.findClassAttribute(methodName, false) != null) {
     return false;
   }
   return PyUtil.isDecoratedAsAbstract(method)
       || PyOverrideImplementUtil.raisesNotImplementedError(method);
 }
コード例 #2
0
 @Override
 public void visitPyClass(PyClass pyClass) {
   if (isAbstract(pyClass)) {
     return;
   }
   final Set<PyFunction> toBeImplemented = new HashSet<PyFunction>();
   final Collection<PyFunction> functions =
       PyOverrideImplementUtil.getAllSuperFunctions(pyClass);
   for (PyFunction method : functions) {
     if (isAbstractMethodForClass(method, pyClass)) {
       toBeImplemented.add(method);
     }
   }
   final ASTNode nameNode = pyClass.getNameNode();
   if (!toBeImplemented.isEmpty() && nameNode != null) {
     registerProblem(
         nameNode.getPsi(),
         PyBundle.message("INSP.NAME.abstract.class.$0.must.implement", pyClass.getName()),
         new PyImplementMethodsQuickFix(pyClass, toBeImplemented));
   }
 }