From 92de3f94c0ca2803cb3a7e03d204e4ca8543f914 Mon Sep 17 00:00:00 2001 From: Chris Recoskie Date: Wed, 4 Jun 2008 01:31:02 +0000 Subject: [PATCH] RESOLVED - bug 230161: "clean selected files" causes NullPointer exception https://bugs.eclipse.org/bugs/show_bug.cgi?id=230161 --- .../core/GeneratedMakefileBuilder.java | 67 ++++++++++--------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java index 9225141600d..7ad7a1e3601 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java @@ -1633,43 +1633,46 @@ public class GeneratedMakefileBuilder extends ACBuilder { IBuildResource buildResource = des.getBuildResource(file); - // step collector - Set dependentSteps = new HashSet(); + + if (buildResource != null) { - // get dependent IO types - IBuildIOType depTypes[] = buildResource.getDependentIOTypes(); + // step collector + Set dependentSteps = new HashSet(); - // iterate through each type and add the step the type belongs to to - // the collector - for (int j = 0; j < depTypes.length; j++) { - IBuildIOType type = depTypes[j]; - if (type != null && type.getStep() != null) - dependentSteps.add(type.getStep()); - } + // get dependent IO types + IBuildIOType depTypes[] = buildResource.getDependentIOTypes(); - // iterate through all build steps - Iterator stepIter = dependentSteps.iterator(); - - while (stepIter.hasNext()) { - IBuildStep step = (IBuildStep) stepIter.next(); - - // Delete the output resources - IBuildIOType[] outputIOTypes = step.getOutputIOTypes(); - - for (int j = 0; j < outputIOTypes.length; j++) { - IBuildResource[] resources = outputIOTypes[j] - .getResources(); - - for (int i = 0; i < resources.length; i++) { - IResource outputFile = currentProject - .findMember(resources[i].getFullPath().removeFirstSegments(1)); // strip project name - - if (outputFile != null) - outputFile.delete(true, new SubProgressMonitor( - monitor, 1)); - } + // iterate through each type and add the step the type belongs + // to to + // the collector + for (int j = 0; j < depTypes.length; j++) { + IBuildIOType type = depTypes[j]; + if (type != null && type.getStep() != null) + dependentSteps.add(type.getStep()); } + // iterate through all build steps + Iterator stepIter = dependentSteps.iterator(); + + while (stepIter.hasNext()) { + IBuildStep step = (IBuildStep) stepIter.next(); + + // Delete the output resources + IBuildIOType[] outputIOTypes = step.getOutputIOTypes(); + + for (int j = 0; j < outputIOTypes.length; j++) { + IBuildResource[] resources = outputIOTypes[j].getResources(); + + for (int i = 0; i < resources.length; i++) { + IResource outputFile = currentProject.findMember(resources[i] + .getFullPath().removeFirstSegments(1)); // strip project name + + if (outputFile != null) + outputFile.delete(true, new SubProgressMonitor(monitor, 1)); + } + } + + } } } catch (CoreException e) {