From 70eb59751815d16feddae8207b68d112f07623e8 Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 5 Apr 2010 22:23:55 +0000 Subject: [PATCH] 292264: declare error/warning with type patterns --- .../aspectj/weaver/CrosscuttingMembers.java | 4 +++ .../src/org/aspectj/weaver/World.java | 7 +++-- .../weaver/patterns/PatternParser.java | 30 ++++++++++++++++++- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/CrosscuttingMembers.java b/org.aspectj.matcher/src/org/aspectj/weaver/CrosscuttingMembers.java index af2fe22ce..5ada3efc9 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/CrosscuttingMembers.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/CrosscuttingMembers.java @@ -454,6 +454,10 @@ public class CrosscuttingMembers { changed = true; declareAnnotationsOnMethods = other.declareAnnotationsOnMethods; } + if (!declareTypeEow.equals(other.declareTypeEow)) { + changed = true; + declareTypeEow = other.declareTypeEow; + } return changed; } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/World.java b/org.aspectj.matcher/src/org/aspectj/weaver/World.java index 2736e64e9..cf38789ff 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/World.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/World.java @@ -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 getDeclareTypeEows() { - // return crosscuttingMembersSet.getDeclareTypeEows(); - // } + public List getDeclareTypeEows() { + return crosscuttingMembersSet.getDeclareTypeEows(); + } public List getDeclareSoft() { return crosscuttingMembersSet.getDeclareSofts(); diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java index 8aeb64720..1062c79c9 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java @@ -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); -- 2.39.5