]> source.dussan.org Git - aspectj.git/commitdiff
292264: declare error/warning with type patterns
authoraclement <aclement>
Mon, 5 Apr 2010 22:23:55 +0000 (22:23 +0000)
committeraclement <aclement>
Mon, 5 Apr 2010 22:23:55 +0000 (22:23 +0000)
org.aspectj.matcher/src/org/aspectj/weaver/CrosscuttingMembers.java
org.aspectj.matcher/src/org/aspectj/weaver/World.java
org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java

index af2fe22ce2310d8f0eaf2a51cb172563aa79351b..5ada3efc9aff37789b3eb08cbb6ca5855b0e7323 100644 (file)
@@ -454,6 +454,10 @@ public class CrosscuttingMembers {
                        changed = true;
                        declareAnnotationsOnMethods = other.declareAnnotationsOnMethods;
                }
+               if (!declareTypeEow.equals(other.declareTypeEow)) {
+                       changed = true;
+                       declareTypeEow = other.declareTypeEow;
+               }
 
                return changed;
        }
index 2736e64e949233c3095620e7bd949cd97f49768f..cf38789ffa05ca18a4647fb29e968e86a302fe78 100644 (file)
@@ -41,6 +41,7 @@ import org.aspectj.weaver.patterns.DeclareAnnotation;
 import org.aspectj.weaver.patterns.DeclareParents;
 import org.aspectj.weaver.patterns.DeclarePrecedence;
 import org.aspectj.weaver.patterns.DeclareSoft;
+import org.aspectj.weaver.patterns.DeclareTypeErrorOrWarning;
 import org.aspectj.weaver.patterns.Pointcut;
 import org.aspectj.weaver.patterns.TypePattern;
 import org.aspectj.weaver.tools.PointcutDesignatorHandler;
@@ -736,9 +737,9 @@ public abstract class World implements Dump.INode {
                return crosscuttingMembersSet.getDeclareAnnotationOnMethods();
        }
 
-       // public List<DeclareTypeErrorOrWarning> getDeclareTypeEows() {
-       // return crosscuttingMembersSet.getDeclareTypeEows();
-       // }
+       public List<DeclareTypeErrorOrWarning> getDeclareTypeEows() {
+               return crosscuttingMembersSet.getDeclareTypeEows();
+       }
 
        public List<DeclareSoft> getDeclareSoft() {
                return crosscuttingMembersSet.getDeclareSofts();
index 8aeb647203e8ffd092a8e212acb05e71e53a2cf4..1062c79c9c2f3dd91d3ff88b48ad96d23a175d3d 100644 (file)
@@ -256,8 +256,36 @@ public class PatternParser {
                return new DeclareSoft(p, pointcut);
        }
 
+       /**
+        * Attempt to parse a pointcut, if that fails then try again for a type pattern.
+        * 
+        * @param isError true if it is declare error rather than declare warning
+        * @return the new declare
+        */
        private Declare parseErrorOrWarning(boolean isError) {
-               Pointcut pointcut = parsePointcut();
+               Pointcut pointcut = null;
+               int index = tokenSource.getIndex();
+               try {
+                       pointcut = parsePointcut();
+               } catch (ParserException pe) {
+                       try {
+                               tokenSource.setIndex(index);
+                               boolean oldValue = allowHasTypePatterns;
+                               TypePattern typePattern = null;
+                               try {
+                                       allowHasTypePatterns = true;
+                                       typePattern = parseTypePattern();
+                               } finally {
+                                       allowHasTypePatterns = oldValue;
+                               }
+                               eat(":");
+                               String message = parsePossibleStringSequence(true);
+                               return new DeclareTypeErrorOrWarning(isError, typePattern, message);
+                       } catch (ParserException pe2) {
+                               // deliberately throw the original problem
+                               throw pe;
+                       }
+               }
                eat(":");
                String message = parsePossibleStringSequence(true);
                return new DeclareErrorOrWarning(isError, pointcut, message);