From 6ca0bb78bbd0724426c5ab320c1e144e6234dff9 Mon Sep 17 00:00:00 2001 From: Marc-Andre Laperle Date: Sat, 10 Oct 2020 01:48:29 -0400 Subject: [PATCH] Bug 329995 - Update all C/C++ views when the active configuration changes Change the default workspace indexer setting Use the active configuration by default, which is less confusing because the UI is properly reflected on active config change. Using a fixed config can be seen as a more advanced setting for performance concerns. A new preference is added, only used at default scope: org.eclipse.cdt.core/cprojectdescription.configRelations This can be used by products to customize the default according to their needs (plugin_customization.ini). This was done because this is a fairly impactful change for users. Change-Id: I35888ffe5bc1814943f432f88a12094394924c88 Signed-off-by: Alex Freidin Signed-off-by: Marc-Andre Laperle --- .../CProjectDescriptionSerializationTests.java | 1 + .../model/CProjectDescriptionDeltaTests.java | 2 ++ .../model/CProjectDescriptionPreferences.java | 17 ++++++++++++++--- .../ui/preferences/IndexerStrategyBlock.java | 7 +++++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/CProjectDescriptionSerializationTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/CProjectDescriptionSerializationTests.java index f7d2fb39c40..dbe9223c266 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/CProjectDescriptionSerializationTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/CProjectDescriptionSerializationTests.java @@ -172,6 +172,7 @@ public class CProjectDescriptionSerializationTests extends TestCase { // Create model project and accompanied descriptions IProject project = BuildSystemTestHelper.createProject(projectName); ICProjectDescription des = coreModel.createProjectDescription(project, false); + des.setConfigurationRelations(ICProjectDescription.CONFIGS_INDEPENDENT); Assert.assertNotNull("createDescription returned null!", des); { diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java index 3b864e88416..c6ff685dfa3 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java @@ -971,6 +971,8 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase { assertNotNull(prjDescription); assertEquals(2, prjDescription.getConfigurations().length); + prjDescription.setConfigurationRelations(ICProjectDescription.CONFIGS_INDEPENDENT); + ICConfigurationDescription cfgDescription0 = prjDescription.getConfigurations()[0]; assertNotNull(cfgDescription0); assertSame(cfgDescription0, prjDescription.getDefaultSettingConfiguration()); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java index c7d4ff4cd5e..ee8e4cd124d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java @@ -13,14 +13,19 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.settings.model; +import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionPreferences; import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.core.settings.model.util.CDataUtil; +import org.eclipse.core.runtime.preferences.DefaultScope; public class CProjectDescriptionPreferences implements ICProjectDescriptionPreferences { + private static final String ATTR_CONFIG_RELATIONS = "configRelations"; //$NON-NLS-1$ - private static final int DEFAULT_RELATIONS = CONFIGS_INDEPENDENT; + // This preference is only used at Default Scope to allow product preference customization (plugin_customization.ini) + private static final String PREF_CPROJECTDESCRIPTION_CONFIG_RELATIONS_KEY = "cprojectdescription.configRelations"; //$NON-NLS-1$ + private boolean fIsReadOnly; private boolean fIsModified; @@ -43,7 +48,8 @@ public class CProjectDescriptionPreferences implements ICProjectDescriptionPrefe fIsReadOnly = isReadOnly; if (el != null) { if (el.getAttribute(ATTR_CONFIG_RELATIONS) != null) - fConfigRelations = Integer.valueOf(CDataUtil.getInteger(el, ATTR_CONFIG_RELATIONS, DEFAULT_RELATIONS)); + fConfigRelations = Integer + .valueOf(CDataUtil.getInteger(el, ATTR_CONFIG_RELATIONS, getDefaultRelations())); } this.fSuperPreference = superPreference; @@ -61,6 +67,11 @@ public class CProjectDescriptionPreferences implements ICProjectDescriptionPrefe CDataUtil.setInteger(el, ATTR_CONFIG_RELATIONS, fConfigRelations.intValue()); } + public static int getDefaultRelations() { + return DefaultScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID) + .getInt(PREF_CPROJECTDESCRIPTION_CONFIG_RELATIONS_KEY, CONFIGS_LINK_SETTINGS_AND_ACTIVE); + } + @Override public int getConfigurationRelations() { if (fConfigRelations != null) @@ -68,7 +79,7 @@ public class CProjectDescriptionPreferences implements ICProjectDescriptionPrefe CProjectDescriptionPreferences superPrefs = getSuperPreferences(); if (superPrefs != null) return superPrefs.getConfigurationRelations(); - return DEFAULT_RELATIONS; + return getDefaultRelations(); } @Override diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock.java index a076dafdb8f..3f7b8894bba 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionPreferences; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionWorkspacePreferences; import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences; +import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionPreferences; import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage; import org.eclipse.cdt.ui.dialogs.ICOptionContainer; import org.eclipse.cdt.utils.ui.controls.ControlFactory; @@ -143,8 +144,10 @@ public class IndexerStrategyBlock extends AbstractCOptionPage { public void performDefaults() { initUpdatePolicy(IndexerPreferences.getDefaultUpdatePolicy()); if (fUseActiveBuildButton != null) { - fUseActiveBuildButton.setSelection(false); - fUseFixedBuildConfig.setSelection(true); + boolean defaultUseActive = CProjectDescriptionPreferences + .getDefaultRelations() == ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE; + fUseActiveBuildButton.setSelection(defaultUseActive); + fUseFixedBuildConfig.setSelection(!defaultUseActive); } updateEnablement(); }