mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Fix for 186336, selecting 'advanced settings' of 'new project wizard' kicks off indexer.
This commit is contained in:
parent
59db7018c7
commit
696a48b294
2 changed files with 53 additions and 18 deletions
|
@ -11,7 +11,6 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.pdom;
|
||||
|
||||
import org.eclipse.cdt.core.index.IIndexManager;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
|
||||
|
@ -22,9 +21,9 @@ import org.eclipse.core.resources.IProject;
|
|||
|
||||
public class CProjectDescriptionListener implements ICProjectDescriptionListener {
|
||||
|
||||
private IIndexManager fIndexManager;
|
||||
private PDOMManager fIndexManager;
|
||||
|
||||
public CProjectDescriptionListener(IIndexManager manager) {
|
||||
public CProjectDescriptionListener(PDOMManager manager) {
|
||||
fIndexManager= manager;
|
||||
}
|
||||
|
||||
|
@ -32,6 +31,22 @@ public class CProjectDescriptionListener implements ICProjectDescriptionListener
|
|||
ICProjectDescription old= event.getOldCProjectDescription();
|
||||
ICProjectDescription act= event.getNewCProjectDescription();
|
||||
if (old != null && act != null) {
|
||||
if (completedProjectCreation(old, act)) {
|
||||
ICProject project= getProject(event);
|
||||
if (project != null) {
|
||||
fIndexManager.addProject(project);
|
||||
}
|
||||
}
|
||||
else if (changedDefaultSettingConfiguration(old, act)) {
|
||||
ICProject project= getProject(event);
|
||||
if (project != null) {
|
||||
fIndexManager.reindex(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean changedDefaultSettingConfiguration(ICProjectDescription old, ICProjectDescription act) {
|
||||
ICConfigurationDescription oldConfig= old.getDefaultSettingConfiguration();
|
||||
ICConfigurationDescription newConfig= act.getDefaultSettingConfiguration();
|
||||
if (oldConfig != null && newConfig != null) {
|
||||
|
@ -39,16 +54,22 @@ public class CProjectDescriptionListener implements ICProjectDescriptionListener
|
|||
String newID= newConfig.getId();
|
||||
if (oldID != null && newID != null) {
|
||||
if (!oldID.equals(newID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private ICProject getProject(CProjectDescriptionEvent event) {
|
||||
IProject project= event.getProject();
|
||||
if (project != null && project.isOpen()) {
|
||||
ICProject cproject= CoreModel.getDefault().getCModel().getCProject(project.getName());
|
||||
if (cproject != null) {
|
||||
fIndexManager.reindex(cproject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return CoreModel.getDefault().create(project);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean completedProjectCreation(ICProjectDescription old, ICProjectDescription act) {
|
||||
return old.isCdtProjectCreating() && !act.isCdtProjectCreating();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ import org.eclipse.cdt.core.model.ILanguageMappingChangeListener;
|
|||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.LanguageManager;
|
||||
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||
|
@ -66,6 +67,7 @@ import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
|||
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMRebuildTask;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMUpdateTask;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.nulli.PDOMNullIndexer;
|
||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -596,6 +598,10 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
|
||||
void addProject(final ICProject cproject) {
|
||||
final IProject project = cproject.getProject();
|
||||
if (!isFullyCreated(project)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Job addProject= new Job(Messages.PDOMManager_StartJob_name) {
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
monitor.beginTask("", 100); //$NON-NLS-1$
|
||||
|
@ -637,6 +643,14 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
addProject.schedule();
|
||||
}
|
||||
|
||||
private boolean isFullyCreated(IProject project) {
|
||||
ICProjectDescription desc= CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
|
||||
if (desc != null && !desc.isCdtProjectCreating()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void registerPreferenceListener(ICProject project) {
|
||||
IProject prj= project.getProject();
|
||||
PCL pcl= (PCL) fPrefListeners.get(prj);
|
||||
|
|
Loading…
Add table
Reference in a new issue