From 4a900f191d94f008c2877f8751e27bef6a5692aa Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 13 Oct 2015 19:08:08 +0200 Subject: [PATCH] separate inspection profile wrappers based on local and shared profiles to avoid conflicts when same names are used (IDEA-97051) --- .../ex/InspectionProfileTest.java | 21 +++++++++++++ .../profile/DefaultProjectProfileManager.java | 4 ++- .../InspectionProjectProfileManagerImpl.java | 30 +++++++++++++++---- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java index 6221c1ddfb65..4241253dbb2f 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java @@ -81,6 +81,27 @@ public class InspectionProfileTest extends LightIdeaTestCase { return new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), InspectionProfileManager.getInstance(), base); } + public void testSameNameSharedProfile() throws Exception { + InspectionProfileManager profileManager = InspectionProfileManager.getInstance(); + InspectionProfileImpl localProfile = createProfile(); + profileManager.updateProfile(localProfile); + + InspectionProjectProfileManager projectProfileManager = InspectionProjectProfileManager.getInstance(getProject()); + try { + //normally on open project profile wrappers are init for both managers + profileManager.updateProfile(localProfile); + InspectionProfileImpl profile = new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), projectProfileManager, + InspectionProfileImpl.getDefaultProfile()); + projectProfileManager.updateProfile(profile); + projectProfileManager.setProjectProfile(profile.getName()); + + assertTrue(projectProfileManager.getInspectionProfile() == profile); + } + finally { + projectProfileManager.deleteProfile(PROFILE); + } + } + public void testConvertOldProfile() throws Exception { Element element = JDOMUtil.loadDocument("\n" + "