void (final Collection<PyFunction> currentFunctions, final PyClass... to) { final Set<PsiFile> filesToCheckImport = new HashSet<>(); final Set<PyClass> classesToAddMetaAbc = new HashSet<>(); for (final PyFunction function : currentFunctions) { for (final PyClass destClass : to) { final PyFunctionBuilder functionBuilder = PyFunctionBuilder.copySignature(function, DECORATORS_MAY_BE_COPIED_TO_ABSTRACT); functionBuilder.decorate(PyNames.ABSTRACTMETHOD); PyFunction abstractMethod = functionBuilder.buildFunction(); PyDependenciesComparator.copyDependencyInfo(function, abstractMethod); PyClassRefactoringUtil.addMethods(destClass, false, abstractMethod); classesToAddMetaAbc.add(destClass); } } // Add ABCMeta to new classes if needed for (final PyClass aClass : classesToAddMetaAbc) { final Project project = aClass.getProject(); final PsiFile file = aClass.getContainingFile(); final PyClass abcMetaClass = PyPsiFacade.getInstance(project).createClassByQName(PyNames.ABC_META, aClass); final TypeEvalContext context = TypeEvalContext.userInitiated(project, file); if (abcMetaClass != null && PyPsiRefactoringUtil.addMetaClassIfNotExist(aClass, abcMetaClass, context)) { filesToCheckImport.add(file); } } // Add imports for ABC if needed for (final PsiFile file : filesToCheckImport) { AddImportHelper.addOrUpdateFromImportStatement(file, ABC_META_PACKAGE, PyNames.ABSTRACTMETHOD, null, ImportPriority.BUILTIN, null); PyClassRefactoringUtil.optimizeImports(file); //To remove redundant imports } }