Search in sources :

Example 6 with MultiValuesMap

use of com.intellij.openapi.util.MultiValuesMap in project intellij-community by JetBrains.

the class FacetModelBase method getFacetsByType.

@Override
@NotNull
public <F extends Facet> Collection<F> getFacetsByType(@NotNull Facet underlyingFacet, FacetTypeId<F> typeId) {
    if (myChildFacets == null) {
        MultiValuesMap<Pair<Facet, FacetTypeId>, Facet> children = new MultiValuesMap<>();
        for (Facet facet : getAllFacets()) {
            final Facet underlying = facet.getUnderlyingFacet();
            if (underlying != null) {
                children.put(Pair.create(underlying, facet.getTypeId()), facet);
            }
        }
        Map<Pair<Facet, FacetTypeId>, Collection<Facet>> childFacets = new HashMap<>();
        for (Pair<Facet, FacetTypeId> pair : children.keySet()) {
            final Collection<Facet> facets = children.get(pair);
            childFacets.put(pair, Collections.unmodifiableCollection(facets));
        }
        myChildFacets = childFacets;
    }
    //noinspection unchecked
    final Collection<F> facets = (Collection<F>) myChildFacets.get(new Pair(underlyingFacet, typeId));
    return facets != null ? facets : Collections.<F>emptyList();
}
Also used : MultiValuesMap(com.intellij.openapi.util.MultiValuesMap) FacetTypeId(com.intellij.facet.FacetTypeId) Pair(com.intellij.openapi.util.Pair) Facet(com.intellij.facet.Facet) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

MultiValuesMap (com.intellij.openapi.util.MultiValuesMap)6 NotNull (org.jetbrains.annotations.NotNull)3 Facet (com.intellij.facet.Facet)2 FacetTypeId (com.intellij.facet.FacetTypeId)2 ProjectViewNode (com.intellij.ide.projectView.ProjectViewNode)2 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 Module (com.intellij.openapi.module.Module)1 Pair (com.intellij.openapi.util.Pair)1 Artifact (com.intellij.packaging.artifacts.Artifact)1 ArtifactManager (com.intellij.packaging.artifacts.ArtifactManager)1 PackagingElement (com.intellij.packaging.elements.PackagingElement)1 PackagingElementResolvingContext (com.intellij.packaging.elements.PackagingElementResolvingContext)1 FileOrDirectoryCopyPackagingElement (com.intellij.packaging.impl.elements.FileOrDirectoryCopyPackagingElement)1 ModuleOutputPackagingElement (com.intellij.packaging.impl.elements.ModuleOutputPackagingElement)1 PsiFile (com.intellij.psi.PsiFile)1 THashMap (gnu.trove.THashMap)1 ArrayList (java.util.ArrayList)1