Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-dev] Compiler monitor messages

Hi Andy,

 

If you’re only seeing this for nodes that are in “.lst” files your guard should be OK.  Nothing that I know of relies on those nodes have proper source locations since the “.lst” files get written out in one go during a save.

 

In “.java” and “.aj” nodes the getSourceLocation() should never return null.  If you ever spot that we should figure out why it is not being set.

 

Mik

 

--

http://kerstens.org/mik

 


From: aspectj-dev-admin@xxxxxxxxxxx [mailto:aspectj-dev-admin@xxxxxxxxxxx] On Behalf Of Andrew Clement
Sent: Friday, May 02, 2003 3:17 AM
To: aspectj-dev@xxxxxxxxxxx

 


Thanks Jim - those messages are just what I needed :)

AJDT is looking much healthier.  *BUT* I still get a problem with one of Miks
changes to AsmBuilder.java. I've attached the eclipse patch below, but
basically I get an NPE on this line:



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----------


Back to the top