use of com.intellij.openapi.externalSystem.model.project.LibraryPathType in project intellij-community by JetBrains.
the class LibraryDataService method syncPaths.
private void syncPaths(@NotNull final LibraryData externalLibrary, @NotNull final Library ideLibrary, @NotNull final IdeModifiableModelsProvider modelsProvider) {
if (externalLibrary.isUnresolved()) {
return;
}
final Map<OrderRootType, Set<String>> toRemove = ContainerUtilRt.newHashMap();
final Map<OrderRootType, Set<String>> toAdd = ContainerUtilRt.newHashMap();
for (LibraryPathType pathType : LibraryPathType.values()) {
OrderRootType ideType = myLibraryPathTypeMapper.map(pathType);
HashSet<String> toAddPerType = ContainerUtilRt.newHashSet(externalLibrary.getPaths(pathType));
toAdd.put(ideType, toAddPerType);
HashSet<String> toRemovePerType = ContainerUtilRt.newHashSet();
toRemove.put(ideType, toRemovePerType);
for (VirtualFile ideFile : ideLibrary.getFiles(ideType)) {
String idePath = ExternalSystemApiUtil.getLocalFileSystemPath(ideFile);
if (!toAddPerType.remove(idePath)) {
toRemovePerType.add(ideFile.getUrl());
}
}
}
if (toRemove.isEmpty() && toAdd.isEmpty()) {
return;
}
final Library.ModifiableModel libraryModel = modelsProvider.getModifiableLibraryModel(ideLibrary);
for (Map.Entry<OrderRootType, Set<String>> entry : toRemove.entrySet()) {
for (String path : entry.getValue()) {
libraryModel.removeRoot(path, entry.getKey());
}
}
for (Map.Entry<OrderRootType, Set<String>> entry : toAdd.entrySet()) {
Map<OrderRootType, Collection<File>> roots = ContainerUtilRt.newHashMap();
roots.put(entry.getKey(), ContainerUtil.map(entry.getValue(), PATH_TO_FILE));
registerPaths(externalLibrary.isUnresolved(), roots, libraryModel, externalLibrary.getInternalName());
}
}
use of com.intellij.openapi.externalSystem.model.project.LibraryPathType in project intellij-community by JetBrains.
the class LibraryDataService method prepareLibraryFiles.
@NotNull
public Map<OrderRootType, Collection<File>> prepareLibraryFiles(@NotNull LibraryData data) {
Map<OrderRootType, Collection<File>> result = ContainerUtilRt.newHashMap();
for (LibraryPathType pathType : LibraryPathType.values()) {
Set<String> paths = data.getPaths(pathType);
if (paths.isEmpty()) {
continue;
}
result.put(myLibraryPathTypeMapper.map(pathType), ContainerUtil.map(paths, PATH_TO_FILE));
}
return result;
}
Aggregations