Author: max.andersen(a)jboss.com
Date: 2007-07-24 13:24:49 -0400 (Tue, 24 Jul 2007)
New Revision: 2637
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
Log:
JBIDE-609
fixed NPE's, general issue was that code assumed findMembers would always return a
valid value.
It doesn't when the file doesn't exist which can easily happen if a user deletes a
source directory and doesn't update eclipses java project info about that directory
have been removed.
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2007-07-24
17:21:40 UTC (rev 2636)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2007-07-24
17:24:49 UTC (rev 2637)
@@ -487,8 +487,11 @@
for (int i = 0; i < es.length; i++) {
try {
if(es[i].getEntryKind() == IClasspathEntry.CPE_SOURCE &&
es[i].getOutputLocation() != null) {
- String s =
project.getWorkspace().getRoot().findMember(es[i].getOutputLocation()).getLocation().toString();
- l.add(new java.io.File(s).getCanonicalPath());
+ IResource findMember =
project.getWorkspace().getRoot().findMember(es[i].getOutputLocation());
+ if(findMember!=null) {
+ String s = findMember.getLocation().toString();
+ l.add(new java.io.File(s).getCanonicalPath());
+ }
}
} catch (Exception e) {
//ignore - we do not care about non-existent files here.
@@ -499,7 +502,12 @@
String s = null;
String path = es[i].getPath().toString();
if(path.startsWith("/" + project.getName() + "/")) {
- s =
project.findMember(es[i].getPath().removeFirstSegments(1)).getLocation().toString();
+ IResource findMember = project.findMember(es[i].getPath().removeFirstSegments(1));
+ if(findMember!=null) {
+ s = findMember.getLocation().toString();
+ } else {
+ s = null;
+ }
} else if(new java.io.File(path).isFile()) {
s = path;
}
@@ -615,7 +623,10 @@
IClasspathEntry[] es = javaProject.getRawClasspath();
for (int i = 0; i < es.length; i++) {
if(es[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) {
- resources.add( ModelPlugin.getWorkspace().getRoot().findMember(es[i].getPath()) );
+ IResource findMember =
ModelPlugin.getWorkspace().getRoot().findMember(es[i].getPath());
+ if(findMember!=null) {
+ resources.add( findMember );
+ }
}
}
} catch(CoreException ce) {
Show replies by date