mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extracted common code
This commit is contained in:
@@ -25,14 +25,12 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactManager;
|
||||
import com.intellij.packaging.artifacts.ArtifactType;
|
||||
import com.intellij.packaging.elements.ComplexPackagingElement;
|
||||
import com.intellij.packaging.elements.PackagingElement;
|
||||
import com.intellij.packaging.elements.PackagingElementResolvingContext;
|
||||
import com.intellij.packaging.impl.artifacts.ArtifactUtil;
|
||||
import com.intellij.packaging.impl.artifacts.PackagingElementPath;
|
||||
import com.intellij.packaging.impl.artifacts.PackagingElementProcessor;
|
||||
import com.intellij.packaging.impl.elements.ArtifactPackagingElement;
|
||||
import com.intellij.packaging.impl.elements.ModuleOutputPackagingElement;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -122,14 +120,9 @@ public class ArtifactsGenerator {
|
||||
private Target createArtifactTarget(Artifact artifact) {
|
||||
final StringBuilder depends = new StringBuilder(INIT_ARTIFACTS_TARGET);
|
||||
|
||||
ArtifactUtil.processPackagingElements(artifact, null, new PackagingElementProcessor<PackagingElement<?>>() {
|
||||
ArtifactUtil.processRecursivelySkippingIncludedArtifacts(artifact, new Processor<PackagingElement<?>>() {
|
||||
@Override
|
||||
public boolean shouldProcessSubstitution(ComplexPackagingElement<?> element) {
|
||||
return !(element instanceof ArtifactPackagingElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(@NotNull PackagingElement<?> packagingElement, @NotNull PackagingElementPath path) {
|
||||
public boolean process(@NotNull PackagingElement<?> packagingElement) {
|
||||
if (packagingElement instanceof ArtifactPackagingElement) {
|
||||
final Artifact included = ((ArtifactPackagingElement)packagingElement).findArtifact(myResolvingContext);
|
||||
if (included != null) {
|
||||
@@ -146,7 +139,7 @@ public class ArtifactsGenerator {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, myResolvingContext, true);
|
||||
}, myResolvingContext);
|
||||
|
||||
final Pair<String, String> xmlNs = getArtifactXmlNs(artifact.getArtifactType());
|
||||
final Target artifactTarget =
|
||||
|
||||
@@ -123,6 +123,22 @@ public class ArtifactUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void processRecursivelySkippingIncludedArtifacts(Artifact artifact,
|
||||
final Processor<PackagingElement<?>> processor,
|
||||
PackagingElementResolvingContext context) {
|
||||
processPackagingElements(artifact.getRootElement(), null, new PackagingElementProcessor<PackagingElement<?>>() {
|
||||
@Override
|
||||
public boolean process(@NotNull PackagingElement<?> element, @NotNull PackagingElementPath path) {
|
||||
return processor.process(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldProcessSubstitution(ComplexPackagingElement<?> element) {
|
||||
return !(element instanceof ArtifactPackagingElement);
|
||||
}
|
||||
}, context, true, artifact.getArtifactType());
|
||||
}
|
||||
|
||||
private static <E extends PackagingElement<?>> boolean processElementRecursively(@NotNull PackagingElement<?> element, @Nullable PackagingElementType<E> type,
|
||||
@NotNull PackagingElementProcessor<? super E> processor,
|
||||
@NotNull PackagingElementResolvingContext resolvingContext,
|
||||
|
||||
+5
-12
@@ -33,14 +33,11 @@ import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactManager;
|
||||
import com.intellij.packaging.elements.ComplexPackagingElement;
|
||||
import com.intellij.packaging.elements.PackagingElement;
|
||||
import com.intellij.packaging.elements.PackagingElementResolvingContext;
|
||||
import com.intellij.packaging.impl.artifacts.ArtifactUtil;
|
||||
import com.intellij.packaging.impl.artifacts.PackagingElementPath;
|
||||
import com.intellij.packaging.impl.artifacts.PackagingElementProcessor;
|
||||
import com.intellij.packaging.impl.elements.ArtifactPackagingElement;
|
||||
import com.intellij.packaging.impl.elements.FileOrDirectoryCopyPackagingElement;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import gnu.trove.THashMap;
|
||||
@@ -104,14 +101,9 @@ public class ArtifactCompilerUtil {
|
||||
final Set<VirtualFile> roots = new HashSet<VirtualFile>();
|
||||
final PackagingElementResolvingContext context = ArtifactManager.getInstance(project).getResolvingContext();
|
||||
for (Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) {
|
||||
ArtifactUtil.processPackagingElements(artifact, null, new PackagingElementProcessor<PackagingElement<?>>() {
|
||||
Processor<PackagingElement<?>> processor = new Processor<PackagingElement<?>>() {
|
||||
@Override
|
||||
public boolean shouldProcessSubstitution(ComplexPackagingElement<?> element) {
|
||||
return !(element instanceof ArtifactPackagingElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(@NotNull PackagingElement<?> element, @NotNull PackagingElementPath path) {
|
||||
public boolean process(@NotNull PackagingElement<?> element) {
|
||||
if (element instanceof FileOrDirectoryCopyPackagingElement<?>) {
|
||||
final VirtualFile file = ((FileOrDirectoryCopyPackagingElement)element).findFile();
|
||||
if (file != null) {
|
||||
@@ -120,7 +112,8 @@ public class ArtifactCompilerUtil {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, context, true);
|
||||
};
|
||||
ArtifactUtil.processRecursivelySkippingIncludedArtifacts(artifact, processor, context);
|
||||
}
|
||||
|
||||
final Module[] modules = ModuleManager.getInstance(project).getModules();
|
||||
|
||||
Reference in New Issue
Block a user