void (final Project project, PsiElement[] elements, PsiElement targetContainer, MoveCallback callback) { elements = super.adjustForMove(project, elements, targetContainer); if (elements == null) { return; } MoveFilesOrDirectoriesUtil .doMove(project, elements, new PsiElement[]{targetContainer}, callback, elements1 -> WriteCommandAction.writeCommandAction(project).withName( JavaRefactoringBundle.message("move.files.regrouping.command.name")).compute(() -> { final List<PsiElement> adjustedElements = new ArrayList<>(); for (int i = 0, length = elements1.length; i < length; i++) { PsiElement element = elements1[i]; if (element instanceof PsiClass) { final PsiClass topLevelClass = PsiUtil.getTopLevelClass(element); if (topLevelClass != null) { elements1[i] = topLevelClass; final PsiFile containingFile = obtainContainingFile(topLevelClass, elements1); if (containingFile != null) { adjustedElements.add(containingFile); continue; } } } adjustedElements.add(element); } return PsiUtilCore.toPsiElementArray(adjustedElements); })); }