1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

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 <freidin.alex@gmail.com>
Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>
This commit is contained in:
Marc-Andre Laperle 2020-10-10 01:48:29 -04:00 committed by Marc-André Laperle
parent cebba80b36
commit 6ca0bb78bb
4 changed files with 22 additions and 5 deletions

View file

@ -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);
{

View file

@ -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());

View file

@ -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

View file

@ -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();
}