List<MavenImporter> (MavenProject p, boolean isWorkspaceImport) { List<MavenImporter> result = null; Set<ModuleType<?>> moduleTypes = null; for (MavenImporter importer : EXTENSION_POINT_NAME.getExtensions()) { if (isWorkspaceImport && importer.isMigratedToConfigurator()) continue; if (importer.isApplicable(p)) { if (result == null) { result = new ArrayList<>(); moduleTypes = new HashSet<>(); } result.add(importer); moduleTypes.add(importer.getModuleType()); } } if (result == null) { return Collections.emptyList(); } if (moduleTypes.size() <= 1) { return result; } // This code is reached when several importers say that they are applicable but they want to have different module types. // Now we select one module type and return only those importers that are ok with it. // If possible - return at least one importer that explicitly supports packaging of the given maven project. ModuleType<?> moduleType = result.get(0).getModuleType(); List<String> supportedPackagingTypes = new ArrayList<>(); for (MavenImporter importer : result) { supportedPackagingTypes.clear(); importer.getSupportedPackagings(supportedPackagingTypes); if (supportedPackagingTypes.contains(p.getPackaging())) { moduleType = importer.getModuleType(); break; } } final ModuleType<?> finalModuleType = moduleType; return ContainerUtil.filter(result, importer -> importer.getModuleType() == finalModuleType); }