mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46:02 +02:00
fixed junit failures and deadlock problems
This commit is contained in:
parent
4a12e51cb9
commit
09a4ea370c
3 changed files with 62 additions and 19 deletions
|
@ -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.
|
||||
|
|
|
@ -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();
|
||||
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);
|
||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
|
||||
|
||||
Element rootElement = descriptor.getProjectData(CDESCRIPTOR_ID);
|
||||
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();
|
||||
}
|
||||
// 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);
|
||||
descriptor.saveProjectData();
|
||||
migrateToCPathEntries(scannerInfo);
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue