]> source.dussan.org Git - aspectj.git/commitdiff
229829: fix for sourceStart() NPE
authoraclement <aclement>
Tue, 29 Jul 2008 16:55:49 +0000 (16:55 +0000)
committeraclement <aclement>
Tue, 29 Jul 2008 16:55:49 +0000 (16:55 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java

index ced21bd9ccbf578424946cdf21b94be6e8115ee2..7fd1d9ba0b36123e618e0ba11dcdf0daa1841d50 100644 (file)
@@ -253,8 +253,20 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
                                        if (amd.binding == null || !amd.binding.isValidBinding()) continue;
                                        ResolvedMember member = factory.makeResolvedMember(amd.binding);
                                        if (unit != null) {
-                                               member.setSourceContext(new EclipseSourceContext(unit.compilationResult,amd.binding.sourceStart()));
-                                               member.setPosition(amd.binding.sourceStart(),amd.binding.sourceEnd());
+                                               boolean positionKnown = true;
+                                               if (amd.binding.sourceMethod() == null) {
+                                                       if (amd.binding.declaringClass instanceof SourceTypeBinding) {
+                                                               SourceTypeBinding stb = ((SourceTypeBinding) amd.binding.declaringClass);
+                                                               if (stb.scope==null || stb.scope.referenceContext==null) positionKnown = false;
+                                                       }
+                                               }
+                                               if (positionKnown) { // pr229829
+                                                       member.setSourceContext(new EclipseSourceContext(unit.compilationResult,amd.binding.sourceStart()));
+                                                       member.setPosition(amd.binding.sourceStart(),amd.binding.sourceEnd());
+                                               } else {
+                                                       member.setSourceContext(new EclipseSourceContext(unit.compilationResult,0));
+                                                       member.setPosition(0,0);
+                                               }
                                        }
                                        declaredMethods.add(member);
                                }