mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
Using PDOMManager.handlePostBuildEvent() helps with perceived
performance
This commit is contained in:
parent
5fffd285f0
commit
9beee54466
1 changed files with 13 additions and 35 deletions
|
@ -10,34 +10,23 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.index.IIndexManager;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.internal.core.language.settings.providers.ILanguageSettingsChangeEvent;
|
||||
import org.eclipse.cdt.internal.core.language.settings.providers.ILanguageSettingsChangeListener;
|
||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
||||
/**
|
||||
* This class handles changes in language settings for the PDOM by reindexing the appropriate resources.
|
||||
*/
|
||||
public class LanguageSettingsChangeListener implements ILanguageSettingsChangeListener {
|
||||
|
||||
private IIndexManager fManager;
|
||||
private PDOMManager fManager;
|
||||
|
||||
public LanguageSettingsChangeListener(IIndexManager manager) {
|
||||
public LanguageSettingsChangeListener(PDOMManager manager) {
|
||||
fManager = manager;
|
||||
}
|
||||
|
||||
|
@ -46,29 +35,18 @@ public class LanguageSettingsChangeListener implements ILanguageSettingsChangeLi
|
|||
IWorkspaceRoot wspRoot = ResourcesPlugin.getWorkspace().getRoot();
|
||||
IProject project = wspRoot.getProject(projectName);
|
||||
|
||||
ICProjectDescription prjDescription = CCorePlugin.getDefault().getProjectDescription(project);
|
||||
ICConfigurationDescription indexedCfgDescription = prjDescription.getDefaultSettingConfiguration();
|
||||
|
||||
CModelManager manager = CModelManager.getDefault();
|
||||
|
||||
IResource[] resources = event.getResources(indexedCfgDescription.getId());
|
||||
|
||||
if (resources.length > 0) {
|
||||
ICProject cProject = manager.getCModel().getCProject(project);
|
||||
List<ICElement> elements = new ArrayList<ICElement>();
|
||||
|
||||
for (IResource rc : resources) {
|
||||
// AG TODO - remove the log
|
||||
CCorePlugin.log(new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID,
|
||||
"LanguageSettingsChangeListener"+"["+System.identityHashCode(this)+"]"+".handleEvent() for " + rc, new Exception()));
|
||||
if (project != null) {
|
||||
ICProjectDescription prjDescription = CCorePlugin.getDefault().getProjectDescription(project);
|
||||
if (prjDescription != null) {
|
||||
ICConfigurationDescription indexedCfgDescription = prjDescription.getDefaultSettingConfiguration();
|
||||
String indexedCfgId = indexedCfgDescription.getId();
|
||||
|
||||
elements.add(manager.create(rc, cProject));
|
||||
}
|
||||
|
||||
try {
|
||||
fManager.update(elements.toArray(new ICElement[elements.size()]), IIndexManager.UPDATE_ALL);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
for (String cfgId : event.getConfigurationDescriptionIds()) {
|
||||
if (cfgId.equals(indexedCfgId)) {
|
||||
fManager.handlePostBuildEvent();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue