Search in sources :

Example 1 with ParentElementProcessor

use of com.intellij.packaging.impl.artifacts.ParentElementProcessor in project intellij-community by JetBrains.

the class PutSourceItemIntoParentAndLinkViaManifestAction method findParentAndGrandParent.

@Nullable
private ParentElementsInfo findParentAndGrandParent(Artifact artifact) {
    final Ref<ParentElementsInfo> result = Ref.create(null);
    ArtifactUtil.processParents(artifact, myArtifactEditor.getContext(), new ParentElementProcessor() {

        @Override
        public boolean process(@NotNull CompositePackagingElement<?> element, @NotNull List<Pair<Artifact, CompositePackagingElement<?>>> parents, @NotNull Artifact artifact) {
            if (parents.size() == 1) {
                final Pair<Artifact, CompositePackagingElement<?>> parent = parents.get(0);
                result.set(new ParentElementsInfo(parent.getFirst(), parent.getSecond(), artifact, element));
                return false;
            }
            return true;
        }
    }, 1);
    return result.get();
}
Also used : ParentElementProcessor(com.intellij.packaging.impl.artifacts.ParentElementProcessor) Artifact(com.intellij.packaging.artifacts.Artifact) Pair(com.intellij.openapi.util.Pair) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Pair (com.intellij.openapi.util.Pair)1 Artifact (com.intellij.packaging.artifacts.Artifact)1 ParentElementProcessor (com.intellij.packaging.impl.artifacts.ParentElementProcessor)1 Nullable (org.jetbrains.annotations.Nullable)1