]> source.dussan.org Git - aspectj.git/commitdiff
updated test cases to reflect new parsing
authoracolyer <acolyer>
Wed, 8 Dec 2004 12:46:09 +0000 (12:46 +0000)
committeracolyer <acolyer>
Wed, 8 Dec 2004 12:46:09 +0000 (12:46 +0000)
13 files changed:
weaver/src/org/aspectj/weaver/patterns/AndAnnotationTypePattern.java
weaver/src/org/aspectj/weaver/patterns/AndTypePattern.java
weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java
weaver/src/org/aspectj/weaver/patterns/ExactTypePattern.java
weaver/src/org/aspectj/weaver/patterns/NotAnnotationTypePattern.java
weaver/src/org/aspectj/weaver/patterns/NotTypePattern.java
weaver/src/org/aspectj/weaver/patterns/OrTypePattern.java
weaver/src/org/aspectj/weaver/patterns/PatternParser.java
weaver/src/org/aspectj/weaver/patterns/SignaturePattern.java
weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java
weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java
weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java

index c6679a98085b12858a31874409f8356f27ebf97b..af9511b1a532e0afcf938ef66f58082e27b3d608 100644 (file)
@@ -77,7 +77,7 @@ public class AndAnnotationTypePattern extends AnnotationTypePattern {
        }
        
        public String toString() {
-               return "(" + left.toString() + " && " + right.toString() + ")";
+               return left.toString() + " " + right.toString();
        }
        
        public AnnotationTypePattern getLeft() { return left; }
index 0752746fcd8115fe5732e13ed075a3e46f73d1c7..15b70540720f3ad7ad9dc9bf86f94679d0e89e57 100644 (file)
@@ -100,9 +100,6 @@ public class AndTypePattern extends TypePattern {
                StringBuffer buff = new StringBuffer();
                if (annotationPattern != AnnotationTypePattern.ANY) {
                        buff.append('(');
-                       if (! (annotationPattern instanceof ExactAnnotationTypePattern )) {
-                               buff.append('@');
-                       }
                        buff.append(annotationPattern.toString());
                        buff.append(' ');
                }
index 8d7bc8d5a28a25456623f9d2cf05b1704663a53d..8017ec7575f46a2769e7e355612ec0f074db8e08 100644 (file)
@@ -76,7 +76,7 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern {
                                                "name binding only allowed in @pcds, args, this, and target");
                                        return this;
                                }
-                               
+                               verifyIsAnnotationType(formalBinding.getType(),scope);
                                BindingAnnotationTypePattern binding = new BindingAnnotationTypePattern(formalBinding);
                                binding.copyLocationFrom(this);
                                bindings.register(binding, scope);
@@ -89,17 +89,24 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern {
                        }
                } else {
                        annotationType = annotationType.resolve(scope.getWorld());
-                       if (!annotationType.isAnnotation(scope.getWorld())) {
-                               IMessage m = MessageUtil.error(
-                                               WeaverMessages.format(WeaverMessages.REFERENCE_TO_NON_ANNOTATION_TYPE,annotationType.getName()),
-                                               getSourceLocation());
-                               scope.getWorld().getMessageHandler().handleMessage(m);
-                               resolved = false;
-                       }
+                       verifyIsAnnotationType(annotationType,scope);
                        return this;
                }
        }
        
