if (child.getSourceLocation().getSourceFile().equals(file))
{
because getSourceLocation() is returning
null. It seems to occur if the child
is the child of a node that is a .lst
file. My patch puts in a guard (and a
warning message right now) - if the
guard is OK then we can get rid of the
message and that can be the fix. I'm
just nervous that there is some reason
why getSourceLocation() should *not*
be returning null in this case and theres
a more complex bug underneath the problem
- hence I currently put out that
warning message. I think I'll
have to defer to Mik about that this problem though?
cheers,
- Andy.
----------8<-------8<--------8<-----------SnipHere----------
Index: AsmBuilder.java
===================================================================
RCS file: /home/technology/org.aspectj/modules/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmBuilder.java,v
retrieving revision 1.10
diff -u -r1.10 AsmBuilder.java
--- AsmBuilder.java 28 Apr 2003 23:22:37
-0000 1.10
+++ AsmBuilder.java 2 May 2003 09:44:57
-0000
@@ -107,11 +107,21 @@
}
// if the node already exists remove before
adding
ProgramElementNode duplicate = null;
+
boolean foundNullSL = false;
for (Iterator itt = pkgNode.getChildren().iterator();
itt.hasNext(); ) {
ProgramElementNode
child = (ProgramElementNode)itt.next();
-
if
(child.getSourceLocation().getSourceFile().equals(file)) {
-
duplicate = child;
-
}
+
ISourceLocation
isl = child.getSourceLocation();
+
if
(isl==null) {
+
foundNullSL = true;
+
}
else {
+
if (isl.getSourceFile().equals(file))
{
+
duplicate
= child;
+
}
+
}
+
}
+
if (foundNullSL) {
+
System.err.println("WARNING:
AsmBuilder.internalBuild(1): Node "+pkgNode+
+
" has at least one
child whose getSourceLocation() returns null");
}
if (duplicate != null) {
pkgNode.removeChild(duplicate);
@@ -120,11 +130,23 @@
}
else {
// if the node already exists remove before
adding
ProgramElementNode duplicate = null;
+
boolean foundNullSL = false;
for (Iterator itt = StructureModelManager.INSTANCE.getStructureModel().getRoot().getChildren().iterator();
itt.hasNext(); ) {
ProgramElementNode
child = (ProgramElementNode)itt.next();
-
if
(child.getSourceLocation().getSourceFile().equals(file)) {
-
duplicate = child;
-
}
+
ISourceLocation
isl = child.getSourceLocation();
+
if
(isl==null) {
+
foundNullSL = true;
+
+
}
else {
+
if (child.getSourceLocation().getSourceFile().equals(file))
{
+
duplicate
= child;
+
}
+
}
+
}
+
if (foundNullSL) {
+
System.err.println("WARNING:
AsmBuilder.internalBuild(2): Node "+
+
StructureModelManager.INSTANCE.getStructureModel().getRoot()+
+
" has at least one child whose getSourceLocation() returns null");
}
if (duplicate != null) {
StructureModelManager.INSTANCE.getStructureModel().getRoot().removeChild(duplicate);
----------8<-------8<--------8<-----------SnipHere----------