Search in sources :

Example 1 with ModuleSourceSet

use of com.intellij.compiler.ModuleSourceSet in project intellij-community by JetBrains.

the class GeneralProjectSettingsElement method check.

@Override
public void check(ProjectStructureProblemsHolder problemsHolder) {
    final Project project = myContext.getProject();
    if (containsModuleWithInheritedSdk()) {
        ProjectSdksModel model = ProjectStructureConfigurable.getInstance(project).getProjectJdksModel();
        Sdk sdk = model.getProjectSdk();
        if (sdk == null) {
            PlaceInProjectStructureBase place = new PlaceInProjectStructureBase(project, ProjectStructureConfigurable.getInstance(project).createProjectConfigurablePlace(), this);
            problemsHolder.registerProblem(ProjectBundle.message("project.roots.project.jdk.problem.message"), null, ProjectStructureProblemType.error("project-sdk-not-defined"), place, null);
        }
    }
    List<Chunk<ModuleSourceSet>> sourceSetCycles = ModuleCompilerUtil.computeSourceSetCycles(myContext.getModulesConfigurator());
    List<String> cycles = new ArrayList<>();
    for (Chunk<ModuleSourceSet> chunk : sourceSetCycles) {
        final Set<ModuleSourceSet> sourceSets = chunk.getNodes();
        List<String> names = new ArrayList<>();
        for (ModuleSourceSet sourceSet : sourceSets) {
            String name = sourceSet.getDisplayName();
            names.add(names.isEmpty() ? name : StringUtil.decapitalize(name));
        }
        cycles.add(StringUtil.join(names, ", "));
    }
    if (!cycles.isEmpty()) {
        final PlaceInProjectStructureBase place = new PlaceInProjectStructureBase(project, ProjectStructureConfigurable.getInstance(project).createModulesPlace(), this);
        final String message;
        final String description;
        if (cycles.size() > 1) {
            message = "Circular dependencies";
            @NonNls final String br = "<br>&nbsp;&nbsp;&nbsp;&nbsp;";
            StringBuilder cyclesString = new StringBuilder();
            for (int i = 0; i < cycles.size(); i++) {
                cyclesString.append(br).append(i + 1).append(". ").append(cycles.get(i));
            }
            description = ProjectBundle.message("module.circular.dependency.warning.description", cyclesString);
        } else {
            message = ProjectBundle.message("module.circular.dependency.warning.short", StringUtil.decapitalize(cycles.get(0)));
            description = null;
        }
        problemsHolder.registerProblem(new ProjectStructureProblemDescription(message, description, place, ProjectStructureProblemType.warning("module-circular-dependency"), Collections.<ConfigurationErrorQuickFix>emptyList()));
    }
}
Also used : NonNls(org.jetbrains.annotations.NonNls) ProjectSdksModel(com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel) ModuleSourceSet(com.intellij.compiler.ModuleSourceSet) Chunk(com.intellij.util.Chunk) Project(com.intellij.openapi.project.Project) Sdk(com.intellij.openapi.projectRoots.Sdk)

Aggregations

ModuleSourceSet (com.intellij.compiler.ModuleSourceSet)1 Project (com.intellij.openapi.project.Project)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 ProjectSdksModel (com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel)1 Chunk (com.intellij.util.Chunk)1 NonNls (org.jetbrains.annotations.NonNls)1