Commit c4596d19 authored by Vladimir Krivosheev's avatar Vladimir Krivosheev
Browse files

getDefaultProfile -> getBaseProfile

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.
parent 03354ff7
Showing with 19 additions and 25 deletions
+19 -25
...@@ -82,7 +82,7 @@ public class InspectionProfileTest extends LightIdeaTestCase { ...@@ -82,7 +82,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
} }
private static InspectionProfileImpl createProfile() { 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) { private static InspectionProfileImpl createProfile(@NotNull InspectionProfileImpl base) {
return new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), InspectionProfileManager.getInstance(), base, null); return new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), InspectionProfileManager.getInstance(), base, null);
...@@ -98,7 +98,7 @@ public class InspectionProfileTest extends LightIdeaTestCase { ...@@ -98,7 +98,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
//normally on open project profile wrappers are init for both managers //normally on open project profile wrappers are init for both managers
profileManager.updateProfile(localProfile); profileManager.updateProfile(localProfile);
InspectionProfileImpl profile = new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), projectProfileManager, InspectionProfileImpl profile = new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), projectProfileManager,
InspectionProfileImpl.getDefaultProfile(), null); InspectionProfileImpl.getBaseProfile(), null);
projectProfileManager.updateProfile(profile); projectProfileManager.updateProfile(profile);
projectProfileManager.setRootProfile(profile.getName()); projectProfileManager.setRootProfile(profile.getName());
...@@ -579,7 +579,7 @@ public class InspectionProfileTest extends LightIdeaTestCase { ...@@ -579,7 +579,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
} }
public void testDoNotInstantiateOnSave() throws Exception { 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)); assertEquals(0, countInitializedTools(profile));
InspectionToolWrapper[] toolWrappers = profile.getInspectionTools(null); InspectionToolWrapper[] toolWrappers = profile.getInspectionTools(null);
assertTrue(toolWrappers.length > 0); assertTrue(toolWrappers.length > 0);
......
...@@ -51,7 +51,7 @@ class InspectionSchemeTest { ...@@ -51,7 +51,7 @@ class InspectionSchemeTest {
profileManager.forceInitProfiles(true) profileManager.forceInitProfiles(true)
profileManager.initProfiles() profileManager.initProfiles()
assertThat(profileManager.profiles).hasSize(2) assertThat(profileManager.profiles).hasSize(1)
val scheme = profileManager.profiles.first() as InspectionProfileImpl val scheme = profileManager.profiles.first() as InspectionProfileImpl
assertThat(scheme.name).isEqualTo("Bar") assertThat(scheme.name).isEqualTo("Bar")
...@@ -61,5 +61,11 @@ class InspectionSchemeTest { ...@@ -61,5 +61,11 @@ class InspectionSchemeTest {
assertThat(schemeFile.readText()).isEqualTo(schemeData) assertThat(schemeFile.readText()).isEqualTo(schemeData)
profileManager.profiles profileManager.profiles
schemeManagerFactory.process {
it.reload()
}
assertThat(profileManager.profiles).hasSize(1)
} }
} }
...@@ -101,7 +101,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, ...@@ -101,7 +101,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
public InspectionProfileImpl(@NotNull String profileName, public InspectionProfileImpl(@NotNull String profileName,
@NotNull InspectionToolRegistrar registrar, @NotNull InspectionToolRegistrar registrar,
@NotNull ProfileManager profileManager) { @NotNull ProfileManager profileManager) {
this(profileName, registrar, profileManager, getDefaultProfile(), null); this(profileName, registrar, profileManager, getBaseProfile(), null);
} }
public InspectionProfileImpl(@NotNull @NonNls String profileName) { public InspectionProfileImpl(@NotNull @NonNls String profileName) {
...@@ -125,7 +125,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, ...@@ -125,7 +125,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
@NotNull InspectionToolRegistrar registrar, @NotNull InspectionToolRegistrar registrar,
@NotNull ProfileManager profileManager, @NotNull ProfileManager profileManager,
@Nullable SchemeDataHolder<? super InspectionProfileImpl> dataHolder) { @Nullable SchemeDataHolder<? super InspectionProfileImpl> dataHolder) {
this(profileName, registrar, profileManager, getDefaultProfile(), dataHolder); this(profileName, registrar, profileManager, getBaseProfile(), dataHolder);
} }
@NotNull @NotNull
...@@ -163,7 +163,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, ...@@ -163,7 +163,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
} }
@NotNull @NotNull
public static InspectionProfileImpl getDefaultProfile() { public static InspectionProfileImpl getBaseProfile() {
return InspectionProfileImplHolder.DEFAULT_PROFILE; return InspectionProfileImplHolder.DEFAULT_PROFILE;
} }
......
...@@ -98,7 +98,7 @@ class ProjectInspectionProfileManager(val project: Project, ...@@ -98,7 +98,7 @@ class ProjectInspectionProfileManager(val project: Project,
attributeProvider: Function<String, String?>, attributeProvider: Function<String, String?>,
isBundled: Boolean): InspectionProfileImpl { isBundled: Boolean): InspectionProfileImpl {
val profile = InspectionProfileImpl(name, InspectionToolRegistrar.getInstance(), this@ProjectInspectionProfileManager, val profile = InspectionProfileImpl(name, InspectionToolRegistrar.getInstance(), this@ProjectInspectionProfileManager,
InspectionProfileImpl.getDefaultProfile(), dataHolder) InspectionProfileImpl.getBaseProfile(), dataHolder)
profile.isProjectLevel = true profile.isProjectLevel = true
return profile return profile
} }
...@@ -306,7 +306,7 @@ class ProjectInspectionProfileManager(val project: Project, ...@@ -306,7 +306,7 @@ class ProjectInspectionProfileManager(val project: Project,
currentScheme = schemeManager.allSchemes.firstOrNull() currentScheme = schemeManager.allSchemes.firstOrNull()
if (currentScheme == null) { if (currentScheme == null) {
currentScheme = InspectionProfileImpl(PROJECT_DEFAULT_PROFILE_NAME, InspectionToolRegistrar.getInstance(), this, currentScheme = InspectionProfileImpl(PROJECT_DEFAULT_PROFILE_NAME, InspectionToolRegistrar.getInstance(), this,
InspectionProfileImpl.getDefaultProfile(), null) InspectionProfileImpl.getBaseProfile(), null)
currentScheme.copyFrom(applicationProfileManager.currentProfile as ProfileEx) currentScheme.copyFrom(applicationProfileManager.currentProfile as ProfileEx)
currentScheme.isProjectLevel = true currentScheme.isProjectLevel = true
currentScheme.name = PROJECT_DEFAULT_PROFILE_NAME currentScheme.name = PROJECT_DEFAULT_PROFILE_NAME
......
...@@ -60,8 +60,6 @@ import java.util.Collections; ...@@ -60,8 +60,6 @@ import java.util.Collections;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function; import java.util.function.Function;
import static com.intellij.codeInspection.ex.InspectionProfileImpl.getDefaultProfile;
@State( @State(
name = "InspectionProfileManager", name = "InspectionProfileManager",
storages = { storages = {
...@@ -92,7 +90,7 @@ public class ApplicationInspectionProfileManager extends BaseInspectionProfileMa ...@@ -92,7 +90,7 @@ public class ApplicationInspectionProfileManager extends BaseInspectionProfileMa
mySchemeManager = schemeManagerFactory.create(INSPECTION_DIR, new InspectionProfileProcessor() { mySchemeManager = schemeManagerFactory.create(INSPECTION_DIR, new InspectionProfileProcessor() {
@NotNull @NotNull
@Override @Override
public String getName(@NotNull Function<String, String> attributeProvider, String fileNameWithoutExtension) { public String getName(@NotNull Function<String, String> attributeProvider, @NotNull String fileNameWithoutExtension) {
return fileNameWithoutExtension; return fileNameWithoutExtension;
} }
...@@ -170,13 +168,9 @@ public class ApplicationInspectionProfileManager extends BaseInspectionProfileMa ...@@ -170,13 +168,9 @@ public class ApplicationInspectionProfileManager extends BaseInspectionProfileMa
loadBundledSchemes(); loadBundledSchemes();
mySchemeManager.loadSchemes(); mySchemeManager.loadSchemes();
createDefaultProfile();
}
private void createDefaultProfile() { if (mySchemeManager.isEmpty()) {
final InspectionProfileImpl oldDefault = mySchemeManager.findSchemeByName(InspectionProfileImpl.DEFAULT_PROFILE_NAME); mySchemeManager.addScheme(createSampleProfile(InspectionProfileImpl.DEFAULT_PROFILE_NAME, InspectionProfileImpl.getBaseProfile()));
if (oldDefault == null || !oldDefault.isProfileLocked()) {
getSchemeManager().addScheme(createSampleProfile(InspectionProfileImpl.DEFAULT_PROFILE_NAME, getDefaultProfile()));
} }
} }
...@@ -239,12 +233,6 @@ public class ApplicationInspectionProfileManager extends BaseInspectionProfileMa ...@@ -239,12 +233,6 @@ public class ApplicationInspectionProfileManager extends BaseInspectionProfileMa
return new InspectionProfileConvertor(this); return new InspectionProfileConvertor(this);
} }
@SuppressWarnings("unused")
@Deprecated
public InspectionProfileImpl createProfile() {
return createSampleProfile(InspectionProfileImpl.DEFAULT_PROFILE_NAME, getDefaultProfile());
}
@Override @Override
public void setRootProfile(@Nullable String profileName) { public void setRootProfile(@Nullable String profileName) {
mySchemeManager.setCurrentSchemeName(profileName); mySchemeManager.setCurrentSchemeName(profileName);
......
...@@ -40,7 +40,7 @@ fun configureInspections(tools: Array<InspectionProfileEntry>, ...@@ -40,7 +40,7 @@ fun configureInspections(tools: Array<InspectionProfileEntry>,
Disposer.register(parentDisposable, Disposable { Disposer.register(parentDisposable, Disposable {
profileManager.deleteProfile(profile) profileManager.deleteProfile(profile)
profileManager.setCurrentProfile(null) profileManager.setCurrentProfile(null)
clearAllToolsIn(InspectionProfileImpl.getDefaultProfile()) clearAllToolsIn(InspectionProfileImpl.getBaseProfile())
}) })
profileManager.addProfile(profile) profileManager.addProfile(profile)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment