From c4596d19b597c5025d980c46c579c0eae7ecd2fc Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 17 Oct 2016 12:23:31 +0200 Subject: [PATCH] getDefaultProfile -> getBaseProfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is not default — it is base. Do not add default default profile if there is at least on bundled/custom global profile — as before. --- .../ex/InspectionProfileTest.java | 6 +++--- .../codeInspection/ex/InspectionSchemeTest.kt | 8 +++++++- .../ex/InspectionProfileImpl.java | 6 +++--- .../ProjectInspectionProfileManager.kt | 4 ++-- .../ApplicationInspectionProfileManager.java | 18 +++--------------- .../com/intellij/testFramework/inspections.kt | 2 +- 6 files changed, 19 insertions(+), 25 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 922d706384e2..975f15ccfe43 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java @@ -82,7 +82,7 @@ public class InspectionProfileTest extends LightIdeaTestCase { } private static InspectionProfileImpl createProfile() { - return new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), InspectionProfileManager.getInstance(), InspectionProfileImpl.getDefaultProfile(), null); + return new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), InspectionProfileManager.getInstance(), InspectionProfileImpl.getBaseProfile(), null); } private static InspectionProfileImpl createProfile(@NotNull InspectionProfileImpl base) { return new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), InspectionProfileManager.getInstance(), base, null); @@ -98,7 +98,7 @@ public class InspectionProfileTest extends LightIdeaTestCase { //normally on open project profile wrappers are init for both managers profileManager.updateProfile(localProfile); InspectionProfileImpl profile = new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), projectProfileManager, - InspectionProfileImpl.getDefaultProfile(), null); + InspectionProfileImpl.getBaseProfile(), null); projectProfileManager.updateProfile(profile); projectProfileManager.setRootProfile(profile.getName()); @@ -579,7 +579,7 @@ public class InspectionProfileTest extends LightIdeaTestCase { } public void testDoNotInstantiateOnSave() throws Exception { - InspectionProfileImpl profile = new InspectionProfileImpl("profile", InspectionToolRegistrar.getInstance(), InspectionProfileManager.getInstance(), InspectionProfileImpl.getDefaultProfile(), null); + InspectionProfileImpl profile = new InspectionProfileImpl("profile", InspectionToolRegistrar.getInstance(), InspectionProfileManager.getInstance(), InspectionProfileImpl.getBaseProfile(), null); assertEquals(0, countInitializedTools(profile)); InspectionToolWrapper[] toolWrappers = profile.getInspectionTools(null); assertTrue(toolWrappers.length > 0); diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionSchemeTest.kt b/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionSchemeTest.kt index 974c9661cba7..58880e3e19fc 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionSchemeTest.kt +++ b/java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionSchemeTest.kt @@ -51,7 +51,7 @@ class InspectionSchemeTest { profileManager.forceInitProfiles(true) profileManager.initProfiles() - assertThat(profileManager.profiles).hasSize(2) + assertThat(profileManager.profiles).hasSize(1) val scheme = profileManager.profiles.first() as InspectionProfileImpl assertThat(scheme.name).isEqualTo("Bar") @@ -61,5 +61,11 @@ class InspectionSchemeTest { assertThat(schemeFile.readText()).isEqualTo(schemeData) profileManager.profiles + + schemeManagerFactory.process { + it.reload() + } + + assertThat(profileManager.profiles).hasSize(1) } } diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java index 5f6ac4764dba..0556319665dd 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java @@ -101,7 +101,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, public InspectionProfileImpl(@NotNull String profileName, @NotNull InspectionToolRegistrar registrar, @NotNull ProfileManager profileManager) { - this(profileName, registrar, profileManager, getDefaultProfile(), null); + this(profileName, registrar, profileManager, getBaseProfile(), null); } public InspectionProfileImpl(@NotNull @NonNls String profileName) { @@ -125,7 +125,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, @NotNull InspectionToolRegistrar registrar, @NotNull ProfileManager profileManager, @Nullable SchemeDataHolder dataHolder) { - this(profileName, registrar, profileManager, getDefaultProfile(), dataHolder); + this(profileName, registrar, profileManager, getBaseProfile(), dataHolder); } @NotNull @@ -163,7 +163,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, } @NotNull - public static InspectionProfileImpl getDefaultProfile() { + public static InspectionProfileImpl getBaseProfile() { return InspectionProfileImplHolder.DEFAULT_PROFILE; } diff --git a/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt b/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt index f7f31fc78e52..f6a759bfbe13 100644 --- a/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt +++ b/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt @@ -98,7 +98,7 @@ class ProjectInspectionProfileManager(val project: Project, attributeProvider: Function, isBundled: Boolean): InspectionProfileImpl { val profile = InspectionProfileImpl(name, InspectionToolRegistrar.getInstance(), this@ProjectInspectionProfileManager, - InspectionProfileImpl.getDefaultProfile(), dataHolder) + InspectionProfileImpl.getBaseProfile(), dataHolder) profile.isProjectLevel = true return profile } @@ -306,7 +306,7 @@ class ProjectInspectionProfileManager(val project: Project, currentScheme = schemeManager.allSchemes.firstOrNull() if (currentScheme == null) { currentScheme = InspectionProfileImpl(PROJECT_DEFAULT_PROFILE_NAME, InspectionToolRegistrar.getInstance(), this, - InspectionProfileImpl.getDefaultProfile(), null) + InspectionProfileImpl.getBaseProfile(), null) currentScheme.copyFrom(applicationProfileManager.currentProfile as ProfileEx) currentScheme.isProjectLevel = true currentScheme.name = PROJECT_DEFAULT_PROFILE_NAME diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/ApplicationInspectionProfileManager.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/ApplicationInspectionProfileManager.java index 91b13c8643d4..cdb88bebf4aa 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/ApplicationInspectionProfileManager.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/ApplicationInspectionProfileManager.java @@ -60,8 +60,6 @@ import java.util.Collections; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; -import static com.intellij.codeInspection.ex.InspectionProfileImpl.getDefaultProfile; - @State( name = "InspectionProfileManager", storages = { @@ -92,7 +90,7 @@ public class ApplicationInspectionProfileManager extends BaseInspectionProfileMa mySchemeManager = schemeManagerFactory.create(INSPECTION_DIR, new InspectionProfileProcessor() { @NotNull @Override - public String getName(@NotNull Function attributeProvider, String fileNameWithoutExtension) { + public String getName(@NotNull Function attributeProvider, @NotNull String fileNameWithoutExtension) { return fileNameWithoutExtension; } @@ -170,13 +168,9 @@ public class ApplicationInspectionProfileManager extends BaseInspectionProfileMa loadBundledSchemes(); mySchemeManager.loadSchemes(); - createDefaultProfile(); - } - private void createDefaultProfile() { - final InspectionProfileImpl oldDefault = mySchemeManager.findSchemeByName(InspectionProfileImpl.DEFAULT_PROFILE_NAME); - if (oldDefault == null || !oldDefault.isProfileLocked()) { - getSchemeManager().addScheme(createSampleProfile(InspectionProfileImpl.DEFAULT_PROFILE_NAME, getDefaultProfile())); + if (mySchemeManager.isEmpty()) { + mySchemeManager.addScheme(createSampleProfile(InspectionProfileImpl.DEFAULT_PROFILE_NAME, InspectionProfileImpl.getBaseProfile())); } } @@ -239,12 +233,6 @@ public class ApplicationInspectionProfileManager extends BaseInspectionProfileMa return new InspectionProfileConvertor(this); } - @SuppressWarnings("unused") - @Deprecated - public InspectionProfileImpl createProfile() { - return createSampleProfile(InspectionProfileImpl.DEFAULT_PROFILE_NAME, getDefaultProfile()); - } - @Override public void setRootProfile(@Nullable String profileName) { mySchemeManager.setCurrentSchemeName(profileName); diff --git a/platform/testFramework/src/com/intellij/testFramework/inspections.kt b/platform/testFramework/src/com/intellij/testFramework/inspections.kt index f557aadd5720..d466de5c7871 100644 --- a/platform/testFramework/src/com/intellij/testFramework/inspections.kt +++ b/platform/testFramework/src/com/intellij/testFramework/inspections.kt @@ -40,7 +40,7 @@ fun configureInspections(tools: Array, Disposer.register(parentDisposable, Disposable { profileManager.deleteProfile(profile) profileManager.setCurrentProfile(null) - clearAllToolsIn(InspectionProfileImpl.getDefaultProfile()) + clearAllToolsIn(InspectionProfileImpl.getBaseProfile()) }) profileManager.addProfile(profile)