]> source.dussan.org Git - aspectj.git/commitdiff
better infrastructure for checking pointcuts terminate correctly - inactive right now
authorAndy Clement <aclement@pivotal.io>
Wed, 9 Jan 2019 21:23:02 +0000 (13:23 -0800)
committerAndy Clement <aclement@pivotal.io>
Wed, 9 Jan 2019 21:23:02 +0000 (13:23 -0800)
org.aspectj.matcher/src/org/aspectj/weaver/patterns/BasicTokenSource.java
org.aspectj.matcher/src/org/aspectj/weaver/patterns/ITokenSource.java
org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java
org.aspectj.matcher/src/org/aspectj/weaver/tools/PointcutParser.java

index ccde927f42e082fc936a5d9cbb3ce286be2edff5..0a099529b699a20cf39a85d319e448e1e57f99e4 100644 (file)
@@ -180,4 +180,9 @@ public class BasicTokenSource implements ITokenSource {
                this.sourceContext = context;
        }
 
+       @Override
+       public boolean hasMoreTokens() {
+               return index < tokens.length;
+       }
+
 }
index ea777a47f2e34e6f3d9e7e11a19ee5211969a00f..4649b046f0e536192bdd01d0312e3713921b93f7 100644 (file)
@@ -23,4 +23,5 @@ public interface ITokenSource {
        public int getIndex();
        public void setIndex(int newIndex);
        public ISourceContext getSourceContext();
+       public boolean hasMoreTokens();
 }
index f3bf0883358c1b3348f84bead6e22dc6e7725a30..effecfeafc64fe901ad730bcba2b89cd51e546d5 100644 (file)
@@ -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("&&")) {
index 4e3b2bd595d6c2e529e323485510a9bd51640680..ca0fa3aca77abdc8a4df43b8398830deb6ce135e 100644 (file)
@@ -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);