+       /**
+        * @param scope
+        */
+       private void verifyIsAnnotationType(TypeX type,IScope scope) {
+               if (!type.isAnnotation(scope.getWorld())) {
+                       IMessage m = MessageUtil.error(
+                                       WeaverMessages.format(WeaverMessages.REFERENCE_TO_NON_ANNOTATION_TYPE,type.getName()),
+                                       getSourceLocation());
+                       scope.getWorld().getMessageHandler().handleMessage(m);
+                       resolved = false;
+               }
+       }
+
        private static byte VERSION = 1; // rev if serialisation form changes
        /* (non-Javadoc)
         * @see org.aspectj.weaver.patterns.PatternNode#write(java.io.DataOutputStream)
index 755e025e27204230e93a51be6d8a3c91162486d7..6da79c77928700611598446ffcacf894fc086d0c 100644 (file)
@@ -185,9 +185,6 @@ public class ExactTypePattern extends TypePattern {
                StringBuffer buff = new StringBuffer();
                if (annotationPattern != AnnotationTypePattern.ANY) {
                        buff.append('(');
-                       if (! (annotationPattern instanceof ExactAnnotationTypePattern )) {
-                               buff.append('@');
-                       }
                        buff.append(annotationPattern.toString());
                        buff.append(' ');
                }
index d7869d90a56a32bd97b18b64ffdc89e6dd1b02e9..8e3679e537a64bc77918b56cd7aed5446b3ed109 100644 (file)
@@ -69,7 +69,7 @@ public class NotAnnotationTypePattern extends AnnotationTypePattern {
        }
        
        public String toString() {
-               return "(!" + negatedPattern.toString() + ")";
+               return "!" + negatedPattern.toString();
        }
        
        public AnnotationTypePattern getNegatedPattern() {
index 02adeadd8f711c51522609a61da0960d72f9a68b..cbe48e03b48485d131573832d9fe29fb1ea14baf 100644 (file)
@@ -95,9 +95,6 @@ public class NotTypePattern extends TypePattern {
                StringBuffer buff = new StringBuffer();
                if (annotationPattern != AnnotationTypePattern.ANY) {
                        buff.append('(');
-                       if (! (annotationPattern instanceof ExactAnnotationTypePattern )) {
-                               buff.append('@');
-                       }
                        buff.append(annotationPattern.toString());
                        buff.append(' ');
                }
index 6d8689eb1da16993282c317d15b0f683457dc700..37fa7767aeb4ba092ae29396e2a5b89e4fec4494 100644 (file)
@@ -100,9 +100,6 @@ public class OrTypePattern extends TypePattern {
                StringBuffer buff = new StringBuffer();
                if (annotationPattern != AnnotationTypePattern.ANY) {
                        buff.append('(');
-                       if (! (annotationPattern instanceof ExactAnnotationTypePattern )) {
-                               buff.append('@');
-                       }
                        buff.append(annotationPattern.toString());
                        buff.append(' ');
                }
index a91a44b6f49afecfabaad8284ea27e6f6042df34..0cb850d3e809568f6d48b42789d51e65dc7f872b 100644 (file)
@@ -504,40 +504,38 @@ public class PatternParser {
                        //int startPos = tokenSource.peek(-1).getStart();
                        //??? we lose source location for true start of !type
                        TypePattern p = new NotTypePattern(parseAtomicTypePattern());
+                       p = setAnnotationPatternForTypePattern(p,ap);
                        return p;                       
                }
                if (maybeEat("(")) {
                        TypePattern p = parseTypePattern();
+                       p = setAnnotationPatternForTypePattern(p,ap);
                        eat(")");
                        return p;
                }
-//             if (maybeEat("@")) {
-//                     AnnotationTypePattern ap = null;
-//                     if (maybeEat("(")) {
-//                             ap = parseAnnotationTypePattern();
-//                             eat(")");
-//                     } else {
-//                             ap = parseSimpleAnnotationName();
-//                     }
-//                     int startPos = tokenSource.peek().getStart();
-//                 TypePattern p = parseAtomicTypePattern();
-//                 int endPos = tokenSource.peek(-1).getEnd();
-//                 p.setLocation(sourceContext, startPos, endPos);
-//                 if (ap != null) {
-//                     if (p == TypePattern.ANY) {
-//                             p = new WildTypePattern(new NamePattern[] {NamePattern.ANY},false,0);
-//                     }       
-//                     p.setAnnotationTypePattern(ap);         
-//                 }
-//                 return p;
-//             }
                int startPos = tokenSource.peek().getStart();
            TypePattern p = parseSingleTypePattern();
            int endPos = tokenSource.peek(-1).getEnd();
+           p = setAnnotationPatternForTypePattern(p,ap);
            p.setLocation(sourceContext, startPos, endPos);
            return p;
        }
        
+       private TypePattern setAnnotationPatternForTypePattern(TypePattern t, AnnotationTypePattern ap) {
+               TypePattern ret = t;
+               if (ap != AnnotationTypePattern.ANY) {
+                       if (t == TypePattern.ANY) {
+                               ret = new WildTypePattern(new NamePattern[] {NamePattern.ANY},false,0,false);
+                       }
+                       if (t.annotationPattern == AnnotationTypePattern.ANY) {
+                               ret.setAnnotationTypePattern(ap);                               
+                       } else {
+                               ret.setAnnotationTypePattern(new AndAnnotationTypePattern(ap,t.annotationPattern)); //???
+                       }
+               }
+               return ret;
+       }
+       
        public AnnotationTypePattern maybeParseAnnotationPattern() {
                AnnotationTypePattern ret = AnnotationTypePattern.ANY;
                AnnotationTypePattern nextPattern = null;
@@ -560,6 +558,7 @@ public class PatternParser {
                                if (maybeEat("(")) {
                                        TypePattern p = parseTypePattern();
                                        ret = new NotAnnotationTypePattern(new WildAnnotationTypePattern(p));
+                                       eat(")");
                                        return ret;
                                } else {
                                        TypePattern p = parseSingleTypePattern();
@@ -575,6 +574,7 @@ public class PatternParser {
                        if (maybeEat("(")) {
                                TypePattern p = parseTypePattern();
                                ret = new WildAnnotationTypePattern(p);
+                               eat(")");
                                return ret;
                        } else {
                                TypePattern p = parseSingleTypePattern();
@@ -617,35 +617,35 @@ public class PatternParser {
        
 
        
-       private AnnotationTypePattern completeAnnotationPattern(AnnotationTypePattern p) {
-               if (maybeEat("&&")) {
-                       return new AndAnnotationTypePattern(p,parseNotOrAnnotationPattern());
-               }
-               if (maybeEat("||")) {
-                       return new OrAnnotationTypePattern(p,parseAnnotationTypePattern());
-               }
-               return p;
-       }
-
-       protected AnnotationTypePattern parseAnnotationTypePattern() {
-               AnnotationTypePattern ap = parseAtomicAnnotationPattern();
-               if (maybeEat("&&")) {
-                       ap = new AndAnnotationTypePattern(ap, parseNotOrAnnotationPattern());
-               }  
-               
-               if (maybeEat("||")) {
-                       ap = new OrAnnotationTypePattern(ap, parseAnnotationTypePattern());
-               }               
-               return ap;
-       }
-
-       private AnnotationTypePattern parseNotOrAnnotationPattern() {
-               AnnotationTypePattern p = parseAtomicAnnotationPattern();
-               if (maybeEat("&&")) {
-                       p = new AndAnnotationTypePattern(p,parseAnnotationTypePattern());
-               }
-               return p;
-       }
+//     private AnnotationTypePattern completeAnnotationPattern(AnnotationTypePattern p) {
+//             if (maybeEat("&&")) {
+//                     return new AndAnnotationTypePattern(p,parseNotOrAnnotationPattern());
+//             }
+//             if (maybeEat("||")) {
+//                     return new OrAnnotationTypePattern(p,parseAnnotationTypePattern());
+//             }
+//             return p;
+//     }
+//
+//     protected AnnotationTypePattern parseAnnotationTypePattern() {
+//             AnnotationTypePattern ap = parseAtomicAnnotationPattern();
+//             if (maybeEat("&&")) {
+//                     ap = new AndAnnotationTypePattern(ap, parseNotOrAnnotationPattern());
+//             }  
+//             
+//             if (maybeEat("||")) {
+//                     ap = new OrAnnotationTypePattern(ap, parseAnnotationTypePattern());
+//             }               
+//             return ap;
+//     }
+//
+//     private AnnotationTypePattern parseNotOrAnnotationPattern() {
+//             AnnotationTypePattern p = parseAtomicAnnotationPattern();
+//             if (maybeEat("&&")) {
+//                     p = new AndAnnotationTypePattern(p,parseAnnotationTypePattern());
+//             }
+//             return p;
+//     }
        
        
        protected AnnotationTypePattern parseAnnotationNameOrVarTypePattern() {
@@ -680,32 +680,32 @@ public class PatternParser {
                return p;
        }
 
-       private AnnotationTypePattern parseAtomicAnnotationPattern() {
-               if (maybeEat("!")) {
-                       //int startPos = tokenSource.peek(-1).getStart();
-                       //??? we lose source location for true start of !type
-                       AnnotationTypePattern p = new NotAnnotationTypePattern(parseAtomicAnnotationPattern());
-                       return p;                       
-               }
-               if (maybeEat("(")) {
-                       AnnotationTypePattern p = parseAnnotationTypePattern();
-                       eat(")");
-                       return p;
-               }
-               int startPos = tokenSource.peek().getStart();
-               eat("@");
-               StringBuffer annotationName = new StringBuffer();
-               annotationName.append(parseIdentifier());
-               while (maybeEat(".")) {
-                       annotationName.append('.');
-                       annotationName.append(parseIdentifier());
-               }
-               TypeX type = TypeX.forName(annotationName.toString());
-               AnnotationTypePattern p = new ExactAnnotationTypePattern(type);
-           int endPos = tokenSource.peek(-1).getEnd();
-           p.setLocation(sourceContext, startPos, endPos);
-           return p;           
-       }
+//     private AnnotationTypePattern parseAtomicAnnotationPattern() {
+//             if (maybeEat("!")) {
+//                     //int startPos = tokenSource.peek(-1).getStart();
+//                     //??? we lose source location for true start of !type
+//                     AnnotationTypePattern p = new NotAnnotationTypePattern(parseAtomicAnnotationPattern());
+//                     return p;                       
+//             }
+//             if (maybeEat("(")) {
+//                     AnnotationTypePattern p = parseAnnotationTypePattern();
+//                     eat(")");
+//                     return p;
+//             }
+//             int startPos = tokenSource.peek().getStart();
+//             eat("@");
+//             StringBuffer annotationName = new StringBuffer();
+//             annotationName.append(parseIdentifier());
+//             while (maybeEat(".")) {
+//                     annotationName.append('.');
+//                     annotationName.append(parseIdentifier());
+//             }
+//             TypeX type = TypeX.forName(annotationName.toString());
+//             AnnotationTypePattern p = new ExactAnnotationTypePattern(type);
+//         int endPos = tokenSource.peek(-1).getEnd();
+//         p.setLocation(sourceContext, startPos, endPos);
+//         return p;           
+//     }
        
 
        private boolean isAnnotationPattern(PatternNode p) {
index d1cb4fee89956759ed9cd36bf795eda80f2432a8..31cf6545a659cff5290f3e509e2b478aba580fef 100644 (file)
@@ -436,9 +436,6 @@ public class SignaturePattern extends PatternNode {
        StringBuffer buf = new StringBuffer();
        
        if (annotationPattern != AnnotationTypePattern.ANY) {
-                       if (! (annotationPattern instanceof ExactAnnotationTypePattern )) {
-                               buf.append('@');
-                       }
                        buf.append(annotationPattern.toString());
                        buf.append(' ');
        }
index f76a4e65febff97480fbf054b328e9ee4bbf1fca..145915e195ab681a0d8ea5cd3fbebb245a001952 100644 (file)
@@ -13,12 +13,14 @@ import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
 
+import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.MessageUtil;
 import org.aspectj.util.FuzzyBoolean;
 import org.aspectj.weaver.AnnotatedElement;
 import org.aspectj.weaver.BCException;
 import org.aspectj.weaver.ISourceContext;
 import org.aspectj.weaver.ResolvedTypeX;
-import org.aspectj.weaver.TypeX;
+import org.aspectj.weaver.WeaverMessages;
 
 /**
  * @author colyer
@@ -29,6 +31,7 @@ import org.aspectj.weaver.TypeX;
 public class WildAnnotationTypePattern extends AnnotationTypePattern {
 
        private TypePattern typePattern;
+       private boolean resolved = false;
        
        /**
         * 
@@ -43,6 +46,9 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
         * @see org.aspectj.weaver.patterns.AnnotationTypePattern#matches(org.aspectj.weaver.AnnotatedElement)
         */
        public FuzzyBoolean matches(AnnotatedElement annotated) {
+               if (!resolved) {
+                       throw new IllegalStateException("Can't match on an unresolved annotation type pattern");
+               }
                // matches if the type of any of the annotations on the AnnotatedElement is
                // matched by the typePattern.
                ResolvedTypeX[] annTypes = annotated.getAnnotationTypes();
@@ -61,8 +67,16 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
                                                                             boolean allowBinding)
     { 
        this.typePattern = typePattern.resolveBindings(scope,bindings,false,false);
+       resolved = true;
        if (typePattern instanceof ExactTypePattern) {
                ExactTypePattern et = (ExactTypePattern)typePattern;
+                       if (!et.getExactType().isAnnotation(scope.getWorld())) {
+                               IMessage m = MessageUtil.error(
+                                               WeaverMessages.format(WeaverMessages.REFERENCE_TO_NON_ANNOTATION_TYPE,et.getExactType().getName()),
+                                               getSourceLocation());
+                               scope.getWorld().getMessageHandler().handleMessage(m);
+                               resolved = false;
+                       }
                return new ExactAnnotationTypePattern(et.getExactType());
        } else {
                return this;
@@ -91,5 +105,27 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
                ret.readLocation(context,s);
                return ret;             
        }
+
+       /* (non-Javadoc)
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       public boolean equals(Object obj) {
+               if (!(obj instanceof WildAnnotationTypePattern)) return false;
+               WildAnnotationTypePattern other = (WildAnnotationTypePattern) obj;
+               return other.typePattern.equals(typePattern);
+       }
        
+       /* (non-Javadoc)
+        * @see java.lang.Object#hashCode()
+        */
+       public int hashCode() {
+               return 17 + 37*typePattern.hashCode();
+       }
+       
+       /* (non-Javadoc)
+        * @see java.lang.Object#toString()
+        */
+       public String toString() {
+               return "@(" + typePattern.toString() + ")";
+       }
 }
