From: Andy Clement Date: Wed, 9 Jan 2019 21:23:02 +0000 (-0800) Subject: better infrastructure for checking pointcuts terminate correctly - inactive right now X-Git-Tag: V1_9_3RC1~113 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b21a59365261d248f36c77446ec2b011dffd9a52;p=aspectj.git better infrastructure for checking pointcuts terminate correctly - inactive right now --- diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BasicTokenSource.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BasicTokenSource.java index ccde927f4..0a099529b 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BasicTokenSource.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BasicTokenSource.java @@ -180,4 +180,9 @@ public class BasicTokenSource implements ITokenSource { this.sourceContext = context; } + @Override + public boolean hasMoreTokens() { + return index < tokens.length; + } + } diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ITokenSource.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ITokenSource.java index ea777a47f..4649b046f 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ITokenSource.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/ITokenSource.java @@ -23,4 +23,5 @@ public interface ITokenSource { public int getIndex(); public void setIndex(int newIndex); public ISourceContext getSourceContext(); + public boolean hasMoreTokens(); } 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 f3bf08833..effecfeaf 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java @@ -97,6 +97,10 @@ public class PatternParser { eat(")"); return new PerCflow(entry, isBelow); } + + public boolean moreToParse() { + return tokenSource.hasMoreTokens(); + } private PerClause parsePerObject(boolean isThis) { parseIdentifier(); @@ -330,6 +334,16 @@ public class PatternParser { String message = parsePossibleStringSequence(true); return new DeclareErrorOrWarning(isError, pointcut, message); } + + public Pointcut parsePointcut(boolean shouldConsumeAllInput) { + Pointcut p = parsePointcut(); + if (shouldConsumeAllInput && tokenSource.hasMoreTokens()) { + throw new ParserException( + "Found unexpected data after parsing pointcut", + tokenSource.next()); + } + return p; + } public Pointcut parsePointcut() { Pointcut p = parseAtomicPointcut(); @@ -343,7 +357,7 @@ public class PatternParser { return p; } - + private Pointcut parseNotOrPointcut() { Pointcut p = parseAtomicPointcut(); if (maybeEat("&&")) { diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/tools/PointcutParser.java b/org.aspectj.matcher/src/org/aspectj/weaver/tools/PointcutParser.java index 4e3b2bd59..ca0fa3aca 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/tools/PointcutParser.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/tools/PointcutParser.java @@ -325,7 +325,7 @@ public class PointcutParser { try { PatternParser parser = new PatternParser(expression); parser.setPointcutDesignatorHandlers(pointcutDesignators, world); - Pointcut pc = parser.parsePointcut(); + Pointcut pc = parser.parsePointcut(); // more correctly: parsePointcut(true) validateAgainstSupportedPrimitives(pc, expression); IScope resolutionScope = buildResolutionScope((inScope == null ? Object.class : inScope), formalParameters); pc = pc.resolve(resolutionScope);