mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-23537 - NPE: DirectoryChooserUtil.getOrChooseDirectory
This commit is contained in:
@@ -37,6 +37,9 @@ public class CreateDirectoryOrPackageAction extends AnAction implements DumbAwar
|
||||
IdeView view = e.getData(LangDataKeys.IDE_VIEW);
|
||||
Project project = e.getData(PlatformDataKeys.PROJECT);
|
||||
|
||||
if (view == null) {
|
||||
return;
|
||||
}
|
||||
PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
|
||||
|
||||
if (directory == null) return;
|
||||
@@ -51,7 +54,7 @@ public class CreateDirectoryOrPackageAction extends AnAction implements DumbAwar
|
||||
Messages.getQuestionIcon(), "", validator);
|
||||
|
||||
final PsiElement result = validator.getCreatedElement();
|
||||
if (result != null && view != null) {
|
||||
if (result != null) {
|
||||
view.selectElement(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -34,7 +35,7 @@ public class DirectoryChooserUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiDirectory getOrChooseDirectory(IdeView view) {
|
||||
public static PsiDirectory getOrChooseDirectory(@NotNull IdeView view) {
|
||||
PsiDirectory[] dirs = view.getDirectories();
|
||||
if (dirs.length == 0) return null;
|
||||
if (dirs.length == 1) {
|
||||
|
||||
Reference in New Issue
Block a user