1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-04 23:55:26 +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:
Chris Recoskie 2013-03-15 09:04:01 -04:00
parent 89a36b0bdd
commit 484d24b986
5 changed files with 65 additions and 10 deletions

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
* IBM Corporation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom; 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.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener; 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.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -52,11 +54,13 @@ public class CProjectDescriptionListener implements ICProjectDescriptionListener
} else if (old != null && changedDefaultSettingConfiguration(old, act)) { } else if (old != null && changedDefaultSettingConfiguration(old, act)) {
ICProject project= getProject(event); ICProject project= getProject(event);
if (project != null) { if (project != null) {
if (IndexerPreferences.getReindexOnConfigChange(project.getProject())) {
fIndexManager.reindex(project); fIndexManager.reindex(project);
} }
} }
} }
} }
}
private boolean changedDefaultSettingConfiguration(ICProjectDescription old, ICProjectDescription act) { private boolean changedDefaultSettingConfiguration(ICProjectDescription old, ICProjectDescription act) {
ICConfigurationDescription oldConfig= old.getDefaultSettingConfiguration(); ICConfigurationDescription oldConfig= old.getDefaultSettingConfiguration();

View file

@ -14,6 +14,7 @@
* Anna Dushistova (MontaVista) * Anna Dushistova (MontaVista)
* Marc-Andre Laperle * Marc-Andre Laperle
* Martin Oberhuber (Wind River) - [397652] fix up-to-date check for PDOM * Martin Oberhuber (Wind River) - [397652] fix up-to-date check for PDOM
* IBM Corporation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom; package org.eclipse.cdt.internal.core.pdom;
@ -522,9 +523,12 @@ public class PDOMManager implements IWritableIndexManager, IListener {
enqueue(new NotifyCModelManagerTask(cproject.getProject())); enqueue(new NotifyCModelManagerTask(cproject.getProject()));
} }
} }
if (IndexerPreferences.getReindexOnIndexerChange(cproject.getProject())) {
enqueue(new PDOMRebuildTask(indexer)); enqueue(new PDOMRebuildTask(indexer));
} }
} }
}
if (oldIndexer != null) { if (oldIndexer != null) {
stopIndexer(oldIndexer); stopIndexer(oldIndexer);

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Anton Gorenkov - Enable the "Index unused headers" preference by default (Bug 377992) * Anton Gorenkov - Enable the "Index unused headers" preference by default (Bug 377992)
* IBM Corporation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.indexer; 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_INDEXER_PREFS_SCOPE = "preferenceScope"; //$NON-NLS-1$
private static final String KEY_INDEX_IMPORT_LOCATION = "indexImportLocation"; //$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 String DEFAULT_INDEX_IMPORT_LOCATION = ".settings/cdt-index.zip"; //$NON-NLS-1$
private static final int DEFAULT_UPDATE_POLICY= 0; private static final int DEFAULT_UPDATE_POLICY= 0;
public static final int DEFAULT_FILE_SIZE_LIMIT = 8; 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 QUALIFIER = CCorePlugin.PLUGIN_ID;
private static final String INDEXER_NODE = "indexer"; //$NON-NLS-1$ private static final String INDEXER_NODE = "indexer"; //$NON-NLS-1$
/** /**
* Returns the scope that is selected for the project. * Returns the scope that is selected for the project.
* @param project * @param project
@ -387,7 +390,6 @@ public class IndexerPreferences {
public static void setIndexImportLocation(IProject project, String location) { public static void setIndexImportLocation(IProject project, String location) {
if (!location.equals(getIndexImportLocation(project))) { if (!location.equals(getIndexImportLocation(project))) {
getProjectPreferences(project).put(KEY_INDEX_IMPORT_LOCATION, location); getProjectPreferences(project).put(KEY_INDEX_IMPORT_LOCATION, location);
CCoreInternals.savePreferences(project, true);
} }
} }
@ -434,4 +436,24 @@ public class IndexerPreferences {
} }
return true; 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);
}
} }

View file

@ -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 # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at # 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. Editorutility.closedproject.description = The project {0} containing that declaration is closed.
# ------- Index View Text ----------- # ------- 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 IndexerBlock.enable=Enable indexer
IndexView.rebuildIndex.name = Rebuild Index IndexView.rebuildIndex.name = Rebuild Index
IndexView.openDefinition.name = Open Definition IndexView.openDefinition.name = Open Definition

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -89,6 +89,8 @@ public class IndexerBlock extends AbstractCOptionPage {
private ControlEnableState fEnableState; private ControlEnableState fEnableState;
private Group fBuildConfigGroup; private Group fBuildConfigGroup;
private int fLastScope; private int fLastScope;
private Button fReindexOnConfigChange;
private Button fReindexOnIndexerChange;
public IndexerBlock(){ public IndexerBlock(){
super(INDEXER_LABEL); super(INDEXER_LABEL);
@ -208,6 +210,7 @@ public class IndexerBlock extends AbstractCOptionPage {
if (fIndexerConfigMap.size() > 2) { if (fIndexerConfigMap.size() > 2) {
fIndexersComboBox = ControlFactory.createSelectCombo(group, "", ""); //$NON-NLS-1$ //$NON-NLS-2$ fIndexersComboBox = ControlFactory.createSelectCombo(group, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
fIndexersComboBox.addSelectionListener(indexerChangeListener); fIndexersComboBox.addSelectionListener(indexerChangeListener);
fReindexOnIndexerChange = ControlFactory.createCheckBox(group, CUIPlugin.getResourceString("IndexerBlock.redindexOnIndexerChange")); //$NON-NLS-1$
} }
// add composite for pages // add composite for pages
@ -230,6 +233,8 @@ public class IndexerBlock extends AbstractCOptionPage {
}; };
fUseActiveBuildButton.addSelectionListener(listener); fUseActiveBuildButton.addSelectionListener(listener);
fUseFixedBuildConfig.addSelectionListener(listener); fUseFixedBuildConfig.addSelectionListener(listener);
fReindexOnConfigChange = ControlFactory.createCheckBox(group, CUIPlugin.getResourceString("IndexerBlock.reindexOnBuildConfigChange")); //$NON-NLS-1$
} }
initializeScope(); initializeScope();
@ -280,6 +285,7 @@ public class IndexerBlock extends AbstractCOptionPage {
fBuildConfigComboBox.setEnabled(fixed); fBuildConfigComboBox.setEnabled(fixed);
fUseActiveBuildButton.setEnabled(notDerived); fUseActiveBuildButton.setEnabled(notDerived);
fUseFixedBuildConfig.setEnabled(notDerived); fUseFixedBuildConfig.setEnabled(notDerived);
fReindexOnConfigChange.setEnabled(fUseActiveBuildButton.getEnabled() && fUseActiveBuildButton.getSelection());
fBuildConfigGroup.setEnabled(notDerived || fixed); fBuildConfigGroup.setEnabled(notDerived || fixed);
} }
} }
@ -291,9 +297,11 @@ public class IndexerBlock extends AbstractCOptionPage {
ICProjectDescription prefs= prjDescMgr.getProjectDescription(getProject(), false); ICProjectDescription prefs= prjDescMgr.getProjectDescription(getProject(), false);
selectBuildConfigInCombo(prefs.getActiveConfiguration().getName()); selectBuildConfigInCombo(prefs.getActiveConfiguration().getName());
fBuildConfigComboBox.setEnabled(false); fBuildConfigComboBox.setEnabled(false);
fReindexOnConfigChange.setEnabled(fUseActiveBuildButton.getEnabled());
} else { } else {
// independent of the scope // independent of the scope
fBuildConfigComboBox.setEnabled(true); fBuildConfigComboBox.setEnabled(true);
fReindexOnConfigChange.setEnabled(false);
} }
fUseActiveBuildButton.setSelection(useActive); fUseActiveBuildButton.setSelection(useActive);
fUseFixedBuildConfig.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() { private void initializeBuildConfigs() {
if (fBuildConfigComboBox != null) { if (fBuildConfigComboBox != null) {
ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager(); 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); setUseActiveBuildConfig(prefs.getConfigurationRelations() == ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE);
ICConfigurationDescription[] configs= prefs.getConfigurations(); ICConfigurationDescription[] configs= prefs.getConfigurations();
String[] names= new String[configs.length]; String[] names= new String[configs.length];
@ -369,6 +382,8 @@ public class IndexerBlock extends AbstractCOptionPage {
Arrays.sort(names, collator); Arrays.sort(names, collator);
fBuildConfigComboBox.setItems(names); fBuildConfigComboBox.setItems(names);
selectBuildConfigInCombo(prefs.getDefaultSettingConfiguration().getName()); selectBuildConfigInCombo(prefs.getDefaultSettingConfiguration().getName());
fReindexOnConfigChange.setSelection(IndexerPreferences.getReindexOnConfigChange(project));
} }
} }
@ -535,6 +550,7 @@ public class IndexerBlock extends AbstractCOptionPage {
props.putAll(p1); props.putAll(p1);
} }
} }
IndexerPreferences.setProperties(project, scope, props); IndexerPreferences.setProperties(project, scope, props);
} }
@ -542,6 +558,10 @@ public class IndexerBlock extends AbstractCOptionPage {
IndexerPreferences.setScope(project, scope); IndexerPreferences.setScope(project, scope);
} }
if (fReindexOnIndexerChange != null) {
IndexerPreferences.setReindexOnIndexerChange(project, fReindexOnIndexerChange.getSelection());
}
if (fBuildConfigComboBox != null) { if (fBuildConfigComboBox != null) {
boolean useActive= fUseActiveBuildButton.getSelection(); boolean useActive= fUseActiveBuildButton.getSelection();
ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager(); ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
@ -559,6 +579,9 @@ public class IndexerBlock extends AbstractCOptionPage {
prefs.setDefaultSettingConfiguration(config); prefs.setDefaultSettingConfiguration(config);
} }
} }
IndexerPreferences.setReindexOnConfigChange(project, fReindexOnConfigChange.getSelection());
prjDescMgr.setProjectDescription(getProject(), prefs); prjDescMgr.setProjectDescription(getProject(), prefs);
} }
CCoreInternals.savePreferences(project, scope == IndexerPreferences.SCOPE_PROJECT_SHARED); CCoreInternals.savePreferences(project, scope == IndexerPreferences.SCOPE_PROJECT_SHARED);