1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

NEW - bug 205257: CDTProject creation scalability issue

https://bugs.eclipse.org/bugs/show_bug.cgi?id=205257
This commit is contained in:
Chris Recoskie 2009-02-20 21:08:12 +00:00
parent 7a8b371d46
commit abe9cb4822
4 changed files with 88 additions and 88 deletions

View file

@ -12,7 +12,6 @@ package org.eclipse.cdt.managedbuilder.core;
import java.util.List; import java.util.List;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.cdt.core.settings.model.extension.CLanguageData; import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
@ -498,45 +497,12 @@ public interface ITool extends IBuildObject, IHoldsOptions {
*/ */
public void setCommandLinePattern(String pattern); public void setCommandLinePattern(String pattern);
/**
* Returns the plugin.xml element of the commandLineGenerator extension or <code>null</code> if none.
*
* @return IConfigurationElement
*
* @deprecated - use getCommandLineGenerator
*/
public IConfigurationElement getCommandLineGeneratorElement();
/**
* Sets the CommandLineGenerator plugin.xml element
*
* @param element
* @deprecated
*/
public void setCommandLineGeneratorElement(IConfigurationElement element);
/** /**
* Returns the command line generator specified for this tool * Returns the command line generator specified for this tool
* @return IManagedCommandLineGenerator * @return IManagedCommandLineGenerator
*/ */
public IManagedCommandLineGenerator getCommandLineGenerator(); public IManagedCommandLineGenerator getCommandLineGenerator();
/**
* Returns the plugin.xml element of the dependencyGenerator extension or <code>null</code> if none.
*
* @return IConfigurationElement
* @deprecated - use getDependencyGeneratorForExtension or IInputType#getDependencyGenerator method
*/
public IConfigurationElement getDependencyGeneratorElement();
/**
* Sets the DependencyGenerator plugin.xml element
*
* @param element
* @deprecated
*/
public void setDependencyGeneratorElement(IConfigurationElement element);
/** /**
* Returns a class instance that implements an interface to generate * Returns a class instance that implements an interface to generate
* source-level dependencies for the tool specified in the argument. * source-level dependencies for the tool specified in the argument.
@ -747,22 +713,12 @@ public interface ITool extends IBuildObject, IHoldsOptions {
IResourceInfo getParentResourceInfo(); IResourceInfo getParentResourceInfo();
/* IInputType setSourceContentTypeIds(IInputType type, String[] ids);
IInputType setHeaderContentTypeIds(IInputType type, String[] ids);
IInputType setSourceExtensionsAttribute(IInputType type, String[] extensions);
IInputType setHeaderExtensionsAttribute(IInputType type, String[] extensions);
*/
IInputType getEditableInputType(IInputType base); IInputType getEditableInputType(IInputType base);
IOutputType getEditableOutputType(IOutputType base); IOutputType getEditableOutputType(IOutputType base);
boolean isEnabled(); boolean isEnabled();
// boolean isReal();
boolean supportsBuild(boolean managed); boolean supportsBuild(boolean managed);
boolean matches(ITool tool); boolean matches(ITool tool);

View file

@ -223,6 +223,8 @@ public class ManagedBuildManager extends AbstractCExtension {
private static Map extensionOutputTypeMap; private static Map extensionOutputTypeMap;
// Targets defined in the manifest files (CDT V2.0 object model) // Targets defined in the manifest files (CDT V2.0 object model)
private static Map extensionTargetMap; private static Map extensionTargetMap;
// "Selected configuraton" elements defined in the manifest files. // "Selected configuraton" elements defined in the manifest files.
// These are configuration elements that map to objects in the internal // These are configuration elements that map to objects in the internal
// representation of the manifest files. For example, ListOptionValues // representation of the manifest files. For example, ListOptionValues
@ -233,6 +235,7 @@ public class ManagedBuildManager extends AbstractCExtension {
// A configuration element, with its attributes and children, directly // A configuration element, with its attributes and children, directly
// reflects the content and structure of the extension section within the // reflects the content and structure of the extension section within the
// declaring plug-in's manifest (plugin.xml) file. // declaring plug-in's manifest (plugin.xml) file.
// This map has a lifecycle corresponding to the build definitions extension loading.
private static Map configElementMap; private static Map configElementMap;
// private static List sortedToolChains; // private static List sortedToolChains;
@ -2250,6 +2253,12 @@ public class ManagedBuildManager extends AbstractCExtension {
return; return;
projectTypesLoading = true; projectTypesLoading = true;
// scalability issue: configElementMap does not need to live past when loading is done, so we will
// deallocate it upon exit with a try...finally
try {
//The list of the IManagedBuildDefinitionsStartup callbacks //The list of the IManagedBuildDefinitionsStartup callbacks
List buildDefStartupList = null; List buildDefStartupList = null;
// Get the extensions that use the current CDT managed build model // Get the extensions that use the current CDT managed build model
@ -2555,6 +2564,12 @@ public class ManagedBuildManager extends AbstractCExtension {
projectTypesLoaded = true; projectTypesLoaded = true;
ToolChainModificationManager.getInstance().start(); ToolChainModificationManager.getInstance().start();
} // try
finally {
configElementMap = null;
}
} }
private static void performAdjustments(){ private static void performAdjustments(){
@ -3207,6 +3222,9 @@ public class ManagedBuildManager extends AbstractCExtension {
} }
private static Map getConfigElementMap() { private static Map getConfigElementMap() {
if(!projectTypesLoading)
throw new IllegalStateException();
if (configElementMap == null) { if (configElementMap == null) {
configElementMap = new HashMap(); configElementMap = new HashMap();
} }
@ -3214,8 +3232,9 @@ public class ManagedBuildManager extends AbstractCExtension {
} }
/** /**
* This method public for implementation reasons. Not intended for use * @noreference This method public for implementation reasons. Not intended for use
* by clients. * by clients.
*
*/ */
public static void putConfigElement(IBuildObject buildObj, IManagedConfigElement configElement) { public static void putConfigElement(IBuildObject buildObj, IManagedConfigElement configElement) {
getConfigElementMap().put(buildObj, configElement); getConfigElementMap().put(buildObj, configElement);
@ -3229,7 +3248,7 @@ public class ManagedBuildManager extends AbstractCExtension {
} }
/** /**
* This method public for implementation reasons. Not intended for use * @noreference This method public for implementation reasons. Not intended for use
* by clients. * by clients.
*/ */
public static IManagedConfigElement getConfigElement(IBuildObject buildObj) { public static IManagedConfigElement getConfigElement(IBuildObject buildObj) {

View file

@ -12,6 +12,8 @@ package org.eclipse.cdt.managedbuilder.internal.core;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -64,7 +66,6 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
private Vector<String> categoryIds; private Vector<String> categoryIds;
private Map<String, IOptionCategory> categoryMap; private Map<String, IOptionCategory> categoryMap;
private List<IOptionCategory> childOptionCategories; private List<IOptionCategory> childOptionCategories;
private Vector<Option> optionList;
private Map<String, Option> optionMap; private Map<String, Option> optionMap;
// Miscellaneous // Miscellaneous
private boolean isDirty = false; private boolean isDirty = false;
@ -97,8 +98,8 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
// found on an non-extension tools // found on an non-extension tools
boolean copyIds = id.equals(source.id); boolean copyIds = id.equals(source.id);
if (source.optionList != null) { if (source.optionMap != null) {
Iterator<Option> iter = source.getOptionList().listIterator(); Iterator<Option> iter = source.getOptionCollection().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Option option = iter.next(); Option option = iter.next();
int nnn = ManagedBuildManager.getRandomNumber(); int nnn = ManagedBuildManager.getRandomNumber();
@ -123,7 +124,7 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
} }
void copyNonoverriddenSettings(HoldsOptions ho){ void copyNonoverriddenSettings(HoldsOptions ho){
if (ho.optionList == null || ho.optionList.size() == 0) if (ho.optionMap == null || ho.optionMap.size() == 0)
return; return;
IOption options[] = getOptions(); IOption options[] = getOptions();
@ -209,8 +210,8 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
} }
} }
List<Option> optionElements = getOptionList(); Collection<Option> optionElements = getOptionCollection();
Iterator<Option> iter2 = optionElements.listIterator(); Iterator<Option> iter2 = optionElements.iterator();
while (iter2.hasNext()) { while (iter2.hasNext()) {
Option option = iter2.next(); Option option = iter2.next();
ICStorageElement optionElement = element.createChild(OPTION); ICStorageElement optionElement = element.createChild(OPTION);
@ -239,7 +240,7 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
* @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#createOptions(IHoldsOptions) * @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#createOptions(IHoldsOptions)
*/ */
public void createOptions(IHoldsOptions superClass) { public void createOptions(IHoldsOptions superClass) {
Iterator<Option> iter = ((HoldsOptions)superClass).getOptionList().listIterator(); Iterator<Option> iter = ((HoldsOptions)superClass).getOptionCollection().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Option optionChild = (Option) iter.next(); Option optionChild = (Option) iter.next();
int nnn = ManagedBuildManager.getRandomNumber(); int nnn = ManagedBuildManager.getRandomNumber();
@ -256,7 +257,6 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
return; return;
// throw new IllegalArgumentException(); // throw new IllegalArgumentException();
getOptionList().remove(option);
getOptionMap().remove(option.getId()); getOptionMap().remove(option.getId());
setDirty(true); setDirty(true);
setRebuildState(true); setRebuildState(true);
@ -276,11 +276,12 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
options = superClass.getOptions(); options = superClass.getOptions();
} }
// Our options take precedence. // Our options take precedence.
Vector<Option> ourOpts = getOptionList(); Collection<Option> ourOpts = getOptionCollection();
Iterator<Option> iter = ourOpts.iterator();
if (options != null) { if (options != null) {
for (int i = 0; i < ourOpts.size(); i++) { while(iter.hasNext()) {
int j = options.length; int j = options.length;
IOption ourOpt = (IOption)ourOpts.get(i); IOption ourOpt = iter.next();
if (ourOpt.getSuperClass() != null) { if (ourOpt.getSuperClass() != null) {
String matchId = ourOpt.getSuperClass().getId(); String matchId = ourOpt.getSuperClass().getId();
search: search:
@ -434,7 +435,6 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
* @param option * @param option
*/ */
public void addOption(Option option) { public void addOption(Option option) {
getOptionList().add(option);
getOptionMap().put(option.getId(), option); getOptionMap().put(option.getId(), option);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -450,11 +450,11 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
/* (non-Javadoc) /* (non-Javadoc)
* Memory-safe way to access the list of options * Memory-safe way to access the list of options
*/ */
private Vector<Option> getOptionList() { private Collection<Option> getOptionCollection() {
if (optionList == null) { // no need to store all the options twice, get them out of the map
optionList = new Vector<Option>(); if(optionMap != null)
} return optionMap.values();
return optionList; else return Collections.emptyList();
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -502,7 +502,7 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
if (isDirty) if (isDirty)
return true; return true;
for (Option option : getOptionList()) for (Option option : getOptionCollection())
if (option.isDirty()) if (option.isDirty())
return true; return true;
@ -517,7 +517,7 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
this.isDirty = isDirty; this.isDirty = isDirty;
// Propagate "false" to the children // Propagate "false" to the children
if (!isDirty) { if (!isDirty) {
for (Option option : getOptionList()) for (Option option : getOptionCollection())
if(!option.isExtensionElement()) if(!option.isExtensionElement())
option.setDirty(false); option.setDirty(false);
} }
@ -531,7 +531,7 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
if (!resolved) { if (!resolved) {
resolved = true; resolved = true;
// Call resolveReferences on our children // Call resolveReferences on our children
for (Option current : getOptionList()) { for (Option current : getOptionCollection()) {
current.resolveReferences(); current.resolveReferences();
} }
// Somewhat wasteful, but use the vector to retrieve the categories in proper order // Somewhat wasteful, but use the vector to retrieve the categories in proper order
@ -638,7 +638,7 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
return true; return true;
// Otherwise see if any options need saving // Otherwise see if any options need saving
for (Option option : getOptionList()) for (Option option : getOptionCollection())
if (option.needsRebuild()) if (option.needsRebuild())
return true; return true;
@ -653,7 +653,7 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
// Propagate "false" to the children // Propagate "false" to the children
if (!rebuildState) if (!rebuildState)
for (Option option : getOptionList()) for (Option option : getOptionCollection())
if(!option.isExtensionElement()) if(!option.isExtensionElement())
option.setRebuildState(false); option.setRebuildState(false);
} }
@ -754,8 +754,8 @@ public abstract class HoldsOptions extends BuildObject implements IHoldsOptions,
if(superClass == null) if(superClass == null)
return true; return true;
if(optionList != null && optionList.size() != 0){ if(optionMap != null && optionMap.size() != 0){
for(Option option : optionList) for(Option option : getOptionCollection())
if(option.hasCustomSettings()) if(option.hasCustomSettings())
return true; return true;
} }

View file

@ -434,10 +434,18 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
supportsManagedBuild = tool.supportsManagedBuild; supportsManagedBuild = tool.supportsManagedBuild;
commandLineGeneratorElement = tool.commandLineGeneratorElement;
commandLineGenerator = tool.commandLineGenerator; commandLineGenerator = tool.commandLineGenerator;
dependencyGeneratorElement = tool.dependencyGeneratorElement; if(commandLineGenerator == null) {
// only need XML if the generator hasn't been created yet
commandLineGeneratorElement = tool.commandLineGeneratorElement;
}
dependencyGenerator = tool.dependencyGenerator; dependencyGenerator = tool.dependencyGenerator;
if(dependencyGenerator == null) {
// only need XML if the generator hasn't been created yet
dependencyGeneratorElement = tool.dependencyGeneratorElement;
}
pathconverterElement = tool.pathconverterElement ; pathconverterElement = tool.pathconverterElement ;
optionPathConverter = tool.optionPathConverter ; optionPathConverter = tool.optionPathConverter ;
@ -562,19 +570,31 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
if(supportsManagedBuild == null) if(supportsManagedBuild == null)
supportsManagedBuild = tool.supportsManagedBuild; supportsManagedBuild = tool.supportsManagedBuild;
if(commandLineGenerator == null) {
if(commandLineGeneratorElement == null)
commandLineGeneratorElement = tool.commandLineGeneratorElement;
if(commandLineGenerator == null)
commandLineGenerator = tool.commandLineGenerator; commandLineGenerator = tool.commandLineGenerator;
// only copy the generator element if we don't already have a generator
if(commandLineGenerator == null && commandLineGeneratorElement == null)
commandLineGeneratorElement = tool.commandLineGeneratorElement;
}
if(dependencyGenerator == null) {
dependencyGenerator = tool.dependencyGenerator;
// only copy the generator element if we don't already have a generator
if(dependencyGenerator == null) {
if(dependencyGeneratorElement == null) if(dependencyGeneratorElement == null)
dependencyGeneratorElement = tool.dependencyGeneratorElement; dependencyGeneratorElement = tool.dependencyGeneratorElement;
if(dependencyGenerator == null) }
dependencyGenerator = tool.dependencyGenerator; }
if(optionPathConverter == null) {
optionPathConverter = tool.optionPathConverter ;
if(optionPathConverter == null) {
if(pathconverterElement == null) if(pathconverterElement == null)
pathconverterElement = tool.pathconverterElement ; pathconverterElement = tool.pathconverterElement ;
if(optionPathConverter == null) }
optionPathConverter = tool.optionPathConverter ; }
if(envVarBuildPathList == null && tool.envVarBuildPathList != null) if(envVarBuildPathList == null && tool.envVarBuildPathList != null)
envVarBuildPathList = new ArrayList<IEnvVarBuildPath>(tool.envVarBuildPathList); envVarBuildPathList = new ArrayList<IEnvVarBuildPath>(tool.envVarBuildPathList);
@ -2089,6 +2109,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
try { try {
if (element.getAttribute(COMMAND_LINE_GENERATOR) != null) { if (element.getAttribute(COMMAND_LINE_GENERATOR) != null) {
commandLineGenerator = (IManagedCommandLineGenerator) element.createExecutableExtension(COMMAND_LINE_GENERATOR); commandLineGenerator = (IManagedCommandLineGenerator) element.createExecutableExtension(COMMAND_LINE_GENERATOR);
commandLineGeneratorElement = null; // no longer needed now that we've created one
return commandLineGenerator; return commandLineGenerator;
} }
} catch (CoreException e) {} } catch (CoreException e) {}
@ -2143,7 +2164,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
* @see org.eclipse.cdt.managedbuilder.core.ITool#setDependencyGeneratorElement(String) * @see org.eclipse.cdt.managedbuilder.core.ITool#setDependencyGeneratorElement(String)
* @deprecated * @deprecated
*/ */
public void setDependencyGeneratorElement(IConfigurationElement element) { private void setDependencyGeneratorElement(IConfigurationElement element) {
dependencyGeneratorElement = element; dependencyGeneratorElement = element;
setDirty(true); setDirty(true);
} }
@ -2165,8 +2186,10 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
if (element.getAttribute(DEP_CALC_ID) != null) { if (element.getAttribute(DEP_CALC_ID) != null) {
dependencyGenerator = (IManagedDependencyGeneratorType) element.createExecutableExtension(DEP_CALC_ID); dependencyGenerator = (IManagedDependencyGeneratorType) element.createExecutableExtension(DEP_CALC_ID);
if (dependencyGenerator != null) { if (dependencyGenerator != null) {
if (dependencyGenerator instanceof IManagedDependencyGenerator) if (dependencyGenerator instanceof IManagedDependencyGenerator) {
dependencyGeneratorElement = null; // no longer needed now that we've created one
return (IManagedDependencyGenerator)dependencyGenerator; return (IManagedDependencyGenerator)dependencyGenerator;
}
else else
return null; return null;
} }
@ -2790,6 +2813,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
optionPathConverter = toolchain.getOptionPathConverter(); optionPathConverter = toolchain.getOptionPathConverter();
} }
} }
pathconverterElement = null; // discard now that we've created one
return optionPathConverter ; return optionPathConverter ;
} }