Search in sources :

Example 1 with InvalidFacet

use of com.intellij.facet.impl.invalid.InvalidFacet in project intellij-community by JetBrains.

the class FacetManagerImpl method addInvalidFacet.

private void addInvalidFacet(final FacetState state, ModifiableFacetModel model, final Facet underlyingFacet, final String errorMessage, final String typeId) {
    final InvalidFacetManager invalidFacetManager = InvalidFacetManager.getInstance(myModule.getProject());
    final InvalidFacetType type = InvalidFacetType.getInstance();
    final InvalidFacetConfiguration configuration = new InvalidFacetConfiguration(state, errorMessage);
    final InvalidFacet facet = createFacet(type, StringUtil.notNullize(state.getName()), configuration, underlyingFacet);
    model.addFacet(facet);
    if (!invalidFacetManager.isIgnored(facet)) {
        FacetLoadingErrorDescription description = new FacetLoadingErrorDescription(facet);
        ProjectLoadingErrorsNotifier.getInstance(myModule.getProject()).registerError(description);
        if (typeId != null) {
            UnknownFeaturesCollector.getInstance(myModule.getProject()).registerUnknownFeature("com.intellij.facetType", typeId, "Facet");
        }
    }
}
Also used : FacetLoadingErrorDescription(com.intellij.facet.impl.FacetLoadingErrorDescription) InvalidFacetManager(com.intellij.facet.impl.invalid.InvalidFacetManager) InvalidFacetConfiguration(com.intellij.facet.impl.invalid.InvalidFacetConfiguration) InvalidFacetType(com.intellij.facet.impl.invalid.InvalidFacetType) InvalidFacet(com.intellij.facet.impl.invalid.InvalidFacet)

Example 2 with InvalidFacet

use of com.intellij.facet.impl.invalid.InvalidFacet 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;
}
Also used : Element(org.jdom.Element) InvalidFacet(com.intellij.facet.impl.invalid.InvalidFacet) InvalidFacetConfiguration(com.intellij.facet.impl.invalid.InvalidFacetConfiguration) FacetManagerState(org.jetbrains.jps.model.serialization.facet.FacetManagerState) FacetState(org.jetbrains.jps.model.serialization.facet.FacetState) InvalidFacet(com.intellij.facet.impl.invalid.InvalidFacet)

Aggregations

InvalidFacet (com.intellij.facet.impl.invalid.InvalidFacet)2 InvalidFacetConfiguration (com.intellij.facet.impl.invalid.InvalidFacetConfiguration)2 FacetLoadingErrorDescription (com.intellij.facet.impl.FacetLoadingErrorDescription)1 InvalidFacetManager (com.intellij.facet.impl.invalid.InvalidFacetManager)1 InvalidFacetType (com.intellij.facet.impl.invalid.InvalidFacetType)1 Element (org.jdom.Element)1 FacetManagerState (org.jetbrains.jps.model.serialization.facet.FacetManagerState)1 FacetState (org.jetbrains.jps.model.serialization.facet.FacetState)1