use of org.jetbrains.jps.model.serialization.facet.FacetManagerState in project intellij-community by JetBrains.
the class FacetManagerImpl method getState.
@Override
public FacetManagerState getState() {
FacetManagerState managerState = new FacetManagerState();
final Facet[] facets = getSortedFacets();
Map<Facet, List<FacetState>> states = new HashMap<>();
states.put(null, managerState.getFacets());
for (Facet facet : facets) {
final Facet underlyingFacet = facet.getUnderlyingFacet();
final List<FacetState> parent = states.get(underlyingFacet);
FacetState facetState;
if (facet instanceof InvalidFacet) {
facetState = ((InvalidFacet) facet).getConfiguration().getFacetState();
} else {
facetState = new FacetState();
facetState.setFacetType(facet.getType().getStringId());
facetState.setName(facet.getName());
final Element config;
try {
FacetConfiguration configuration = facet.getConfiguration();
config = FacetUtil.saveFacetConfiguration(configuration);
if (facet instanceof JDOMExternalizable) {
//todo[nik] remove
((JDOMExternalizable) facet).writeExternal(config);
}
} catch (WriteExternalException e) {
continue;
}
facetState.setConfiguration(config);
}
parent.add(facetState);
states.put(facet, facetState.getSubFacets());
}
return managerState;
}
Aggregations