1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

Bug 533363 - Indexer spending a lot of time in CommandLauncherManager

- it seems that fetching the active configuration for a project
  using an ICConfigurationDescription is time-consuming
- the active configuration is sought in ContainerCommandLauncherFactory
  to get the optional build properties and thus we can figure out
  if the active configuration has enabled container build or not
- see if we are given a CConfigurationDescriptionCache and it
  contains a BuildConfigurationData element which allows us to
  get an IConfiguration without creating a new one, serializing
  it etc.. which is adding to the time taken

Change-Id: I8973f1707a602a73fc5ac751f12a1e8dbd549aab
This commit is contained in:
Jeff Johnston 2018-07-11 13:35:26 -04:00
parent 79331d755a
commit a394557c60

View file

@ -28,10 +28,13 @@ import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICIncludePathEntry; import org.eclipse.cdt.core.settings.model.ICIncludePathEntry;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescriptionCache;
import org.eclipse.cdt.internal.docker.launcher.Messages; import org.eclipse.cdt.internal.docker.launcher.Messages;
import org.eclipse.cdt.managedbuilder.buildproperties.IOptionalBuildProperties; import org.eclipse.cdt.managedbuilder.buildproperties.IOptionalBuildProperties;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildConfigurationData;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -43,20 +46,38 @@ public class ContainerCommandLauncherFactory
private IProject project; private IProject project;
@SuppressWarnings("restriction")
@Override @Override
public ICommandLauncher getCommandLauncher(IProject project) { public ICommandLauncher getCommandLauncher(IProject project) {
this.project = project; this.project = project;
// check if container build enablement has been checked // check if container build enablement has been checked
ICConfigurationDescription cfgd = CoreModel.getDefault() ICConfigurationDescription cfgd = CoreModel.getDefault()
.getProjectDescription(project) .getProjectDescription(project, false)
.getActiveConfiguration(); .getActiveConfiguration();
IConfiguration cfg = ManagedBuildManager
.getConfigurationForDescription(cfgd); IConfiguration cfg = null;
// TODO: figure out why this occurs
try {
if (cfgd instanceof CConfigurationDescriptionCache) {
CConfigurationData data = ((CConfigurationDescriptionCache) cfgd)
.getConfigurationData();
if (data instanceof BuildConfigurationData) {
cfg = ((BuildConfigurationData) data).getConfiguration();
}
}
if (cfg == null) {
cfg = ManagedBuildManager.getConfigurationForDescription(cfgd);
}
} catch (Exception e) {
// ignore
}
if (cfg == null) { if (cfg == null) {
return null; return null;
} }
IOptionalBuildProperties props = cfg.getOptionalBuildProperties(); IOptionalBuildProperties props = cfg.getOptionalBuildProperties();
if (props != null) { if (props != null) {
String enablementProperty = props.getProperty( String enablementProperty = props.getProperty(
ContainerCommandLauncher.CONTAINER_BUILD_ENABLED); ContainerCommandLauncher.CONTAINER_BUILD_ENABLED);
@ -253,8 +274,8 @@ public class ContainerCommandLauncherFactory
Messages.ContainerCommandLauncher_invalid_values); Messages.ContainerCommandLauncher_invalid_values);
return includePaths; return includePaths;
} }
ContainerLauncher launcher = new ContainerLauncher();
if (includePaths.size() > 0) { if (includePaths.size() > 0) {
ContainerLauncher launcher = new ContainerLauncher();
// Create a directory to put the header files for // Create a directory to put the header files for
// the image. Use the connection name to form // the image. Use the connection name to form
// the directory name as the connection may be // the directory name as the connection may be
@ -327,6 +348,16 @@ public class ContainerCommandLauncherFactory
return newEntries; return newEntries;
} }
} else {
// TODO: fix this logic in future so it can be done using a call
// rather than using a property of the toolchain
IPath pluginPath = Platform
.getStateLocation(Platform
.getBundle(DockerLaunchUIPlugin.PLUGIN_ID))
.append("HEADERS").append(getCleanName(connectionName)) //$NON-NLS-1$
.append(getCleanName(imageName));
toolchain.setProperty("cdt.needScannerRefresh", //$NON-NLS-1$
pluginPath.toFile().exists() ? "false" : "true"); //$NON-NLS-2$
} }
} }
return includePaths; return includePaths;