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

on-demand source root creation restricted to general modules only


(cherry picked from commit 9fd1dc32b8888c70af9b384b41cd6e56d752933e)

IJ-CR-162668

GitOrigin-RevId: c0d30403b109597d94293a319f104197dab060cd
This commit is contained in:
Dmitry Avdeev
2025-05-08 17:08:32 +02:00
committed by intellij-monorepo-bot
parent da9f0d478e
commit 737852c635

View File

@@ -9,7 +9,9 @@ import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.module.GeneralModuleType;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
@@ -150,7 +152,9 @@ public abstract class CreateTemplateInPackageAction<T extends PsiElement> extend
private static boolean noSourceRootConfigured(VirtualFile file, ProjectFileIndex index) {
Module module = index.getModuleForFile(file);
return module != null && ModuleRootManager.getInstance(module).getSourceRoots().length == 0;
return module != null &&
ModuleType.get(module) instanceof GeneralModuleType &&
ModuleRootManager.getInstance(module).getSourceRoots().length == 0;
}
protected abstract boolean checkPackageExists(PsiDirectory directory);