use of com.intellij.packaging.impl.elements.FileOrDirectoryCopyPackagingElement in project intellij-community by JetBrains.
the class ArtifactBySourceFileFinderImpl method computeFileToArtifactsMap.
private MultiValuesMap<VirtualFile, Artifact> computeFileToArtifactsMap() {
final MultiValuesMap<VirtualFile, Artifact> result = new MultiValuesMap<>();
final ArtifactManager artifactManager = ArtifactManager.getInstance(myProject);
for (final Artifact artifact : artifactManager.getArtifacts()) {
final PackagingElementResolvingContext context = artifactManager.getResolvingContext();
ArtifactUtil.processPackagingElements(artifact, null, new PackagingElementProcessor<PackagingElement<?>>() {
@Override
public boolean process(@NotNull PackagingElement<?> element, @NotNull PackagingElementPath path) {
if (element instanceof FileOrDirectoryCopyPackagingElement<?>) {
final VirtualFile root = ((FileOrDirectoryCopyPackagingElement) element).findFile();
if (root != null) {
result.put(root, artifact);
}
} else if (element instanceof ModuleOutputPackagingElement) {
for (VirtualFile sourceRoot : ((ModuleOutputPackagingElement) element).getSourceRoots(context)) {
result.put(sourceRoot, artifact);
}
}
return true;
}
}, context, true);
}
return result;
}
use of com.intellij.packaging.impl.elements.FileOrDirectoryCopyPackagingElement in project intellij-community by JetBrains.
the class ArtifactVirtualFileListener method filePathChanged.
private void filePathChanged(@NotNull final String oldPath, @NotNull final String newPath) {
final Collection<Artifact> artifacts = myParentPathsToArtifacts.getValue().get(oldPath);
if (artifacts != null) {
final ModifiableArtifactModel model = myArtifactManager.createModifiableModel();
for (Artifact artifact : artifacts) {
final Artifact copy = model.getOrCreateModifiableArtifact(artifact);
ArtifactUtil.processFileOrDirectoryCopyElements(copy, new PackagingElementProcessor<FileOrDirectoryCopyPackagingElement<?>>() {
@Override
public boolean process(@NotNull FileOrDirectoryCopyPackagingElement<?> element, @NotNull PackagingElementPath pathToElement) {
final String path = element.getFilePath();
if (FileUtil.startsWith(path, oldPath)) {
element.setFilePath(newPath + path.substring(oldPath.length()));
}
return true;
}
}, myArtifactManager.getResolvingContext(), false);
}
model.commit();
}
}
Aggregations