diff options
author | David Inglis | 2004-05-26 14:48:54 +0000 |
---|---|---|
committer | David Inglis | 2004-05-26 14:48:54 +0000 |
commit | 09a4ea370cd03cca08ddfea0239bc0263a36f158 (patch) | |
tree | f06e23e7b65b94c0d6440ee855bf137ff55f7a9a | |
parent | 4a12e51cb9273662c3630a529943b955a56053f0 (diff) | |
download | org.eclipse.cdt-09a4ea370cd03cca08ddfea0239bc0263a36f158.tar.gz org.eclipse.cdt-09a4ea370cd03cca08ddfea0239bc0263a36f158.tar.xz org.eclipse.cdt-09a4ea370cd03cca08ddfea0239bc0263a36f158.zip |
fixed junit failures and deadlock problems
3 files changed, 66 insertions, 23 deletions
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeProjectNature.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeProjectNature.java index 87e0cc257c8..1e00511c1e2 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeProjectNature.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeProjectNature.java @@ -36,8 +36,7 @@ public class MakeProjectNature implements IProjectNature { project.setDescription(description, monitor); } - public static ICommand getBuildSpec(IProject project, String builderID) throws CoreException { - IProjectDescription description = project.getDescription(); + public static ICommand getBuildSpec(IProjectDescription description, String builderID) throws CoreException { ICommand[] commands = description.getBuildSpec(); for (int i = 0; i < commands.length; ++i) { if (commands[i].getBuilderName().equals(builderID)) { @@ -46,6 +45,37 @@ public class MakeProjectNature implements IProjectNature { } return null; } + + /** + * Update the Java command in the build spec (replace existing one if present, + * add one first if none). + */ + public static IProjectDescription setBuildSpec(IProjectDescription description, ICommand newCommand) + throws CoreException { + + ICommand[] oldCommands = description.getBuildSpec(); + ICommand oldCommand = getBuildSpec(description, newCommand.getBuilderName()); + ICommand[] newCommands; + + if (oldCommand == null) { + // Add a Java build spec before other builders (1FWJK7I) + newCommands = new ICommand[oldCommands.length + 1]; + System.arraycopy(oldCommands, 0, newCommands, 1, oldCommands.length); + newCommands[0] = newCommand; + } else { + for (int i = 0, max = oldCommands.length; i < max; i++) { + if (oldCommands[i] == oldCommand) { + oldCommands[i] = newCommand; + break; + } + } + newCommands = oldCommands; + } + + // Commit the spec change into the project + description.setBuildSpec(newCommands); + return description; + } /** * Adds a builder to the build spec for the given project. diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeScannerProvider.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeScannerProvider.java index 8efb2b61721..c283a730c29 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeScannerProvider.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeScannerProvider.java @@ -28,7 +28,10 @@ import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.resources.ScannerProvider; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.QualifiedName; import org.w3c.dom.Element; @@ -175,22 +178,27 @@ public class MakeScannerProvider extends ScannerProvider { * * @param project */ - public static void updateScannerInfo(MakeScannerInfo scannerInfo) throws CoreException { - IProject project = scannerInfo.getProject(); - - ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project); - - Element rootElement = descriptor.getProjectData(CDESCRIPTOR_ID); - - // Clear out all current children - // Note: Probably would be a better idea to merge in the data - Node child = rootElement.getFirstChild(); - while (child != null) { - rootElement.removeChild(child); - child = rootElement.getFirstChild(); - } - - descriptor.saveProjectData(); - migrateToCPathEntries(scannerInfo); + public static void updateScannerInfo(final MakeScannerInfo scannerInfo) throws CoreException { + ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { + + public void run(IProgressMonitor monitor) throws CoreException { + IProject project = scannerInfo.getProject(); + + ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project); + + Element rootElement = descriptor.getProjectData(CDESCRIPTOR_ID); + + // Clear out all current children + // Note: Probably would be a better idea to merge in the data + Node child = rootElement.getFirstChild(); + while (child != null) { + rootElement.removeChild(child); + child = rootElement.getFirstChild(); + } + + descriptor.saveProjectData(); + migrateToCPathEntries(scannerInfo); + } + }, null); } }
\ No newline at end of file diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java index d6871ba19bc..66da7766508 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java @@ -24,6 +24,7 @@ import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.core.MakeProjectNature; import org.eclipse.core.resources.ICommand; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; @@ -316,7 +317,7 @@ public class BuildInfoFactory { this.project = project; this.builderID = builderID; ICommand builder; - builder = MakeProjectNature.getBuildSpec(project, builderID); + builder = MakeProjectNature.getBuildSpec(project.getDescription(), builderID); if (builder == null) { throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, MakeMessages.getString("BuildInfoFactory.Missing_Builder") + builderID, null)); //$NON-NLS-1$ } @@ -328,10 +329,14 @@ public class BuildInfoFactory { if (curValue != null && curValue.equals(value)) { return; } - ICommand builder = MakeProjectNature.getBuildSpec(project, builderID); + IProjectDescription description = project.getDescription(); + ICommand builder = MakeProjectNature.getBuildSpec(description, builderID); args.put(name, value); - builder.setArguments(args); - project.setDescription(project.getDescription(), null); + ICommand newBuilder = description.newCommand(); + newBuilder.setBuilderName(builder.getBuilderName()); + newBuilder.setArguments(args); + description = MakeProjectNature.setBuildSpec(description, newBuilder); + project.setDescription(description, null); } protected String getString(String name) { |