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();
}
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);
}
}
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();
}
Aggregations