Search in sources :

Example 1 with FacetTypeId

use of com.intellij.facet.FacetTypeId in project intellij-community by JetBrains.

the class FacetModelBase method getFacetsByType.

@Override
@NotNull
public <F extends Facet> Collection<F> getFacetsByType(FacetTypeId<F> typeId) {
    if (myType2Facets == null) {
        MultiValuesMap<FacetTypeId, Facet> typeToFacets = new MultiValuesMap<>();
        for (Facet facet : getAllFacets()) {
            typeToFacets.put(facet.getTypeId(), facet);
        }
        Map<FacetTypeId, Collection<Facet>> typeToFacetsCollection = new HashMap<>();
        for (FacetTypeId id : typeToFacets.keySet()) {
            final Collection<Facet> facets = typeToFacets.get(id);
            typeToFacetsCollection.put(id, Collections.unmodifiableCollection(facets));
        }
        myType2Facets = typeToFacetsCollection;
    }
    final Collection<F> facets = (Collection<F>) myType2Facets.get(typeId);
    return facets != null ? facets : Collections.<F>emptyList();
}
Also used : MultiValuesMap(com.intellij.openapi.util.MultiValuesMap) FacetTypeId(com.intellij.facet.FacetTypeId) Facet(com.intellij.facet.Facet) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with FacetTypeId

use of com.intellij.facet.FacetTypeId in project intellij-community by JetBrains.

the class AddFacetOfTypeAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final FacetType type = myFacetType;
    if (type == null)
        return;
    final FacetTypeId underlyingFacetType = type.getUnderlyingFacetType();
    if (underlyingFacetType == null) {
        addFacetToModule(type);
    } else {
        addSubFacet(type, underlyingFacetType);
    }
}
Also used : FacetType(com.intellij.facet.FacetType) FacetTypeId(com.intellij.facet.FacetTypeId)

Example 3 with FacetTypeId

use of com.intellij.facet.FacetTypeId 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

FacetTypeId (com.intellij.facet.FacetTypeId)3 Facet (com.intellij.facet.Facet)2 MultiValuesMap (com.intellij.openapi.util.MultiValuesMap)2 NotNull (org.jetbrains.annotations.NotNull)2 FacetType (com.intellij.facet.FacetType)1 Pair (com.intellij.openapi.util.Pair)1