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;
|
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.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
|
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
|
||||||
|
@ -22,9 +21,9 @@ import org.eclipse.core.resources.IProject;
|
||||||
|
|
||||||
public class CProjectDescriptionListener implements ICProjectDescriptionListener {
|
public class CProjectDescriptionListener implements ICProjectDescriptionListener {
|
||||||
|
|
||||||
private IIndexManager fIndexManager;
|
private PDOMManager fIndexManager;
|
||||||
|
|
||||||
public CProjectDescriptionListener(IIndexManager manager) {
|
public CProjectDescriptionListener(PDOMManager manager) {
|
||||||
fIndexManager= manager;
|
fIndexManager= manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,23 +31,45 @@ public class CProjectDescriptionListener implements ICProjectDescriptionListener
|
||||||
ICProjectDescription old= event.getOldCProjectDescription();
|
ICProjectDescription old= event.getOldCProjectDescription();
|
||||||
ICProjectDescription act= event.getNewCProjectDescription();
|
ICProjectDescription act= event.getNewCProjectDescription();
|
||||||
if (old != null && act != null) {
|
if (old != null && act != null) {
|
||||||
ICConfigurationDescription oldConfig= old.getDefaultSettingConfiguration();
|
if (completedProjectCreation(old, act)) {
|
||||||
ICConfigurationDescription newConfig= act.getDefaultSettingConfiguration();
|
ICProject project= getProject(event);
|
||||||
if (oldConfig != null && newConfig != null) {
|
if (project != null) {
|
||||||
String oldID= oldConfig.getId();
|
fIndexManager.addProject(project);
|
||||||
String newID= newConfig.getId();
|
}
|
||||||
if (oldID != null && newID != null) {
|
}
|
||||||
if (!oldID.equals(newID)) {
|
else if (changedDefaultSettingConfiguration(old, act)) {
|
||||||
IProject project= event.getProject();
|
ICProject project= getProject(event);
|
||||||
if (project != null && project.isOpen()) {
|
if (project != null) {
|
||||||
ICProject cproject= CoreModel.getDefault().getCModel().getCProject(project.getName());
|
fIndexManager.reindex(project);
|
||||||
if (cproject != null) {
|
|
||||||
fIndexManager.reindex(cproject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean changedDefaultSettingConfiguration(ICProjectDescription old, ICProjectDescription act) {
|
||||||
|
ICConfigurationDescription oldConfig= old.getDefaultSettingConfiguration();
|
||||||
|
ICConfigurationDescription newConfig= act.getDefaultSettingConfiguration();
|
||||||
|
if (oldConfig != null && newConfig != null) {
|
||||||
|
String oldID= oldConfig.getId();
|
||||||
|
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()) {
|
||||||
|
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.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.LanguageManager;
|
import org.eclipse.cdt.core.model.LanguageManager;
|
||||||
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
|
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.core.settings.model.ICProjectDescriptionListener;
|
||||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
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.PDOMRebuildTask;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMUpdateTask;
|
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.pdom.indexer.nulli.PDOMNullIndexer;
|
||||||
|
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
@ -596,6 +598,10 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
|
|
||||||
void addProject(final ICProject cproject) {
|
void addProject(final ICProject cproject) {
|
||||||
final IProject project = cproject.getProject();
|
final IProject project = cproject.getProject();
|
||||||
|
if (!isFullyCreated(project)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Job addProject= new Job(Messages.PDOMManager_StartJob_name) {
|
Job addProject= new Job(Messages.PDOMManager_StartJob_name) {
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
monitor.beginTask("", 100); //$NON-NLS-1$
|
monitor.beginTask("", 100); //$NON-NLS-1$
|
||||||
|
@ -637,6 +643,14 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
addProject.schedule();
|
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) {
|
private void registerPreferenceListener(ICProject project) {
|
||||||
IProject prj= project.getProject();
|
IProject prj= project.getProject();
|
||||||
PCL pcl= (PCL) fPrefListeners.get(prj);
|
PCL pcl= (PCL) fPrefListeners.get(prj);
|
||||||
|
|
Loading…
Add table
Reference in a new issue