mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-04 15:45:25 +02:00
Bug 403455 - make reindexing after build config changes and/or indexer
changes optional Change-Id: Icbf5f6563fc90faa09aa1c5c87a9fc9c8065cbbd Reviewed-on: https://git.eclipse.org/r/11194 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> Reviewed-by: Chris Recoskie <recoskie@ca.ibm.com>
This commit is contained in:
parent
89a36b0bdd
commit
484d24b986
5 changed files with 65 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2012 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* IBM Corporation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom;
|
||||
|
||||
|
@ -17,6 +18,7 @@ import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
|
|||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
||||
|
@ -52,7 +54,9 @@ public class CProjectDescriptionListener implements ICProjectDescriptionListener
|
|||
} else if (old != null && changedDefaultSettingConfiguration(old, act)) {
|
||||
ICProject project= getProject(event);
|
||||
if (project != null) {
|
||||
fIndexManager.reindex(project);
|
||||
if (IndexerPreferences.getReindexOnConfigChange(project.getProject())) {
|
||||
fIndexManager.reindex(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
* Anna Dushistova (MontaVista)
|
||||
* Marc-Andre Laperle
|
||||
* Martin Oberhuber (Wind River) - [397652] fix up-to-date check for PDOM
|
||||
* IBM Corporation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom;
|
||||
|
||||
|
@ -522,7 +523,10 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
enqueue(new NotifyCModelManagerTask(cproject.getProject()));
|
||||
}
|
||||
}
|
||||
enqueue(new PDOMRebuildTask(indexer));
|
||||
|
||||
if (IndexerPreferences.getReindexOnIndexerChange(cproject.getProject())) {
|
||||
enqueue(new PDOMRebuildTask(indexer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -9,6 +9,7 @@
|
|||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
* Anton Gorenkov - Enable the "Index unused headers" preference by default (Bug 377992)
|
||||
* IBM Corporation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||
|
||||
|
@ -61,6 +62,9 @@ public class IndexerPreferences {
|
|||
private static final String KEY_INDEXER_PREFS_SCOPE = "preferenceScope"; //$NON-NLS-1$
|
||||
private static final String KEY_INDEX_IMPORT_LOCATION = "indexImportLocation"; //$NON-NLS-1$
|
||||
|
||||
public static final String KEY_REINDEX_ON_CONFIG_CHANGE = "reindexOnConfigChange"; //$NON-NLS-1$
|
||||
public static final String KEY_REINDEX_ON_INDEXER_CHANGE = "reindexOnIndexerChange"; //$NON-NLS-1$
|
||||
|
||||
private static final String DEFAULT_INDEX_IMPORT_LOCATION = ".settings/cdt-index.zip"; //$NON-NLS-1$
|
||||
private static final int DEFAULT_UPDATE_POLICY= 0;
|
||||
public static final int DEFAULT_FILE_SIZE_LIMIT = 8;
|
||||
|
@ -68,7 +72,6 @@ public class IndexerPreferences {
|
|||
private static final String QUALIFIER = CCorePlugin.PLUGIN_ID;
|
||||
private static final String INDEXER_NODE = "indexer"; //$NON-NLS-1$
|
||||
|
||||
|
||||
/**
|
||||
* Returns the scope that is selected for the project.
|
||||
* @param project
|
||||
|
@ -387,7 +390,6 @@ public class IndexerPreferences {
|
|||
public static void setIndexImportLocation(IProject project, String location) {
|
||||
if (!location.equals(getIndexImportLocation(project))) {
|
||||
getProjectPreferences(project).put(KEY_INDEX_IMPORT_LOCATION, location);
|
||||
CCoreInternals.savePreferences(project, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -434,4 +436,24 @@ public class IndexerPreferences {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void setReindexOnConfigChange(IProject project, boolean shouldReindexOnConfigChange) {
|
||||
if (shouldReindexOnConfigChange != getReindexOnConfigChange(project)) {
|
||||
getProjectPreferences(project).putBoolean(KEY_REINDEX_ON_CONFIG_CHANGE, shouldReindexOnConfigChange);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getReindexOnConfigChange(IProject project) {
|
||||
return getProjectPreferences(project).getBoolean(KEY_REINDEX_ON_CONFIG_CHANGE, true);
|
||||
}
|
||||
|
||||
public static void setReindexOnIndexerChange(IProject project, boolean shouldReindexOnIndexerChange) {
|
||||
if (shouldReindexOnIndexerChange != getReindexOnIndexerChange(project)) {
|
||||
getProjectPreferences(project).putBoolean(KEY_REINDEX_ON_INDEXER_CHANGE, shouldReindexOnIndexerChange);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getReindexOnIndexerChange(IProject project) {
|
||||
return getProjectPreferences(project).getBoolean(KEY_REINDEX_ON_INDEXER_CHANGE, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
# Copyright (c) 2005, 2013 IBM Corporation and others.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
|
@ -219,6 +219,8 @@ EditorUtility.closedproject = Project is closed
|
|||
Editorutility.closedproject.description = The project {0} containing that declaration is closed.
|
||||
|
||||
# ------- Index View Text -----------
|
||||
IndexerBlock.redindexOnIndexerChange=Reindex project on change of indexer
|
||||
IndexerBlock.reindexOnBuildConfigChange=Reindex project on change of active build configuration
|
||||
IndexerBlock.enable=Enable indexer
|
||||
IndexView.rebuildIndex.name = Rebuild Index
|
||||
IndexView.openDefinition.name = Open Definition
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2013 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -89,6 +89,8 @@ public class IndexerBlock extends AbstractCOptionPage {
|
|||
private ControlEnableState fEnableState;
|
||||
private Group fBuildConfigGroup;
|
||||
private int fLastScope;
|
||||
private Button fReindexOnConfigChange;
|
||||
private Button fReindexOnIndexerChange;
|
||||
|
||||
public IndexerBlock(){
|
||||
super(INDEXER_LABEL);
|
||||
|
@ -208,6 +210,7 @@ public class IndexerBlock extends AbstractCOptionPage {
|
|||
if (fIndexerConfigMap.size() > 2) {
|
||||
fIndexersComboBox = ControlFactory.createSelectCombo(group, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
fIndexersComboBox.addSelectionListener(indexerChangeListener);
|
||||
fReindexOnIndexerChange = ControlFactory.createCheckBox(group, CUIPlugin.getResourceString("IndexerBlock.redindexOnIndexerChange")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
// add composite for pages
|
||||
|
@ -230,6 +233,8 @@ public class IndexerBlock extends AbstractCOptionPage {
|
|||
};
|
||||
fUseActiveBuildButton.addSelectionListener(listener);
|
||||
fUseFixedBuildConfig.addSelectionListener(listener);
|
||||
|
||||
fReindexOnConfigChange = ControlFactory.createCheckBox(group, CUIPlugin.getResourceString("IndexerBlock.reindexOnBuildConfigChange")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
initializeScope();
|
||||
|
@ -280,6 +285,7 @@ public class IndexerBlock extends AbstractCOptionPage {
|
|||
fBuildConfigComboBox.setEnabled(fixed);
|
||||
fUseActiveBuildButton.setEnabled(notDerived);
|
||||
fUseFixedBuildConfig.setEnabled(notDerived);
|
||||
fReindexOnConfigChange.setEnabled(fUseActiveBuildButton.getEnabled() && fUseActiveBuildButton.getSelection());
|
||||
fBuildConfigGroup.setEnabled(notDerived || fixed);
|
||||
}
|
||||
}
|
||||
|
@ -291,9 +297,11 @@ public class IndexerBlock extends AbstractCOptionPage {
|
|||
ICProjectDescription prefs= prjDescMgr.getProjectDescription(getProject(), false);
|
||||
selectBuildConfigInCombo(prefs.getActiveConfiguration().getName());
|
||||
fBuildConfigComboBox.setEnabled(false);
|
||||
fReindexOnConfigChange.setEnabled(fUseActiveBuildButton.getEnabled());
|
||||
} else {
|
||||
// independent of the scope
|
||||
fBuildConfigComboBox.setEnabled(true);
|
||||
fReindexOnConfigChange.setEnabled(false);
|
||||
}
|
||||
fUseActiveBuildButton.setSelection(useActive);
|
||||
fUseFixedBuildConfig.setSelection(!useActive);
|
||||
|
@ -352,12 +360,17 @@ public class IndexerBlock extends AbstractCOptionPage {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fReindexOnIndexerChange != null) {
|
||||
fReindexOnIndexerChange.setSelection(IndexerPreferences.getReindexOnIndexerChange(getProject()));
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeBuildConfigs() {
|
||||
if (fBuildConfigComboBox != null) {
|
||||
ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
|
||||
ICProjectDescription prefs= prjDescMgr.getProjectDescription(getProject(), false);
|
||||
final IProject project = getProject();
|
||||
ICProjectDescription prefs= prjDescMgr.getProjectDescription(project, false);
|
||||
setUseActiveBuildConfig(prefs.getConfigurationRelations() == ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE);
|
||||
ICConfigurationDescription[] configs= prefs.getConfigurations();
|
||||
String[] names= new String[configs.length];
|
||||
|
@ -369,6 +382,8 @@ public class IndexerBlock extends AbstractCOptionPage {
|
|||
Arrays.sort(names, collator);
|
||||
fBuildConfigComboBox.setItems(names);
|
||||
selectBuildConfigInCombo(prefs.getDefaultSettingConfiguration().getName());
|
||||
|
||||
fReindexOnConfigChange.setSelection(IndexerPreferences.getReindexOnConfigChange(project));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -535,6 +550,7 @@ public class IndexerBlock extends AbstractCOptionPage {
|
|||
props.putAll(p1);
|
||||
}
|
||||
}
|
||||
|
||||
IndexerPreferences.setProperties(project, scope, props);
|
||||
}
|
||||
|
||||
|
@ -542,6 +558,10 @@ public class IndexerBlock extends AbstractCOptionPage {
|
|||
IndexerPreferences.setScope(project, scope);
|
||||
}
|
||||
|
||||
if (fReindexOnIndexerChange != null) {
|
||||
IndexerPreferences.setReindexOnIndexerChange(project, fReindexOnIndexerChange.getSelection());
|
||||
}
|
||||
|
||||
if (fBuildConfigComboBox != null) {
|
||||
boolean useActive= fUseActiveBuildButton.getSelection();
|
||||
ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
|
||||
|
@ -559,6 +579,9 @@ public class IndexerBlock extends AbstractCOptionPage {
|
|||
prefs.setDefaultSettingConfiguration(config);
|
||||
}
|
||||
}
|
||||
|
||||
IndexerPreferences.setReindexOnConfigChange(project, fReindexOnConfigChange.getSelection());
|
||||
|
||||
prjDescMgr.setProjectDescription(getProject(), prefs);
|
||||
}
|
||||
CCoreInternals.savePreferences(project, scope == IndexerPreferences.SCOPE_PROJECT_SHARED);
|
||||
|
|
Loading…
Add table
Reference in a new issue