void (final Project project, Editor editor, final PsiClass anonymousOrLocalClass) { myProject = project; myManager = PsiManager.getInstance(myProject); myAnonOrLocalClass = anonymousOrLocalClass; for (PsiClassType baseRef : myAnonOrLocalClass.getSuperTypes()) { // Ignore j.l.Record and j.l.Enum base classes, so we can move records/enums with broken/missing JDK String refText = baseRef.getCanonicalText(); if (CommonClassNames.JAVA_LANG_RECORD.equals(refText) || CommonClassNames.JAVA_LANG_ENUM.equals(refText)) { continue; } PsiClass baseClass = baseRef.resolve(); if (baseClass == null) { String message = JavaRefactoringBundle.message("error.cannot.resolve", refText); showErrorMessage(editor, message); return; } if (PsiUtil.isLocalClass(baseClass)) { String message = JavaRefactoringBundle.message("error.not.supported.for.local", JavaRefactoringBundle.message("anonymousToInner.refactoring.name")); showErrorMessage(editor, message); return; } } PsiElement targetContainer = findTargetContainer(myAnonOrLocalClass); if (FileTypeUtils.isInServerPageFile(targetContainer) && targetContainer instanceof PsiFile) { String message = JavaRefactoringBundle.message("error.not.supported.for.jsp", JavaRefactoringBundle.message("anonymousToInner.refactoring.name")); showErrorMessage(editor, message); return; } LOG.assertTrue(targetContainer instanceof PsiClass); myTargetClass = (PsiClass) targetContainer; if (!CommonRefactoringUtil.checkReadOnlyStatus(project, myTargetClass)) return; Map<PsiVariable,VariableInfo> variableInfoMap = new LinkedHashMap<>(); if (!myAnonOrLocalClass.hasModifierProperty(PsiModifier.STATIC)) { collectUsedVariables(variableInfoMap, myAnonOrLocalClass); } final VariableInfo[] infos = variableInfoMap.values().toArray(new VariableInfo[0]); myVariableInfos = infos; Arrays.sort(myVariableInfos, Comparator.comparing((VariableInfo vi) -> vi.variable.getType() instanceof PsiEllipsisType) .thenComparing(vi -> ArrayUtil.find(infos, vi))); if (!showRefactoringDialog()) return; CommandProcessor.getInstance().executeCommand( myProject, () -> { final Runnable action = () -> { try { doRefactoring(); } catch (IncorrectOperationException e) { LOG.error(e); } }; ApplicationManager.getApplication().runWriteAction(action); }, JavaRefactoringBundle.message("anonymousToInner.refactoring.name"), null ); }