]> source.dussan.org Git - aspectj.git/commitdiff
annoValMatch: implementation
authoraclement <aclement>
Mon, 25 Feb 2008 21:44:07 +0000 (21:44 +0000)
committeraclement <aclement>
Mon, 25 Feb 2008 21:44:07 +0000 (21:44 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java

index 1e7a36e355dba25886536505cb8dc66fb3cf50ab..98d75b42af4374257697113f29a00fddc850bd76 100644 (file)
@@ -13,8 +13,11 @@ package org.aspectj.ajdt.internal.compiler.lookup;
 
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
@@ -72,6 +75,31 @@ public class EclipseResolvedMember extends ResolvedMemberImpl {
                throw new RuntimeException("not yet implemented - please raise an AJ bug");
 //             return super.getAnnotations();
        }
+       
+       public String getAnnotationDefaultValue() {
+               if (realBinding instanceof MethodBinding) {
+                       AbstractMethodDeclaration methodDecl = getTypeDeclaration().declarationOf((MethodBinding)realBinding);
+                       if (methodDecl instanceof AnnotationMethodDeclaration) {
+                               AnnotationMethodDeclaration annoMethodDecl = (AnnotationMethodDeclaration)methodDecl;
+                               Expression e = annoMethodDecl.defaultValue;
+                               if (e.resolvedType==null)
+                               e.resolve(methodDecl.scope);
+                               // TODO does not cope with many cases...
+                               if (e instanceof QualifiedNameReference) {
+                                       
+                                       QualifiedNameReference qnr = (QualifiedNameReference)e;
+                                       if (qnr.binding instanceof FieldBinding) {
+                                               FieldBinding fb = (FieldBinding)qnr.binding;
+                                               StringBuffer sb = new StringBuffer();
+                                               sb.append(fb.declaringClass.signature());
+                                               sb.append(fb.name);
+                                               return sb.toString();
+                                       }
+                               }
+                       }
+               }
+               return null;
+       }
 
        public ResolvedType[] getAnnotationTypes() {
                if (cachedAnnotationTypes == null) {