void (final @NotNull Module module, final @NotNull ModifiableRootModel rootModel, final FrameworkVersion version, final @Nullable Library library) { FacetManager facetManager = FacetManager.getInstance(module); ModifiableFacetModel model = facetManager.createModifiableModel(); Facet underlyingFacet = null; FacetTypeId<?> underlyingFacetType = myFacetType.getUnderlyingFacetType(); if (underlyingFacetType != null) { underlyingFacet = model.getFacetByType(underlyingFacetType); LOG.assertTrue(underlyingFacet != null, underlyingFacetType); } F facet = facetManager.createFacet(myFacetType, myFacetType.getDefaultFacetName(), underlyingFacet); setupConfiguration(facet, rootModel, version); if (library != null) { onLibraryAdded(facet, library); } model.addFacet(facet); model.commit(); onFacetCreated(facet, rootModel, version); }