use of com.intellij.openapi.roots.ui.configuration.FacetsProvider in project intellij-community by JetBrains.
the class FrameworkDetectionContextImpl method createDetectedFacetDescriptions.
@NotNull
@Override
public <F extends Facet, C extends FacetConfiguration> List<? extends DetectedFrameworkDescription> createDetectedFacetDescriptions(@NotNull FacetBasedFrameworkDetector<F, C> detector, @NotNull Collection<VirtualFile> files) {
MultiMap<Module, VirtualFile> filesByModule = MultiMap.createSet();
for (VirtualFile file : files) {
final Module module = ModuleUtilCore.findModuleForFile(file, myProject);
if (module != null) {
filesByModule.putValue(module, file);
}
}
final List<DetectedFrameworkDescription> result = new ArrayList<>();
final FacetType<F, C> facetType = detector.getFacetType();
final FacetsProvider provider = DefaultFacetsProvider.INSTANCE;
for (Module module : filesByModule.keySet()) {
final Collection<F> facets = provider.getFacetsByType(module, facetType.getId());
if (!facetType.isSuitableModuleType(ModuleType.get(module)) || facetType.isOnlyOneFacetAllowed() && !facets.isEmpty()) {
continue;
}
List<C> existentConfigurations = new ArrayList<>();
for (F facet : facets) {
//noinspection unchecked
existentConfigurations.add((C) facet.getConfiguration());
}
final Collection<VirtualFile> moduleFiles = filesByModule.get(module);
final List<Pair<C, Collection<VirtualFile>>> pairs = detector.createConfigurations(moduleFiles, existentConfigurations);
for (Pair<C, Collection<VirtualFile>> pair : pairs) {
result.add(new FacetBasedDetectedFrameworkDescriptionImpl<>(module, detector, pair.getFirst(), new HashSet<>(pair.getSecond())));
}
}
return result;
}
Aggregations