From 37ff8bba7b64ac4606d2e58aff303824eb5278f3 Mon Sep 17 00:00:00 2001 From: Nikolay Chashnikov Date: Thu, 21 May 2020 18:03:17 +0300 Subject: [PATCH] [web tests] don't add 2 web facets with the same name Such configurations are unexpected and lead to assertions in the new project model. GitOrigin-RevId: 6b15ac38d8e8683ccc1afd36c8d0cfae7545583b --- .../src/com/intellij/facet/impl/FacetUtil.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/facet/impl/FacetUtil.java b/platform/lang-impl/src/com/intellij/facet/impl/FacetUtil.java index df4858fcceef..3c2dbbb8bd28 100644 --- a/platform/lang-impl/src/com/intellij/facet/impl/FacetUtil.java +++ b/platform/lang-impl/src/com/intellij/facet/impl/FacetUtil.java @@ -22,8 +22,12 @@ import java.util.Arrays; public class FacetUtil { public static F addFacet(Module module, FacetType type) { + return addFacet(module, type, type.getPresentableName()); + } + + public static F addFacet(@NotNull Module module, @NotNull FacetType type, @NotNull String facetName) { final ModifiableFacetModel model = FacetManager.getInstance(module).createModifiableModel(); - final F facet = createFacet(module, type); + final F facet = createFacet(module, type, facetName); ApplicationManager.getApplication().runWriteAction(() -> { model.addFacet(facet); model.commit(); @@ -31,8 +35,9 @@ public class FacetUtil { return facet; } - private static F createFacet(final Module module, final FacetType type) { - return FacetManager.getInstance(module).createFacet(type, type.getPresentableName(), type.createDefaultConfiguration(), null); + private static F createFacet(final Module module, + final FacetType type, @NotNull String facetName) { + return FacetManager.getInstance(module).createFacet(type, facetName, type.createDefaultConfiguration(), null); } public static void deleteFacet(final Facet facet) {