void (@NotNull KtClassOrObject initialTargetClass) { //noinspection ConstantConditions originalClassField.setText(originalClass.getFqName().asString()); //noinspection ConstantConditions targetClassChooser = new KotlinTypeReferenceEditorComboWithBrowseButton( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TreeClassChooser chooser = new TreeJavaClassChooserDialog( RefactoringBundle.message("choose.destination.class"), myProject, searchScope, MoveKotlinNestedClassesDialog.this::classMatchesFilter, null, null, true ) { @Nullable @Override protected PsiClass getSelectedFromTreeUserObject(DefaultMutableTreeNode node) { PsiClass psiClass = super.getSelectedFromTreeUserObject(node); if (psiClass != null) return psiClass; Object userObject = node.getUserObject(); if (!(userObject instanceof KtClassOrObjectTreeNode)) return null; return LightClassUtilsKt.toLightClass(((KtClassOrObjectTreeNode) userObject).getValue()); } }; chooser.selectDirectory( (targetClass != null ? targetClass : originalClass).getContainingFile().getContainingDirectory()); chooser.showDialog(); PsiClass aClass = chooser.getSelected(); if (aClass instanceof KtLightClassForSourceDeclaration) { targetClass = ((KtLightClassForSourceDeclaration) aClass).getKotlinOrigin(); targetClassChooser.setText(Objects.requireNonNull(aClass.getQualifiedName())); } else { targetClass = aClass; } } }, initialTargetClass.getFqName().asString(), originalClass, RECENTS_KEY); KtTypeCodeFragment codeFragment = targetClassChooser.getCodeFragment(); if (codeFragment != null) { CompletionUtilsKt.setExtraCompletionFilter( codeFragment, lookupElement -> { Object lookupObject = lookupElement.getObject(); if (!(lookupObject instanceof DescriptorBasedDeclarationLookupObject)) return false; PsiElement psiElement = ((DescriptorBasedDeclarationLookupObject) lookupObject).getPsiElement(); if (lookupObject instanceof PackageLookupObject) return true; return (psiElement instanceof KtClassOrObject) && KotlinCommonRefactoringUtilKt.canRefactorElement(psiElement); } ); } targetClassChooser.getChildComponent().getDocument().addDocumentListener( new DocumentListener() { @Override public void documentChanged(@NotNull DocumentEvent e) { PsiClass aClass = JavaPsiFacade .getInstance(myProject) .findClass(targetClassChooser.getText(), searchScope); targetClass = aClass instanceof KtLightClassForSourceDeclaration ? ((KtLightClassForSourceDeclaration) aClass).getKotlinOrigin() : aClass; validateButtons(); } } ); targetClassChooserPanel.add(targetClassChooser); }