void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { PsiElement unresolvedReference = descriptor.getPsiElement(); if (unresolvedReference == null) { return; } PsiFile targetFile = myTargetFile.getElement(); if (targetFile == null) { return; } final boolean isPy3K = LanguageLevel.forElement(targetFile).isPy3K(); String superClass = isPy3K ? "" : "(object)"; PyClass pyClass = PyElementGenerator.getInstance(project).createFromText(LanguageLevel.getDefault(), PyClass.class, "class " + myClassName + superClass + ":\n" + " pass"); InjectedLanguageManager injectionManager = InjectedLanguageManager.getInstance(unresolvedReference.getProject()); PsiLanguageInjectionHost injectionHost = injectionManager.getInjectionHost(unresolvedReference); if (unresolvedReference.getContainingFile() == targetFile) { PsiElement insertionAnchor = PyPsiUtils.getParentRightBefore(unresolvedReference, targetFile); assert insertionAnchor != null; pyClass = (PyClass)insertionAnchor.getParent().addBefore(pyClass, insertionAnchor); } else if (injectionHost != null && injectionHost.getContainingFile() == targetFile) { PsiElement insertionAnchor = PyPsiUtils.getParentRightBefore(injectionHost, targetFile); assert insertionAnchor != null; pyClass = (PyClass)insertionAnchor.getParent().addBefore(pyClass, insertionAnchor); } else { pyClass = (PyClass)targetFile.add(pyClass); } pyClass = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(pyClass); final TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(pyClass); if (!isPy3K) { builder.replaceElement(pyClass.getSuperClassExpressions()[0], "object"); } builder.replaceElement(pyClass.getStatementList(), PyNames.PASS); PythonTemplateRunner.runTemplate(pyClass.getContainingFile(), builder); }