]> source.dussan.org Git - aspectj.git/commitdiff
238992: test and fix
authoraclement <aclement>
Mon, 7 Jul 2008 22:32:43 +0000 (22:32 +0000)
committeraclement <aclement>
Mon, 7 Jul 2008 22:32:43 +0000 (22:32 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java

index dac05522c695ff2d721b0aeb7a80c420ef75ed34..2a28a8535426fa490d7522ce3ef6aa8219177731 100644 (file)
@@ -138,7 +138,7 @@ public class EclipseAnnotationConvertor {
                }
        }
        
-       private static AnnotationValue generateElementValueForConstantExpression(Expression defaultValue, TypeBinding defaultValueBinding) {
+       public static AnnotationValue generateElementValueForConstantExpression(Expression defaultValue, TypeBinding defaultValueBinding) {
                if (defaultValueBinding != null) {
                        Constant c = defaultValue.constant;
                        if (c instanceof IntConstant) {
index c0eaaf4a5f36a95915dde0991df7230e7194b0dc..0f885579cda8dd225be25e9a263c8ecb9c99cc60 100644 (file)
@@ -16,14 +16,19 @@ 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.FalseLiteral;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.IntLiteral;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
+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.FieldBinding;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
 import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
 import org.aspectj.weaver.AnnotationX;
+import org.aspectj.weaver.BCException;
 import org.aspectj.weaver.MemberKind;
 import org.aspectj.weaver.ResolvedMemberImpl;
 import org.aspectj.weaver.ResolvedType;
@@ -114,6 +119,14 @@ public class EclipseResolvedMember extends ResolvedMemberImpl {
                                                sb.append(fb.name);
                                                return sb.toString();
                                        }
+                               } else if (e instanceof TrueLiteral) {
+                                       return "true";
+                               } else if (e instanceof FalseLiteral) {
+                                       return "false";
+                               } else if (e instanceof IntLiteral) {
+                                       return Integer.toString(((IntConstant)e.constant).intValue());
+                               } else {
+                                       throw new BCException("EclipseResolvedMember.getAnnotationDefaultValue() not implemented for value of type '"+e.getClass()+"' - raise an AspectJ bug !");
                                }
                        }
                }
index d2d3cdcb018d565cb27716e87b98d619d35eb7b9..ced21bd9ccbf578424946cdf21b94be6e8115ee2 100644 (file)
@@ -35,6 +35,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MemberValuePair;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.NameReference;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.NormalAnnotation;
@@ -161,7 +162,7 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
             }
         }
         return false;
-    }
+    } 
     
     /** Returns "" if there is a problem */
     private String getPointcutStringFromAnnotationStylePointcut(AbstractMethodDeclaration amd) {
@@ -631,8 +632,10 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
                                annotationAJ.addNameValuePair(
                                                new AnnotationNameValuePair(new String(singleMemberAnnotation.memberValuePairs()[0].name),av));
                        }
+               } else if (annotation instanceof MarkerAnnotation) {
+                       return;
                } else {
-                       // this is a marker annotation (no member value pairs)
+                       // this is something else...
                        throw new MissingImplementationException(
                                    "Please raise an AspectJ bug.  AspectJ does not know how to convert this annotation ["+annotation+"]");
                }
@@ -656,8 +659,12 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
                                }
                        } else {
                                if (constant != null && constant != Constant.NotAConstant) {
-                                       throw new MissingImplementationException(
-                                                   "Please raise an AspectJ bug.  AspectJ does not know how to convert this annotation value ["+defaultValue+"]");
+                                       AnnotationValue av = EclipseAnnotationConvertor.generateElementValueForConstantExpression(defaultValue,defaultValueBinding);
+                                       if (av==null) {
+                                               throw new MissingImplementationException(
+                                                               "Please raise an AspectJ bug.  AspectJ does not know how to convert this annotation value ["+defaultValue+"]");                                         
+                                       }
+                                       return av;
 //                                     generateElementValue(attributeOffset, defaultValue, constant, memberValuePairReturnType.leafComponentType());
                                } else {
                                        AnnotationValue av = generateElementValueForNonConstantExpression(defaultValue, defaultValueBinding);
@@ -708,6 +715,15 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
                                        throw new MissingImplementationException(
                                                    "Please raise an AspectJ bug.  AspectJ does not know how to convert this annotation value ["+defaultValue+"]");
                                }
+//                     } else if (defaultValue instanceof MagicLiteral) {
+//                             if (defaultValue instanceof FalseLiteral) {
+//                                     new AnnotationValue
+//                             } else if (defaultValue instanceof TrueLiteral) {
+//                                     
+//                             } else {                                        
+//                                     throw new MissingImplementationException(
+//                                                 "Please raise an AspectJ bug.  AspectJ does not know how to convert this annotation value ["+defaultValue+"]");
+//                             }
                        } else {
                                // class type
                                throw new MissingImplementationException(