]> source.dussan.org Git - aspectj.git/commitdiff
avoid messy exception on cascading failure
authoraclement <aclement>
Wed, 20 Aug 2008 17:39:37 +0000 (17:39 +0000)
committeraclement <aclement>
Wed, 20 Aug 2008 17:39:37 +0000 (17:39 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java

index 107feb098f3ac78cc689c8a99b51b83e54f18a4b..1f4cfb46cc268e34e53509805205f5ceed6e4c25 100644 (file)
@@ -25,6 +25,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TrueLiteral;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
 import org.aspectj.org.eclipse.jdt.internal.compiler.impl.IntConstant;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
@@ -161,7 +162,7 @@ public class EclipseResolvedMember extends ResolvedMemberImpl {
                        argumentNames=NO_ARGS;
                } else {
                        TypeDeclaration typeDecl = getTypeDeclaration();
-                       AbstractMethodDeclaration methodDecl = typeDecl.declarationOf((MethodBinding)realBinding);
+                       AbstractMethodDeclaration methodDecl =(typeDecl==null?null:typeDecl.declarationOf((MethodBinding)realBinding));
                        Argument[] args = (methodDecl==null?null:methodDecl.arguments); // dont like this - why isnt the method found sometimes? is it because other errors are being reported?
                        if (args==null) {
                                argumentNames=NO_ARGS;
@@ -188,10 +189,23 @@ public class EclipseResolvedMember extends ResolvedMemberImpl {
 
        private TypeDeclaration getTypeDeclaration() {
                if (realBinding instanceof MethodBinding) {
-                       return ((SourceTypeBinding)((MethodBinding)realBinding).declaringClass).scope.referenceContext;
-                       
+                       MethodBinding mb = (MethodBinding)realBinding;
+                       if (mb!=null) {
+                               SourceTypeBinding stb = (SourceTypeBinding)mb.declaringClass;
+                               if (stb!=null) {
+                                       ClassScope cScope = stb.scope;
+                                       if (cScope!=null) return cScope.referenceContext;
+                               }
+                       }                       
                } else if (realBinding instanceof FieldBinding) {
-                       return ((SourceTypeBinding)((FieldBinding)realBinding).declaringClass).scope.referenceContext;
+                       FieldBinding fb = (FieldBinding)realBinding;
+                       if (fb!=null) {
+                               SourceTypeBinding stb = (SourceTypeBinding)fb.declaringClass;
+                               if (stb!=null) {
+                                       ClassScope cScope = stb.scope;
+                                       if (cScope!=null) return cScope.referenceContext;
+                               }
+                       }
                }
                return null;
        }