index 2cef3745c9c7f15191d12cdc4fdbabfb694b66cf..2be4c38b1118218bc8a19f81aa02d7d11dd14e00 100644 (file)
@@ -507,6 +507,7 @@ public class WildTypePattern extends TypePattern {
     public String toString() {
        StringBuffer buf = new StringBuffer();
        if (annotationPattern != AnnotationTypePattern.ANY) {
+               buf.append('(');
                buf.append(annotationPattern.toString());
                buf.append(' ');
        }
@@ -519,6 +520,9 @@ public class WildTypePattern extends TypePattern {
                        buf.append(name.toString());
                }
        }
+       if (annotationPattern != AnnotationTypePattern.ANY) {
+               buf.append(')');
+       }
        return buf.toString();
     }
     
index 8d6462b75ef4c06e9c7224b5a4cbeeba766aee78..e525f857850cb746c469ff2d21670f6ce194b349 100644 (file)
@@ -71,11 +71,11 @@ public class AnnotationPatternMatchingTestCase extends TestCase {
        
        private void initAnnotationTypePatterns() {
                PatternParser p = new PatternParser("@Foo");
-               fooTP = p.parseAnnotationTypePattern();
+               fooTP = p.maybeParseAnnotationPattern();
                fooTP = fooTP.resolveBindings(makeSimpleScope(),new Bindings(3),true);
                
                p = new PatternParser("@p.SimpleAnnotation");
-               simpleAnnotationTP = p.parseAnnotationTypePattern();
+               simpleAnnotationTP = p.maybeParseAnnotationPattern();
                simpleAnnotationTP = simpleAnnotationTP.resolveBindings(makeSimpleScope(),new Bindings(3),true);
        }
        
@@ -108,7 +108,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase {
                
                MyMessageHandler mh = new MyMessageHandler();
                world.setMessageHandler(mh);
-               AnnotationTypePattern atp = p.parseAnnotationTypePattern();
+               AnnotationTypePattern atp = p.maybeParseAnnotationPattern();
                atp = atp.resolveBindings(makeSimpleScope(),new Bindings(3),true);
                
                assertTrue("Expected 1 error message but got "+mh.messages.size(),mh.messages.size()==1);
@@ -142,7 +142,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase {
                ResolvedTypeX rtx = loadType("AnnotatedClass");
 
                PatternParser p = new PatternParser("@Foo");
-               AnnotationTypePattern fooTP = p.parseAnnotationTypePattern();
+               AnnotationTypePattern fooTP = p.maybeParseAnnotationPattern();
                try {
                        fooTP.matches(rtx);
                        fail("Should have failed with illegal state exception, fooTP is not resolved");
index 0ddbc34e2eda93f21bf000c06baea5b1c050a020..52b6b98a68b7564fd01ee7c8aa41013b39f03dd5 100644 (file)
@@ -21,94 +21,93 @@ public class AnnotationPatternTestCase extends TestCase {
 
        public void testParseSimpleAnnotationPattern() {
                PatternParser p = new PatternParser("@Foo");
-               AnnotationTypePattern foo = p.parseAnnotationTypePattern();
+               AnnotationTypePattern foo = p.maybeParseAnnotationPattern();
+               foo = foo.resolveBindings(makeSimpleScope(),new Bindings(3),true);
                assertTrue("ExactAnnotationTypePattern",foo instanceof ExactAnnotationTypePattern);
                assertEquals("Foo",TypeX.forName("Foo"),((ExactAnnotationTypePattern)foo).annotationType);
        }
        
        public void testParseAndAnnotationPattern() {
-               PatternParser p = new PatternParser("@Foo && @Goo");
-               AnnotationTypePattern fooAndGoo = p.parseAnnotationTypePattern();
+               PatternParser p = new PatternParser("@Foo @Goo");
+               AnnotationTypePattern fooAndGoo = p.maybeParseAnnotationPattern();
                assertTrue("AndAnnotationTypePattern",fooAndGoo instanceof AndAnnotationTypePattern);
-               assertEquals("(@Foo && @Goo)",fooAndGoo.toString());
+               assertEquals("@(Foo) @(Goo)",fooAndGoo.toString());
+               fooAndGoo = fooAndGoo.resolveBindings(makeSimpleScope(),new Bindings(3),true);
+               assertEquals("@Foo @Goo",fooAndGoo.toString());
                AnnotationTypePattern left = ((AndAnnotationTypePattern)fooAndGoo).getLeft();
                AnnotationTypePattern right = ((AndAnnotationTypePattern)fooAndGoo).getRight();
                assertEquals("Foo",TypeX.forName("Foo"),((ExactAnnotationTypePattern)left).annotationType);
                assertEquals("Goo",TypeX.forName("Goo"),((ExactAnnotationTypePattern)right).annotationType);            
        }
-
-       public void testParseOrAnnotationPattern() {
-               PatternParser p = new PatternParser("@Foo || @Goo");
-               AnnotationTypePattern fooOrGoo = p.parseAnnotationTypePattern();
-               assertTrue("OrAnnotationTypePattern",fooOrGoo instanceof OrAnnotationTypePattern);
-               assertEquals("(@Foo || @Goo)",fooOrGoo.toString());
-               AnnotationTypePattern left = ((OrAnnotationTypePattern)fooOrGoo).getLeft();
-               AnnotationTypePattern right = ((OrAnnotationTypePattern)fooOrGoo).getRight();
-               assertEquals("Foo",TypeX.forName("Foo"),((ExactAnnotationTypePattern)left).annotationType);
-               assertEquals("Goo",TypeX.forName("Goo"),((ExactAnnotationTypePattern)right).annotationType);            
-       }
-       
+//
+//     public void testParseOrAnnotationPattern() {
+//             PatternParser p = new PatternParser("@Foo || @Goo");
+//             AnnotationTypePattern fooOrGoo = p.parseAnnotationTypePattern();
+//             assertTrue("OrAnnotationTypePattern",fooOrGoo instanceof OrAnnotationTypePattern);
+//             assertEquals("(@Foo || @Goo)",fooOrGoo.toString());
+//             AnnotationTypePattern left = ((OrAnnotationTypePattern)fooOrGoo).getLeft();
+//             AnnotationTypePattern right = ((OrAnnotationTypePattern)fooOrGoo).getRight();
+//             assertEquals("Foo",TypeX.forName("Foo"),((ExactAnnotationTypePattern)left).annotationType);
+//             assertEquals("Goo",TypeX.forName("Goo"),((ExactAnnotationTypePattern)right).annotationType);            
+//     }
+//     
        public void testParseNotAnnotationPattern() {
                PatternParser p = new PatternParser("!@Foo");
-               AnnotationTypePattern notFoo = p.parseAnnotationTypePattern();
+               AnnotationTypePattern notFoo = p.maybeParseAnnotationPattern();
                assertTrue("NotAnnotationTypePattern",notFoo instanceof NotAnnotationTypePattern);
-               assertEquals("(!@Foo)",notFoo.toString());
+               notFoo = notFoo.resolveBindings(makeSimpleScope(),new Bindings(3),true);
+               assertEquals("!@Foo",notFoo.toString());
                AnnotationTypePattern body = ((NotAnnotationTypePattern)notFoo).getNegatedPattern();
                assertEquals("Foo",TypeX.forName("Foo"),((ExactAnnotationTypePattern)body).annotationType);
        }
 
        public void testParseBracketedAnnotationPattern() {
                PatternParser p = new PatternParser("(@Foo)");
-               AnnotationTypePattern foo = p.parseAnnotationTypePattern();
-               assertTrue("ExactAnnotationTypePattern",foo instanceof ExactAnnotationTypePattern);
-               assertEquals("Foo",TypeX.forName("Foo"),((ExactAnnotationTypePattern)foo).annotationType);              
+               AnnotationTypePattern foo = p.maybeParseAnnotationPattern();
+               // cannot start with ( so, we get ANY
+               assertEquals("ANY",AnnotationTypePattern.ANY,foo);
        }
        
        public void testParseFQAnnPattern() {
                PatternParser p = new PatternParser("@org.aspectj.Foo");
-               AnnotationTypePattern foo = p.parseAnnotationTypePattern();
-               assertTrue("ExactAnnotationTypePattern",foo instanceof ExactAnnotationTypePattern);
-               assertEquals("org.aspectj.Foo",TypeX.forName("org.aspectj.Foo"),((ExactAnnotationTypePattern)foo).annotationType);                              
+               AnnotationTypePattern foo = p.maybeParseAnnotationPattern();
+               assertEquals("@(org.aspectj.Foo)",foo.toString());
        }
        
        public void testParseComboPattern() {
-               PatternParser p = new PatternParser("!((@Foo || @Goo) && !@Boo)");
-               AnnotationTypePattern ap = p.parseAnnotationTypePattern();
-               NotAnnotationTypePattern ntp = (NotAnnotationTypePattern) ap;
-               AndAnnotationTypePattern atp = (AndAnnotationTypePattern) ntp.getNegatedPattern();
+//             PatternParser p = new PatternParser("!((@Foo || @Goo) && !@Boo)");
+               PatternParser p = new PatternParser("@(Foo || Goo)!@Boo");
+               AnnotationTypePattern ap = p.maybeParseAnnotationPattern();
+               ap = ap.resolveBindings(makeSimpleScope(),new Bindings(3),true);                
+               AndAnnotationTypePattern atp = (AndAnnotationTypePattern) ap;
                NotAnnotationTypePattern notBoo = (NotAnnotationTypePattern) atp.getRight();
                ExactAnnotationTypePattern boo = (ExactAnnotationTypePattern) notBoo.getNegatedPattern();
-               OrAnnotationTypePattern fooOrGoo = (OrAnnotationTypePattern) atp.getLeft();
-               ExactAnnotationTypePattern foo = (ExactAnnotationTypePattern) fooOrGoo.getLeft();
-               ExactAnnotationTypePattern goo = (ExactAnnotationTypePattern) fooOrGoo.getRight();
-               assertEquals("(!((@Foo || @Goo) && (!@Boo)))",ap.toString());
-       }
-       
-       public void testParseAndOrPattern() {
-               PatternParser p = new PatternParser("@Foo && @Boo || @Goo");
-               AnnotationTypePattern andOr = p.parseAnnotationTypePattern();
-               assertTrue("Should be or pattern",andOr instanceof OrAnnotationTypePattern);
+               WildAnnotationTypePattern fooOrGoo = (WildAnnotationTypePattern) atp.getLeft();
+               assertEquals("@((Foo || Goo)) !@Boo",ap.toString());
        }
        
+//     public void testParseAndOrPattern() {
+//             PatternParser p = new PatternParser("@Foo && @Boo || @Goo");
+//             AnnotationTypePattern andOr = p.parseAnnotationTypePattern();
+//             assertTrue("Should be or pattern",andOr instanceof OrAnnotationTypePattern);
+//     }
+//     
        public void testParseBadPattern() {
                PatternParser p = new PatternParser("@@Foo");
                try {
-                       AnnotationTypePattern bad = p.parseAnnotationTypePattern();
+                       AnnotationTypePattern bad = p.maybeParseAnnotationPattern();
                        fail("ParserException expected");
                } catch(ParserException pEx) {
-                       assertEquals("identifier",pEx.getMessage());
+                       assertEquals("expected name pattern",pEx.getMessage());
                }
        }
        
        public void testParseBadPattern2() {
                PatternParser p = new PatternParser("Foo");
-               try {
-                       AnnotationTypePattern bad = p.parseAnnotationTypePattern();
-                       fail("ParserException expected");
-               } catch(ParserException pEx) {
-                       assertEquals("@",pEx.getMessage());
-               }
+               AnnotationTypePattern bad = p.maybeParseAnnotationPattern();
+               assertEquals("ANY",AnnotationTypePattern.ANY,bad);
        }
+
        public void testParseNameOrVarAnnotationPattern() {
                PatternParser p = new PatternParser("@Foo");
                AnnotationTypePattern foo = p.parseAnnotationNameOrVarTypePattern();
@@ -143,11 +142,10 @@ public class AnnotationPatternTestCase extends TestCase {
        }
 
        public void testParseNameOrVarAnnotationPatternWithAnd() {
-               PatternParser p = new PatternParser("@Foo && @Boo");
+               PatternParser p = new PatternParser("@Foo @Boo");
                AnnotationTypePattern foo = p.parseAnnotationNameOrVarTypePattern();
                // rest of pattern not consumed...
-               assertTrue("ExactAnnotationTypePattern",foo instanceof ExactAnnotationTypePattern);
-               assertEquals("Foo",TypeX.forName("Foo"),((ExactAnnotationTypePattern)foo).annotationType);              
+               assertEquals("@Foo",foo.toString());
        }
 
        public void testMaybeParseAnnotationPattern() {
@@ -163,27 +161,27 @@ public class AnnotationPatternTestCase extends TestCase {
                PatternParser p = new PatternParser("@Foo *");
                TypePattern t = p.parseTypePattern();
                assertTrue("WildTypePattern",t instanceof WildTypePattern);
-               ExactAnnotationTypePattern etp = (ExactAnnotationTypePattern) t.annotationPattern;
-               assertEquals("@Foo",etp.toString());
-               assertEquals("@Foo *",t.toString());
+               AnnotationTypePattern atp = t.annotationPattern;
+               assertEquals("@(Foo)",atp.toString());
+               assertEquals("(@(Foo) *)",t.toString());
        }
        
        public void testParseTypePatternsWithAnnotationsComplex() {
-               PatternParser p = new PatternParser("(@(@Foo || @Boo) (Foo || Boo))");
+               PatternParser p = new PatternParser("(@(Foo || Boo) (Foo || Boo))");
                TypePattern t = p.parseTypePattern();
                assertTrue("OrTypePattern",t instanceof OrTypePattern);
-               OrAnnotationTypePattern etp = (OrAnnotationTypePattern) t.annotationPattern;
-               assertEquals("(@Foo || @Boo)",etp.toString());
-               assertEquals("(@(@Foo || @Boo) (Foo || Boo))",t.toString());
+               WildAnnotationTypePattern wtp = (WildAnnotationTypePattern) t.annotationPattern;
+               assertEquals("@((Foo || Boo))",wtp.toString());
+               assertEquals("(@((Foo || Boo)) (Foo || Boo))",t.toString());
        }
        
-       public void testRidiculousNotSyntax() {
-               PatternParser p = new PatternParser("(@(!@Foo) (Foo || Boo))");
+       public void testNotSyntax() {
+               PatternParser p = new PatternParser("!@Foo (Foo || Boo))");
                TypePattern t = p.parseTypePattern();
                assertTrue("OrTypePattern",t instanceof OrTypePattern);
                NotAnnotationTypePattern natp = (NotAnnotationTypePattern) t.annotationPattern;
-               assertEquals("(!@Foo)",natp.toString());
-               assertEquals("(@(!@Foo) (Foo || Boo))",t.toString());           
+               assertEquals("!@(Foo)",natp.toString());
+               assertEquals("(!@(Foo) (Foo || Boo))",t.toString());            
        }
 
        public void testParseMethodOrConstructorSigNoAP() {
@@ -199,21 +197,21 @@ public class AnnotationPatternTestCase extends TestCase {
        public void testParseMethodOrConstructorSigSimpleAP() {
                PatternParser p = new PatternParser("@Foo * *.*(..)");
                SignaturePattern s = p.parseMethodOrConstructorSignaturePattern();
-               assertEquals("Exact annotation","@Foo",((ExactAnnotationTypePattern)s.getAnnotationPattern()).toString());
+               assertEquals("@(Foo) annotation","@(Foo)",s.getAnnotationPattern().toString());
                assertEquals("Any return","*",s.getReturnType().toString());
                assertEquals("Any dec type","*",s.getDeclaringType().toString());
                assertEquals("Any name","*",s.getName().toString());
-               assertEquals("@Foo * *.*(..)",s.toString());
+               assertEquals("@(Foo) * *.*(..)",s.toString());
        }
        
        public void testParseMethodOrConstructorSigComplexAP() {
-               PatternParser p = new PatternParser("@(!@Foo || @Goo) * *.*(..)");
+               PatternParser p = new PatternParser("!@(Foo || Goo) * *.*(..)");
                SignaturePattern s = p.parseMethodOrConstructorSignaturePattern();
-               assertEquals("complex annotation","((!@Foo) || @Goo)",s.getAnnotationPattern().toString());
+               assertEquals("complex annotation","!@((Foo || Goo))",s.getAnnotationPattern().toString());
                assertEquals("Any return","*",s.getReturnType().toString());
                assertEquals("Any dec type","*",s.getDeclaringType().toString());
                assertEquals("Any name","*",s.getName().toString());    
-               assertEquals("@((!@Foo) || @Goo) * *.*(..)",s.toString());              
+               assertEquals("!@((Foo || Goo)) * *.*(..)",s.toString());                
        }
        
        public void testParseMethodFieldSigNoAP() {
@@ -229,26 +227,26 @@ public class AnnotationPatternTestCase extends TestCase {
        public void testParseFieldSigSimpleAP() {
                PatternParser p = new PatternParser("@Foo * *.*");
                SignaturePattern s = p.parseFieldSignaturePattern();
-               assertEquals("Exact annotation","@Foo",((ExactAnnotationTypePattern)s.getAnnotationPattern()).toString());
+               assertEquals("@Foo annotation","@(Foo)",s.getAnnotationPattern().toString());
                assertEquals("Any field type","*",s.getReturnType().toString());
                assertEquals("Any dec type","*",s.getDeclaringType().toString());
                assertEquals("Any name","*",s.getName().toString());
-               assertEquals("@Foo * *.*",s.toString());                                
+               assertEquals("@(Foo) * *.*",s.toString());                              
        }
        
        public void testParseFieldSigComplexAP() {
-               PatternParser p = new PatternParser("@(!@Foo || @Goo) * *.*");
+               PatternParser p = new PatternParser("!@(Foo || Goo) * *.*");
                SignaturePattern s = p.parseFieldSignaturePattern();
-               assertEquals("complex annotation","((!@Foo) || @Goo)",s.getAnnotationPattern().toString());
+               assertEquals("complex annotation","!@((Foo || Goo))",s.getAnnotationPattern().toString());
                assertEquals("Any field type","*",s.getReturnType().toString());
                assertEquals("Any dec type","*",s.getDeclaringType().toString());
                assertEquals("Any name","*",s.getName().toString());
-               assertEquals("@((!@Foo) || @Goo) * *.*",s.toString());                          
+               assertEquals("!@((Foo || Goo)) * *.*",s.toString());                            
        }
        
        public void testExactAnnotationPatternMatching() {
                PatternParser p = new PatternParser("@Foo");
-               AnnotationTypePattern ap = p.parseAnnotationTypePattern();
+               AnnotationTypePattern ap = p.maybeParseAnnotationPattern();
                ap = ap.resolveBindings(makeSimpleScope(),new Bindings(3),true);
                AnnotatedElementImpl ae = new AnnotatedElementImpl(new String[]{"Foo"});
                assertTrue("matches element with Foo",ap.matches(ae).alwaysTrue());
@@ -267,8 +265,8 @@ public class AnnotationPatternTestCase extends TestCase {
        }
        
        public void testAndAnnotationPatternMatching() {
-               PatternParser p = new PatternParser("@Foo && @Boo");
-               AnnotationTypePattern ap = p.parseAnnotationTypePattern();
+               PatternParser p = new PatternParser("@Foo @Boo");
+               AnnotationTypePattern ap = p.maybeParseAnnotationPattern();
                ap = ap.resolveBindings(makeSimpleScope(),new Bindings(3),true);
                AnnotatedElementImpl ae = new AnnotatedElementImpl(new String[] {"Foo","Boo"});
                assertTrue("matches foo and boo",ap.matches(ae).alwaysTrue());
@@ -279,24 +277,24 @@ public class AnnotationPatternTestCase extends TestCase {
                ae = new AnnotatedElementImpl(new String[] {"Goo"});
                assertTrue("does not match goo",ap.matches(ae).alwaysFalse());          
        }
-       
-       public void testOrAnnotationPatternMatching() {
-               PatternParser p = new PatternParser("@Foo || @Boo");
-               AnnotationTypePattern ap = p.parseAnnotationTypePattern();
-               ap = ap.resolveBindings(makeSimpleScope(),new Bindings(3),true);
-               AnnotatedElementImpl ae = new AnnotatedElementImpl(new String[] {"Foo","Boo"});
-               assertTrue("matches foo and boo",ap.matches(ae).alwaysTrue());
-               ae = new AnnotatedElementImpl(new String[] {"Foo"});
-               assertTrue("matches foo",ap.matches(ae).alwaysTrue());
-               ae = new AnnotatedElementImpl(new String[] {"Boo"});
-               assertTrue("matches boo",ap.matches(ae).alwaysTrue());
-               ae = new AnnotatedElementImpl(new String[] {"Goo"});
-               assertTrue("does not match goo",ap.matches(ae).alwaysFalse());                          
-       }
-       
+//     
+//     public void testOrAnnotationPatternMatching() {
+//             PatternParser p = new PatternParser("@Foo || @Boo");
+//             AnnotationTypePattern ap = p.parseAnnotationTypePattern();
+//             ap = ap.resolveBindings(makeSimpleScope(),new Bindings(3),true);
+//             AnnotatedElementImpl ae = new AnnotatedElementImpl(new String[] {"Foo","Boo"});
+//             assertTrue("matches foo and boo",ap.matches(ae).alwaysTrue());
+//             ae = new AnnotatedElementImpl(new String[] {"Foo"});
+//             assertTrue("matches foo",ap.matches(ae).alwaysTrue());
+//             ae = new AnnotatedElementImpl(new String[] {"Boo"});
+//             assertTrue("matches boo",ap.matches(ae).alwaysTrue());
+//             ae = new AnnotatedElementImpl(new String[] {"Goo"});
+//             assertTrue("does not match goo",ap.matches(ae).alwaysFalse());                          
+//     }
+//     
        public void testNotAnnotationPatternMatching() {
                PatternParser p = new PatternParser("!@Foo");
-               AnnotationTypePattern ap = p.parseAnnotationTypePattern();
+               AnnotationTypePattern ap = p.maybeParseAnnotationPattern();
                ap = ap.resolveBindings(makeSimpleScope(),new Bindings(3),true);
                AnnotatedElementImpl ae = new AnnotatedElementImpl(new String[] {"Foo","Boo"});
                assertTrue("does not match foo and boo",ap.matches(ae).alwaysFalse());          
@@ -314,8 +312,8 @@ public class AnnotationPatternTestCase extends TestCase {
        
        public TestScope makeSimpleScope() {
                BcelWorld bWorld = new BcelWorld(BcweaverTests.TESTDATA_PATH + "/testcode.jar"); // testcode contains Foo/Boo/Goo/etc
-               return new TestScope(new String[] {"int", "java.lang.String","Foo"}, 
-                                            new String[] {"a", "b","foo"}, 
+               return new TestScope(new String[] {"int", "java.lang.String","Foo","Boo","Goo"}, 
+                                            new String[] {"a", "b","foo","boo","goo"}, 
                                                         bWorld);
        }