IDEA-355836 Create new Java class / new Kotlin class actions should not be available on the top project level

suppress if there are source roots in the project

GitOrigin-RevId: 19932e2a81bd40aaed63ef90571c75cd3612fa49
This commit is contained in:
Dmitry Avdeev
2025-02-22 13:22:34 +00:00
committed by intellij-monorepo-bot
parent 439fbffe94
commit 575630219c
@@ -145,12 +145,13 @@ public abstract class CreateTemplateInPackageAction<T extends PsiElement> extend
public static boolean isInContentRoot(VirtualFile file, ProjectFileIndex index) {
return file.equals(index.getContentRootForFile(file)) &&
moduleHasNoSourceRoots(file, index);
projectHasNoSourceRoots(file, index);
}
private static boolean moduleHasNoSourceRoots(VirtualFile file, ProjectFileIndex index) {
private static boolean projectHasNoSourceRoots(VirtualFile file, ProjectFileIndex index) {
Module module = index.getModuleForFile(file);
return module != null && ModuleRootManager.getInstance(module).getSourceRoots().length == 0;
return module != null && ModuleRootManager.getInstance(module).getSourceRoots().length == 0 &&
ProjectRootManager.getInstance(module.getProject()).getContentSourceRoots().length == 0;
}
protected abstract boolean checkPackageExists(PsiDirectory directory);