]> source.dussan.org Git - aspectj.git/commitdiff
Fix for Bugzilla Bug 61536
authoraclement <aclement>
Thu, 29 Jul 2004 12:39:42 +0000 (12:39 +0000)
committeraclement <aclement>
Thu, 29 Jul 2004 12:39:42 +0000 (12:39 +0000)
   Front-end bug, shouldn't allow patterns of the form foo.., should be foo..*

tests/ajcTests.xml
tests/bugs/EllipsesStar.java [new file with mode: 0644]
weaver/src/org/aspectj/weaver/patterns/PatternParser.java

index 024bc1d1ea7c2ddeb834397564317fa489fedd4f..8b42152d32712debcc1a29df0417bb2fda3e0745 100644 (file)
         <compile files="PrimitiveCoercionInExactTypePatternMatching.java"/>
     </ajc-test>
     
+    <ajc-test dir="bugs"
+               pr="61536" title="Front-end bug, shouldn't allow patterns of the form foo.., should be foo..*">
+        <compile files="EllipsesStar.java">
+          <message kind="error" line="3" text="Syntax error on token"/>
+          <message kind="error" line="4" text="Syntax error on token"/>
+          <message kind="error" line="5" text="Syntax error on token"/>
+          <message kind="error" line="6" text="Syntax error on token"/>
+          <message kind="error" line="8" text="Syntax error on token"/>
+          <message kind="error" line="10" text="Syntax error on token"/>
+          <message kind="error" line="12" text="Syntax error on token"/>
+        </compile>
+    </ajc-test>
+    
 </suite>
diff --git a/tests/bugs/EllipsesStar.java b/tests/bugs/EllipsesStar.java
new file mode 100644 (file)
index 0000000..940db8a
--- /dev/null
@@ -0,0 +1,13 @@
+// Name patterns can't end with '..'
+aspect A {
+       pointcut endsDot(): call(* java.(..));
+       pointcut p1(): call(* java.lang..(..));
+       pointcut p2(): call((Integer || java.lang..) m(..));
+       pointcut p3(): call(* m() throws java.lang..);
+       
+       pointcut p4(): call(* a..b..c..d..(..));
+       
+       pointcut p5(): call(* a....(..));
+       
+       pointcut p6(): call(java. m());
+}
\ No newline at end of file
index 0f0bd3e577c83f20b93c79c311f922ebdc404200..89a168fefd8a7c1699d7dc52954ed94c885abd48 100644 (file)
@@ -448,12 +448,17 @@ public class PatternParser {
                List names = new ArrayList();
                StringBuffer buf = new StringBuffer();
                IToken previous = null;
+               boolean justProcessedEllipsis = false; // Remember if we just dealt with an ellipsis (PR61536)
+               boolean justProcessedDot = false; 
+               boolean onADot = false;
                while (true) {
-                       IToken tok;
+                       IToken tok = null;
                        int startPos = tokenSource.peek().getStart();
                        String afterDot = null;
                        while (true) {
+                               if (previous !=null && previous.getString().equals(".")) justProcessedDot = true;
                                tok = tokenSource.peek();
+                               onADot = (tok.getString().equals("."));
                                if (previous != null) {
                                        if (!isAdjacent(previous, tok)) break;
                                }
@@ -481,13 +486,22 @@ public class PatternParser {
                                throw new ParserException("expected name pattern", tok);
                        } 
                        
+                       if (buf.length() == 0 && justProcessedEllipsis) {
+                               throw new ParserException("name pattern cannot finish with ..", tok);
+                       }
+                       if (buf.length() == 0 && justProcessedDot && !onADot) {
+                                       throw new ParserException("name pattern cannot finish with .", tok);
+                       }
+                       
                        if (buf.length() == 0) {
                                names.add(NamePattern.ELLIPSIS);
+                               justProcessedEllipsis = true;
                        } else {
                                checkLegalName(buf.toString(), previous);
                                NamePattern ret = new NamePattern(buf.toString());
                                ret.setLocation(sourceContext, startPos, endPos);
                                names.add(ret);
+                               justProcessedEllipsis = false;
                        }
                        
                        if (afterDot == null) {