Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 2061 Details for
Bug 21029
Need better story for external tool builders
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch file with proposed solution
build-command-patch.diff (text/plain), 31.49 KB, created by
John Arthorne
on 2002-09-25 15:39:28 EDT
(
hide
)
Description:
patch file with proposed solution
Filename:
MIME Type:
Creator:
John Arthorne
Created:
2002-09-25 15:39:28 EDT
Size:
31.49 KB
patch
obsolete
>Index: .project >=================================================================== >RCS file: /home/eclipse/org.eclipse.core.resources/.project,v >retrieving revision 1.7 >diff -u -r1.7 .project >--- .project 17 Jul 2002 19:24:47 -0000 1.7 >+++ .project 25 Sep 2002 19:35:22 -0000 >@@ -14,39 +14,6 @@ > <arguments> > </arguments> > </buildCommand> >- <buildCommand> >- <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> >- <arguments> >- <dictionary> >- <key>!{tool_args}</key> >- <value>-DbuildType=${build_type}</value> >- </dictionary> >- <dictionary> >- <key>!{tool_loc}</key> >- <value>${workspace_loc:/org.eclipse.core.resources/scripts/buildExtraJAR.xml}</value> >- </dictionary> >- <dictionary> >- <key>!{tool_dir}</key> >- <value></value> >- </dictionary> >- <dictionary> >- <key>!{tool_refresh}</key> >- <value>${none}</value> >- </dictionary> >- <dictionary> >- <key>!{tool_name}</key> >- <value>org.eclipse.core.resources extra builder</value> >- </dictionary> >- <dictionary> >- <key>!{tool_type}</key> >- <value>org.eclipse.ui.externaltools.type.ant</value> >- </dictionary> >- <dictionary> >- <key>!{tool_show_log}</key> >- <value>true</value> >- </dictionary> >- </arguments> >- </buildCommand> > </buildSpec> > <natures> > <nature>org.eclipse.jdt.core.javanature</nature> >Index: src/org/eclipse/core/internal/events/BuildCommand.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/events/BuildCommand.java,v >retrieving revision 1.6 >diff -u -r1.6 BuildCommand.java >--- src/org/eclipse/core/internal/events/BuildCommand.java 23 Jul 2002 13:54:31 -0000 1.6 >+++ src/org/eclipse/core/internal/events/BuildCommand.java 25 Sep 2002 19:35:22 -0000 >@@ -17,10 +17,17 @@ > import org.eclipse.core.resources.ICommand; > public class BuildCommand extends ModelObject implements ICommand { > protected HashMap arguments; >+ /** Cached hash code for performance */ >+ protected int hash = -1; >+ > public BuildCommand() { > super(""); //$NON-NLS-1$ > this.arguments = new HashMap(0); > } >+public BuildCommand(String builderName, Map arguments) { >+ super(builderName); >+ this.arguments = new HashMap(arguments); >+} > public Object clone() { > BuildCommand result = null; > result = (BuildCommand) super.clone(); >@@ -34,10 +41,13 @@ > return true; > if (!(object instanceof BuildCommand)) > return false; >+ //for performance compare the cached hash value first >+ if (hashCode() != object.hashCode()) >+ return false; > BuildCommand command = (BuildCommand) object; > // equal if same builder name and equal argument tables >- return getBuilderName().equals(command.getBuilderName()) && >- getArguments(false).equals(command.getArguments(false)); >+ return (name == null ? command.name == null : name.equals(command.name)) && >+ (arguments == null ? command.arguments == null : arguments.equals(command.arguments)); > } > /** > * @see ICommand#getArguments >@@ -55,8 +65,14 @@ > return getName(); > } > public int hashCode() { >- // hash on name alone >- return getName().hashCode(); >+ //lazily compute and cache hashcode >+ if (hash == -1) { >+ String name = getName(); >+ hash = name == null ? 17 : name.hashCode() * 37; >+ if (arguments != null) >+ hash += arguments.hashCode(); >+ } >+ return hash; > } > /** > * @see ICommand#setArguments >@@ -64,6 +80,7 @@ > public void setArguments(Map value) { > // copy parameter for safety's sake > arguments = value == null ? null : new HashMap(value); >+ hash = -1; > } > /** > * @see ICommand#setBuilderName >@@ -71,5 +88,6 @@ > public void setBuilderName(String value) { > //don't allow builder name to be null > setName(value == null ? "" : value); //$NON-NLS-1$ >+ hash = -1; > } > } >Index: src/org/eclipse/core/internal/events/BuildManager.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/events/BuildManager.java,v >retrieving revision 1.29 >diff -u -r1.29 BuildManager.java >--- src/org/eclipse/core/internal/events/BuildManager.java 20 Sep 2002 18:02:45 -0000 1.29 >+++ src/org/eclipse/core/internal/events/BuildManager.java 25 Sep 2002 19:35:22 -0000 >@@ -26,6 +26,16 @@ > //used for debug/trace timing > private long timeStamp = -1; > >+ /** >+ * Persistent information for builders that have not yet been instantiated. >+ * For closed projects, this contains (IProject -> (List of BuilderPersistentInfo)). >+ * For open projects: (IProject -> (Map of (ICommand -> BuilderPersistentInfo))) >+ * This is because the build commands are not yet known for closed projects >+ * since the project description has not been read from disk. The >+ * opening() method performs the conversion from one format to the other. >+ */ >+ private final Map builderPersistentInfo = new HashMap(); >+ > //the following four fields only apply for the lifetime of > //a single builder invocation. > protected ElementTree currentTree; >@@ -159,11 +169,11 @@ > }; > Platform.run(code); > } >-protected void basicBuild(IProject project, int trigger, String builderName, Map args, MultiStatus status, IProgressMonitor monitor) { >+protected void basicBuild(IProject project, int trigger, ICommand command, MultiStatus status, IProgressMonitor monitor) { > IncrementalProjectBuilder builder = null; > try { >- builder = getBuilder(builderName, project); >- if (!validateNature(builder, builderName)) { >+ builder = getBuilder(command, project); >+ if (!validateNature(builder, command.getBuilderName())) { > //skip this builder and null its last built tree because it is invalid > //if the nature gets added or re-enabled a full build will be triggered > ((InternalBuilder)builder).setLastBuiltTree(null); >@@ -173,7 +183,7 @@ > status.add(e.getStatus()); > return; > } >- basicBuild(trigger, builder, args, status, monitor); >+ basicBuild(trigger, builder, ((BuildCommand)command).getArguments(false), status, monitor); > } > protected void basicBuild(IProject project, int trigger, ICommand[] commands, MultiStatus status, IProgressMonitor monitor) { > monitor = Policy.monitorFor(monitor); >@@ -183,7 +193,7 @@ > for (int i = 0; i < commands.length; i++) { > IProgressMonitor sub = Policy.subMonitorFor(monitor, 1); > BuildCommand command = (BuildCommand) commands[i]; >- basicBuild(project, trigger, command.getBuilderName(), command.getArguments(false), status, sub); >+ basicBuild(project, trigger, command, status, sub); > Policy.checkCanceled(monitor); > } > } finally { >@@ -247,7 +257,7 @@ > try { > building = true; > MultiStatus status = new MultiStatus(ResourcesPlugin.PI_RESOURCES, IResourceStatus.INTERNAL_ERROR, Policy.bind("events.errors"), null); //$NON-NLS-1$ >- basicBuild(project, kind, builderName, args, status, Policy.subMonitorFor(monitor, 1)); >+ basicBuild(project, kind, new BuildCommand(builderName, args), status, Policy.subMonitorFor(monitor, 1)); > if (!status.isOK()) > throw new ResourceException(status); > } finally { >@@ -266,12 +276,13 @@ > public void closing(IProject project) { > } > /** >- * Creates and returns a Map mapping String(builder name) -> BuilderPersistentInfo. >- * The table includes entries for all builders that are >- * in the builder spec, and that have a last built state, even if they >- * have not been instantiated this session. >+ * Creates and returns a List of BuilderPersistentInfo, or null if there are >+ * no builders for this project. >+ * The list includes entries for all builders that are in the builder spec, and >+ * that have a last built state, even if they have not been instantiated this >+ * session. > */ >-public Map createBuildersPersistentInfo(IProject project) throws CoreException { >+public List createBuildersPersistentInfo(IProject project) throws CoreException { > /* get the old builder map */ > Map oldInfos = getBuildersPersistentInfo(project); > >@@ -280,30 +291,31 @@ > return null; > > /* build the new map */ >- Map newInfos = new HashMap(buildCommands.length * 2); >- Hashtable instantiatedBuilders = getBuilders(project); >+ List newInfos = new ArrayList(buildCommands.length); >+ Map instantiatedBuilders = getBuilders(project); > for (int i = 0; i < buildCommands.length; i++) { >- String builderName = buildCommands[i].getBuilderName(); >+ ICommand command = buildCommands[i]; > BuilderPersistentInfo info = null; >- IncrementalProjectBuilder builder = (IncrementalProjectBuilder) instantiatedBuilders.get(builderName); >+ InternalBuilder builder = (InternalBuilder) instantiatedBuilders.get(command); > if (builder == null) { > // if the builder was not instantiated, use the old info if any. > if (oldInfos != null) >- info = (BuilderPersistentInfo) oldInfos.get(builderName); >+ info = (BuilderPersistentInfo) oldInfos.get(command); > } else if (!(builder instanceof MissingBuilder)) { >- ElementTree oldTree = ((InternalBuilder) builder).getLastBuiltTree(); >- //don't persist build state for builders that have no last built state >+ ElementTree oldTree = builder.getLastBuiltTree(); >+ //don't persist build state for builders that have no last built tree > if (oldTree != null) { >- // if the builder was instantiated, construct a memento with the important info >+ // construct a memento with the important info > info = new BuilderPersistentInfo(); > info.setProjectName(project.getName()); >- info.setBuilderName(builderName); >+ info.setBuilderName(command.getBuilderName()); > info.setLastBuildTree(oldTree); >- info.setInterestingProjects(((InternalBuilder)builder).getInterestingProjects()); >+ info.setInterestingProjects(builder.getInterestingProjects()); >+ info.setBuildSpecPosition(i); > } > } > if (info != null) >- newInfos.put(builderName, info); >+ newInfos.add(info); > } > return newInfos; > } >@@ -317,37 +329,41 @@ > } > public void deleting(IProject project) { > //make sure the builder persistent info is deleted for the project move case >- if (project.isAccessible()) >- setBuildersPersistentInfo(project, null); >+ setBuildersPersistentInfo(project, null); > } >-protected IncrementalProjectBuilder getBuilder(String builderName, IProject project) throws CoreException { >- Hashtable builders = getBuilders(project); >- IncrementalProjectBuilder result = (IncrementalProjectBuilder) builders.get(builderName); >+protected IncrementalProjectBuilder getBuilder(ICommand command, IProject project) throws CoreException { >+ Map builders = getBuilders(project); >+ IncrementalProjectBuilder result = (IncrementalProjectBuilder) builders.get(command); > if (result != null) > return result; >- result = initializeBuilder(builderName, project); >- builders.put(builderName, result); >+ result = initializeBuilder(command, project); >+ builders.put(command, result); > ((InternalBuilder) result).setProject(project); >- ((InternalBuilder) result).startupOnInitialize(); >+ result.startupOnInitialize(); > return result; > } > /** >- * Returns a hashtable of all instantiated builders for the given project. >- * This hashtable maps String(builder name) -> Builder. >+ * Returns a map of all instantiated builders for the given project. >+ * This hashtable maps ICommand -> Builder. > */ >-protected Hashtable getBuilders(IProject project) { >+protected Map getBuilders(IProject project) { > ProjectInfo info = (ProjectInfo) workspace.getResourceInfo(project.getFullPath(), false, false); > Assert.isNotNull(info, Policy.bind("events.noProject", project.getName())); //$NON-NLS-1$ > return info.getBuilders(); > } > /** >- * Returns a Map mapping String(builder name) -> BuilderPersistentInfo. >+ * Returns a Map mapping ICommand -> BuilderPersistentInfo, or >+ * null if there is no persistent info for this project. > * The map includes entries for all builders that are in the builder spec, >- * and that have a last built state, even if they have not been instantiated >+ * and that have a last built state, but have not been instantiated > * this session. > */ > public Map getBuildersPersistentInfo(IProject project) throws CoreException { >- return (Map) project.getSessionProperty(K_BUILD_MAP); >+ Object result = builderPersistentInfo.get(project); >+ //for closed projects this will be a List >+ if (result instanceof Map) >+ return (Map)result; >+ return null; > } > protected IResourceDelta getDelta(IProject project) { > if (currentTree == null) { >@@ -437,8 +453,9 @@ > * prevent trying to instantiate it every time a build is run. > * This method NEVER returns null. > */ >-protected IncrementalProjectBuilder initializeBuilder(String builderName, IProject project) throws CoreException { >+protected IncrementalProjectBuilder initializeBuilder(ICommand command, IProject project) throws CoreException { > try { >+ String builderName = command.getBuilderName(); > IncrementalProjectBuilder builder = instantiateBuilder(builderName); > if (builder == null) { > //unable to create the builder, so create a placeholder to fill in for it >@@ -447,7 +464,7 @@ > // get the map of builders to get the last built tree > Map infos = getBuildersPersistentInfo(project); > if (infos != null) { >- BuilderPersistentInfo info = (BuilderPersistentInfo) infos.remove(builderName); >+ BuilderPersistentInfo info = (BuilderPersistentInfo) infos.remove(command); > if (info != null) { > ElementTree tree = info.getLastBuiltTree(); > if (tree != null) >@@ -456,7 +473,7 @@ > } > // delete the build map if it's now empty > if (infos.size() == 0) >- setBuildersPersistentInfo(project, null); >+ builderPersistentInfo.remove(project); > } > return builder; > } catch (CoreException e) { >@@ -541,6 +558,36 @@ > return false; > } > public void opening(IProject project) { >+ //a project is being opened. link builder persistent info to appropriate >+ //command in the build spec >+ List infoList = (List)builderPersistentInfo.remove(project); >+ if (infoList == null || infoList.size() == 0) >+ return;//no builders for this project >+ >+ ProjectDescription description = ((Project)project).internalGetDescription(); >+ if (description != null) { >+ ICommand[] commands = description.getBuildSpec(false); >+ //create map of ICommand->BuilderPersistentInfo >+ HashMap infoMap = new HashMap(commands.length * 2 + 1); >+ for (Iterator it = infoList.iterator(); it.hasNext();) { >+ BuilderPersistentInfo info = (BuilderPersistentInfo) it.next(); >+ int position = info.getBuildSpecPosition(); >+ if (position >= 0 && position < commands.length) >+ infoMap.put(commands[position], info); >+ else { >+ //backwards compatibility -- build spec position wasn't previously stored >+ //find a build command with matching builder name >+ String builderName = info.getBuilderName(); >+ for (int i = 0; i < commands.length; i++) { >+ if (commands[i].getBuilderName().equals(builderName)) { >+ infoMap.put(commands[i], info); >+ break; >+ } >+ } >+ } >+ } >+ builderPersistentInfo.put(project, infoMap); >+ } > } > /** > * Removes all builders with the given ID from the build spec. >@@ -573,21 +620,14 @@ > } > > /** >- * Sets the builder map for the given project. The builder map is >- * a Map mapping String(builder name) -> BuilderPersistentInfo. >- * The map includes entries for all builders that are >- * in the builder spec, and that have a last built state, even if they >- * have not been instantiated this session. >+ * Supplies the list of BuilderPersistentInfo objects that was serialized >+ * on shutdown. This list includes entries for all builders that are >+ * in the builder spec, have a last built state, but have not been instantiated >+ * yest this session. Infos should only ever be supplied on startup, as this >+ * information depends on the current ordering of the project's build spec. > */ >-public void setBuildersPersistentInfo(IProject project, Map map) { >- try { >- project.setSessionProperty(K_BUILD_MAP, map); >- } catch (CoreException e) { >- //project is missing -- build state will be lost >- //can't throw an exception because this happens on startup >- IStatus error = new ResourceStatus(IStatus.ERROR, 1, project.getFullPath(), "Project missing in setBuildersPersistentInfo", null); >- ResourcesPlugin.getPlugin().getLog().log(error); >- } >+public void setBuildersPersistentInfo(IProject project, List infoList) { >+ builderPersistentInfo.put(project, infoList); > } > public void shutdown(IProgressMonitor monitor) { > } >Index: src/org/eclipse/core/internal/events/BuilderPersistentInfo.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/events/BuilderPersistentInfo.java,v >retrieving revision 1.5 >diff -u -r1.5 BuilderPersistentInfo.java >--- src/org/eclipse/core/internal/events/BuilderPersistentInfo.java 23 Jul 2002 13:54:31 -0000 1.5 >+++ src/org/eclipse/core/internal/events/BuilderPersistentInfo.java 25 Sep 2002 19:35:22 -0000 >@@ -19,18 +19,12 @@ > protected String builderName; > protected ElementTree lastBuildTree; > protected IProject[] interestingProjects = ICoreConstants.EMPTY_PROJECT_ARRAY; >- >-public void setProjectName(String name) { >- projectName = name; >-} >-public void setBuilderName(String name) { >- builderName = name; >-} >-public void setLastBuildTree(ElementTree tree) { >- lastBuildTree = tree; >+ /** Offset of this builder in the build spec */ >+ protected int buildSpecPosition; >+public BuilderPersistentInfo() { > } >-public void setInterestingProjects(IProject[] projects) { >- interestingProjects = projects; >+public int getBuildSpecPosition() { >+ return buildSpecPosition; > } > public String getProjectName() { > return projectName; >@@ -43,5 +37,20 @@ > } > public IProject[] getInterestingProjects() { > return interestingProjects; >+} >+public void setProjectName(String name) { >+ projectName = name; >+} >+public void setBuilderName(String name) { >+ builderName = name; >+} >+public void setBuildSpecPosition(int buildSpecPosition) { >+ this.buildSpecPosition = buildSpecPosition; >+} >+public void setLastBuildTree(ElementTree tree) { >+ lastBuildTree = tree; >+} >+public void setInterestingProjects(IProject[] projects) { >+ interestingProjects = projects; > } > } >Index: src/org/eclipse/core/internal/resources/ICoreConstants.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ICoreConstants.java,v >retrieving revision 1.11 >diff -u -r1.11 ICoreConstants.java >--- src/org/eclipse/core/internal/resources/ICoreConstants.java 17 May 2002 19:38:00 -0000 1.11 >+++ src/org/eclipse/core/internal/resources/ICoreConstants.java 25 Sep 2002 19:35:22 -0000 >@@ -16,8 +16,10 @@ > public interface ICoreConstants { > > // Standard resource SessionProperties >- /** map of builders to their last built state. */ >+ /** map of build commands to their last built state. */ > public static final QualifiedName K_BUILD_MAP = new QualifiedName(ResourcesPlugin.PI_RESOURCES, "BuildMap"); //$NON-NLS-1$ >+ /** list of builder persistent info */ >+ public static final QualifiedName K_BUILD_LIST = new QualifiedName(ResourcesPlugin.PI_RESOURCES, "BuildList"); //$NON-NLS-1$ > > // resource info constants > static final long I_UNKNOWN_SYNC_INFO = -2; >@@ -63,6 +65,7 @@ > > public static final int WORKSPACE_TREE_VERSION_1 = 67305985; > public static final int WORKSPACE_TREE_VERSION_2 = 67305986; >+ public static final int WORKSPACE_TREE_VERSION_3 = 67305987; > > // helper constants for empty structures > public static final IProject[] EMPTY_PROJECT_ARRAY = new IProject[0]; >Index: src/org/eclipse/core/internal/resources/SaveManager.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java,v >retrieving revision 1.36 >diff -u -r1.36 SaveManager.java >--- src/org/eclipse/core/internal/resources/SaveManager.java 21 Aug 2002 18:44:42 -0000 1.36 >+++ src/org/eclipse/core/internal/resources/SaveManager.java 25 Sep 2002 19:35:22 -0000 >@@ -26,8 +26,7 @@ > protected Properties masterTable; > protected ElementTree lastSnap; > protected int operationCount = 0; >- protected boolean snapshotRequested; >- >+ protected boolean snapshotRequested; > > protected DelayedSnapshotRunnable snapshotRunnable; > >@@ -173,9 +172,9 @@ > for (int i = 0; i < projects.length; i++) { > IProject project = projects[i]; > if (project.isOpen()) { >- Map builderInfos = workspace.getBuildManager().createBuildersPersistentInfo(project); >+ List builderInfos = workspace.getBuildManager().createBuildersPersistentInfo(project); > if (builderInfos != null) { >- for (Iterator it = builderInfos.values().iterator(); it.hasNext();) { >+ for (Iterator it = builderInfos.iterator(); it.hasNext();) { > BuilderPersistentInfo info = (BuilderPersistentInfo) it.next(); > trees.add(info.getLastBuiltTree()); > } >@@ -765,8 +764,7 @@ > workspace.getMetaArea().write(description); > IProject[] roots = workspace.getRoot().getProjects(); > for (int i = 0; i < roots.length; i++) >- if (roots[i].isAccessible()) >- saveMetaInfo((Project) roots[i], null); >+ saveMetaInfo((Project) roots[i], null); > } > /** > * Writes the current state of the entire workspace tree to disk. >@@ -780,7 +778,7 @@ > IPath tempLocation = workspace.getMetaArea().getBackupLocationFor(treeLocation); > DataOutputStream output = new DataOutputStream(new SafeFileOutputStream(treeLocation.toOSString(), tempLocation.toOSString())); > try { >- output.writeInt(ICoreConstants.WORKSPACE_TREE_VERSION_2); >+ output.writeInt(ICoreConstants.WORKSPACE_TREE_VERSION_3); > writeTree(computeStatesToSave(contexts, workspace.getElementTree()), output, monitor); > } finally { > output.close(); >@@ -870,7 +868,7 @@ > SafeChunkyOutputStream safeStream = new SafeChunkyOutputStream(localFile); > DataOutputStream out = new DataOutputStream(safeStream); > try { >- out.writeInt(ICoreConstants.WORKSPACE_TREE_VERSION_2); >+ out.writeInt(ICoreConstants.WORKSPACE_TREE_VERSION_3); > writeWorkspaceFields(out, monitor); > writer.writeDelta(tree, lastSnap, Path.ROOT, writer.D_INFINITE, out, ResourceComparator.getComparator()); > safeStream.succeed(); >@@ -980,16 +978,16 @@ > > // add builders' trees > IProject[] projects = workspace.getRoot().getProjects(); >- List builders = new ArrayList(projects.length * 2); >+ List builderInfos = new ArrayList(projects.length * 2); > for (int i = 0; i < projects.length; i++) { > IProject project = projects[i]; > if (project.isOpen()) { >- Map infos = workspace.getBuildManager().createBuildersPersistentInfo(project); >+ List infos = workspace.getBuildManager().createBuildersPersistentInfo(project); > if (infos != null) >- builders.addAll(infos.values()); >+ builderInfos.addAll(infos); > } > } >- writeBuilderPersistentInfo(output, builders, trees, Policy.subMonitorFor(monitor, Policy.totalWork * 10 / 100)); >+ writeBuilderPersistentInfo(output, builderInfos, trees, Policy.subMonitorFor(monitor, Policy.totalWork * 10 / 100)); > > // add the current tree in the list as the last element > trees.add(current); >@@ -1014,7 +1012,7 @@ > SafeFileOutputStream safe = new SafeFileOutputStream(treeLocation.toOSString(), tempLocation.toOSString()); > try { > DataOutputStream output = new DataOutputStream(safe); >- output.writeInt(ICoreConstants.WORKSPACE_TREE_VERSION_2); >+ output.writeInt(ICoreConstants.WORKSPACE_TREE_VERSION_3); > writeTree(project, output, null); > } finally { > safe.close(); >@@ -1037,13 +1035,13 @@ > boolean wasImmutable = false; > try { > /** >- * Obtain a table of String(builder name) -> BuilderPersistentInfo. >+ * Obtain a List of BuilderPersistentInfo for this project > * This includes builders that have never been instantiated > * but already had a last built state. > */ >- Map builderInfos = workspace.getBuildManager().createBuildersPersistentInfo(project); >- List builders = builderInfos == null ? new ArrayList(5) : new ArrayList(builderInfos.values()); >- List trees = new ArrayList(builders.size() + 1); >+ List builderInfos = workspace.getBuildManager().createBuildersPersistentInfo(project); >+ int numBuilders = builderInfos == null ? 0 : builderInfos.size(); >+ List trees = new ArrayList(numBuilders + 1); > monitor.worked(1); > > /* Make sure the most recent tree is in the array */ >@@ -1052,7 +1050,7 @@ > current.immutable(); > > /* add the tree for each builder to the array */ >- writeBuilderPersistentInfo(output, builders, trees, Policy.subMonitorFor(monitor, 1)); >+ writeBuilderPersistentInfo(output, builderInfos, trees, Policy.subMonitorFor(monitor, 1)); > trees.add(current); > > /* save the forest! */ >@@ -1426,13 +1424,14 @@ > for (int i = 0; i < projects.length; i++) > visitAndSnap(projects[i]); > } >-protected void writeBuilderPersistentInfo(DataOutputStream output, List builders, List trees, IProgressMonitor monitor) throws IOException { >+protected void writeBuilderPersistentInfo(DataOutputStream output, List builderInfos, List trees, IProgressMonitor monitor) throws IOException { > monitor = Policy.monitorFor(monitor); > try { > // write the number of builders we are saving >- output.writeInt(builders.size()); >- for (int i = 0; i < builders.size(); i++) { >- BuilderPersistentInfo info = (BuilderPersistentInfo) builders.get(i); >+ int numBuilders = builderInfos == null ? 0 : builderInfos.size(); >+ output.writeInt(numBuilders); >+ for (int i = 0; i < numBuilders; i++) { >+ BuilderPersistentInfo info = (BuilderPersistentInfo) builderInfos.get(i); > output.writeUTF(info.getProjectName()); > output.writeUTF(info.getBuilderName()); > // write interesting projects >@@ -1440,6 +1439,8 @@ > output.writeInt(interestingProjects.length); > for (int j = 0; j < interestingProjects.length; j++) > output.writeUTF(interestingProjects[j].getName()); >+ //write build spec position >+ output.writeInt(info.getBuildSpecPosition()); > ElementTree last = info.getLastBuiltTree(); > if (last ==null) { > //try to be resilient if a builder has no last built tree >Index: src/org/eclipse/core/internal/resources/WorkspaceTreeReader.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/WorkspaceTreeReader.java,v >retrieving revision 1.7 >diff -u -r1.7 WorkspaceTreeReader.java >--- src/org/eclipse/core/internal/resources/WorkspaceTreeReader.java 17 May 2002 19:38:00 -0000 1.7 >+++ src/org/eclipse/core/internal/resources/WorkspaceTreeReader.java 25 Sep 2002 19:35:22 -0000 >@@ -81,7 +81,7 @@ > monitor.done(); > } > } >-protected void readBuildersPersistentInfo(DataInputStream input, List builders, IProgressMonitor monitor) throws IOException, CoreException { >+protected void readBuildersPersistentInfo(DataInputStream input, List builders, IProgressMonitor monitor) throws IOException { > monitor = Policy.monitorFor(monitor); > try { > int builderCount = input.readInt(); >@@ -139,7 +139,7 @@ > protected void linkBuildersToTrees(List buildersToBeLinked, ElementTree[] trees, int index, IProgressMonitor monitor) throws CoreException { > monitor = Policy.monitorFor(monitor); > try { >- HashMap infos = null; >+ ArrayList infos = null; > String projectName = null; > for (int i = 0; i < buildersToBeLinked.size(); i++) { > BuilderPersistentInfo info = (BuilderPersistentInfo) buildersToBeLinked.get(i); >@@ -149,10 +149,10 @@ > workspace.getBuildManager().setBuildersPersistentInfo(project, infos); > } > projectName = info.getProjectName(); >- infos = new HashMap(5); >+ infos = new ArrayList(5); > } > info.setLastBuildTree(trees[index++]); >- infos.put(info.getBuilderName(), info); >+ infos.add(info); > } > if (infos != null) { > IProject project = workspace.getRoot().getProject(projectName); >@@ -195,6 +195,8 @@ > return new WorkspaceTreeReader(workspace); > case ICoreConstants.WORKSPACE_TREE_VERSION_2: > return new WorkspaceTreeReader_2(workspace); >+ case ICoreConstants.WORKSPACE_TREE_VERSION_3: >+ return new WorkspaceTreeReader_3(workspace); > default: > // The following class should be > // removed soon. See comments in WorkspaceTreeReader_0. >@@ -226,13 +228,13 @@ > > /* map builder names to trees */ > if (numBuilders > 0) { >- Map infos = new HashMap(trees.length * 2 + 1); >+ ArrayList infos = new ArrayList(trees.length * 2 + 1); > for (int i = 0; i < numBuilders; i++) { > BuilderPersistentInfo info = new BuilderPersistentInfo(); > info.setBuilderName(builderNames[i]); > info.setProjectName(project.getName()); > info.setLastBuildTree(trees[i]); >- infos.put(builderNames[i], info); >+ infos.add(info); > } > workspace.getBuildManager().setBuildersPersistentInfo(project, infos); > } >Index: src/org/eclipse/core/internal/resources/WorkspaceTreeReader_3.java >=================================================================== >RCS file: src/org/eclipse/core/internal/resources/WorkspaceTreeReader_3.java >diff -N src/org/eclipse/core/internal/resources/WorkspaceTreeReader_3.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/resources/WorkspaceTreeReader_3.java 25 Sep 2002 19:35:22 -0000 >@@ -0,0 +1,58 @@ >+/********************************************************************** >+ * Copyright (c) 2002 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.core.internal.resources; >+ >+import java.io.DataInputStream; >+import java.io.IOException; >+import java.util.List; >+ >+import org.eclipse.core.internal.events.BuilderPersistentInfo; >+import org.eclipse.core.internal.utils.Policy; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+ >+/** >+ * Reads .tree files in format version 3. >+ */ >+public class WorkspaceTreeReader_3 extends WorkspaceTreeReader_2 { >+public WorkspaceTreeReader_3(Workspace workspace) { >+ super(workspace); >+} >+protected int getVersion() { >+ return ICoreConstants.WORKSPACE_TREE_VERSION_3; >+} >+/** >+ * @see org.eclipse.core.internal.resources.WorkspaceTreeReader#readBuildersPersistentInfo(DataInputStream, List, IProgressMonitor) >+ */ >+protected void readBuildersPersistentInfo(DataInputStream input, List builders, IProgressMonitor monitor) throws IOException { >+ monitor = Policy.monitorFor(monitor); >+ try { >+ int builderCount = input.readInt(); >+ for (int i = 0; i < builderCount; i++) { >+ BuilderPersistentInfo info = new BuilderPersistentInfo(); >+ info.setProjectName(input.readUTF()); >+ info.setBuilderName(input.readUTF()); >+ // read interesting projects >+ int n = input.readInt(); >+ IProject[] projects = new IProject[n]; >+ for (int j = 0; j < n; j++) >+ projects[j] = workspace.getRoot().getProject(input.readUTF()); >+ info.setInterestingProjects(projects); >+ //read build spec position >+ info.setBuildSpecPosition(input.readInt()); >+ builders.add(info); >+ } >+ } finally { >+ monitor.done(); >+ } >+} >+} >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 21029
: 2061 |
13952
|
13953