void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { // can happen during batch-inspection if resolution has already been applied to plugin.xml or java class PsiElement element = myPointer.getElement(); if (element == null || !element.isValid()) return; boolean external = descriptor.getPsiElement().getContainingFile() != element.getContainingFile(); if (external) { PsiClass clazz = PsiTreeUtil.getParentOfType(element, PsiClass.class, false); if (!ReadonlyStatusHandler.ensureFilesWritable(project, element.getContainingFile().getVirtualFile())) { String className = clazz != null ? clazz.getQualifiedName() : element.getContainingFile().getName(); Messages.showErrorDialog(project, DevKitBundle.message("inspections.registration.problems.quickfix.read-only", className), CommonBundle.getErrorTitle()); return; } } try { if (!(element instanceof PsiClass clazz)) return; PsiMethod ctor = JavaPsiFacade.getInstance(clazz.getProject()).getElementFactory().createConstructor(); PsiUtil.setModifierProperty(ctor, PsiModifier.PUBLIC, true); PsiMethod[] constructors = clazz.getConstructors(); if (constructors.length > 0) { ctor = (PsiMethod)clazz.addBefore(ctor, constructors[0]); } else { // shouldn't get here - it's legal if there's no ctor present at all ctor = (PsiMethod)clazz.add(ctor); } if (myOnTheFly) { ctor.navigate(true); } } catch (IncorrectOperationException e) { Logger.getInstance(getClass()).error(e); } }