[92400]: Shoring up resource tree to be a little more bullet proof. Committed for MDE.
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ResourceTreeNode.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ResourceTreeNode.java
index bdaca2d..5da8ffd 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ResourceTreeNode.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ResourceTreeNode.java
@@ -51,8 +51,11 @@
public ResourceTreeNode addChild(ComponentResource aModuleResource) {
ResourceTreeNode newChild = findChild(getPathProvider().getPath(aModuleResource), true);
- newChild.addModuleResource(aModuleResource);
- return newChild;
+ if(newChild != null) {
+ newChild.addModuleResource(aModuleResource);
+ return newChild;
+ }
+ return null;
}
public ResourceTreeNode removeChild(ResourceTreeNode aChild) {
@@ -61,18 +64,24 @@
public ResourceTreeNode removeChild(ComponentResource aModuleResource) {
ResourceTreeNode containingChild = findChild(getPathProvider().getPath(aModuleResource), false);
- containingChild.removeResource(aModuleResource);
- if(containingChild.hasModuleResources())
- return containingChild;
- return removeChild(containingChild);
+ if(containingChild != null) {
+ containingChild.removeResource(aModuleResource);
+ if(containingChild.hasModuleResources())
+ return containingChild;
+ return removeChild(containingChild);
+ }
+ return null;
}
public ResourceTreeNode removeChild(IPath targetPath, ComponentResource aModuleResource) {
ResourceTreeNode containingChild = findChild(targetPath, false);
- containingChild.removeResource(aModuleResource);
- if(containingChild.hasModuleResources())
- return containingChild;
- return removeChild(containingChild);
+ if(containingChild != null) {
+ containingChild.removeResource(aModuleResource);
+ if(containingChild.hasModuleResources())
+ return containingChild;
+ return removeChild(containingChild);
+ }
+ return null;
}
public void removeResource(ComponentResource aResource) {
@@ -84,6 +93,8 @@
}
public ResourceTreeNode findChild(IPath aPath, boolean toCreateChildIfNecessary) {
+ if(aPath == null)
+ return null;
ResourceTreeNode child = this;
if (aPath.segmentCount() > 0) {
child = findChild(aPath.segment(0), toCreateChildIfNecessary);