]> source.dussan.org Git - aspectj.git/commitdiff
fix for 122452 - pattern parser for a duff pointcut definition. Also fix for 125027...
authoraclement <aclement>
Wed, 25 Jan 2006 11:28:51 +0000 (11:28 +0000)
committeraclement <aclement>
Wed, 25 Jan 2006 11:28:51 +0000 (11:28 +0000)
tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java
tests/src/org/aspectj/systemtest/ajc151/ajc151.xml
weaver/src/org/aspectj/weaver/patterns/PatternParser.java
weaver/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java

index cf2e4d7428e090107f687e6d8e0254a03441e617..12ac259bfa02b815d74a0314e27e82908376a5ad 100644 (file)
@@ -28,8 +28,8 @@ public class Ajc151Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
   public void testParameterizedCollectionFieldMatching_pr124808() { runTest("parameterized collection fields matched via pointcut");}
   public void testGenericAspectsAndAnnotations_pr124654() { runTest("generic aspects and annotations");}
   public void testCallInheritedGenericMethod_pr124999() { runTest("calling inherited generic method from around advice");}
-  //public void testIncorrectlyReferencingPointcuts_pr122452()    { runTest("incorrectly referencing pointcuts");}
-  //public void testIncorrectlyReferencingPointcuts_pr122452_2()    { runTest("incorrectly referencing pointcuts - 2");}
+  public void testIncorrectlyReferencingPointcuts_pr122452()    { runTest("incorrectly referencing pointcuts");}
+  public void testIncorrectlyReferencingPointcuts_pr122452_2()    { runTest("incorrectly referencing pointcuts - 2");}
   
   public void testMixingNumbersOfTypeParameters_pr125080()   { 
          runTest("mixing numbers of type parameters");    
index b10528b45528a1ba2d5a5fdd85ef57e4cf8d5c3d..5dffbdc04ce8a58dd05cfbece0c121661e66e51b 100644 (file)
     </ajc-test>
     
     <ajc-test dir="bugs151" title="incorrectly referencing pointcuts">
-        <compile files="pr122452.aj" options="-1.5"/>
+        <compile files="pr122452.aj" options="-1.5">
+          <message kind="warning" line="2" text="no match for this type name: Point [Xlint:invalidAbsoluteTypeName]"/>
+          <message kind="warning" line="3" text="no match for this type name: related.Hello [Xlint:invalidAbsoluteTypeName]"/>
+          <message kind="error" line="4" text="Syntax error on token &quot;*&quot;, &quot;(&quot; expected"/>
+        </compile>
     </ajc-test>
     
     <ajc-test dir="bugs151" title="incorrectly referencing pointcuts - 2">
-        <compile files="pr122452_2.aj" options="-1.5"/>
+        <compile files="pr122452_2.aj" options="-1.5">
+          <message kind="error" line="2" text="Syntax error on token &quot;*&quot;, &quot;(&quot; expected"/>
+        </compile>
     </ajc-test>
     
     <ajc-test dir="bugs151/pr125080" title="mixing numbers of type parameters">
index 3d5866203bf1f72ac1f6bdf7611e4d943f67363d..e37663d3d380fba1a5bcbfa8a83580a72da688ca 100644 (file)
@@ -546,8 +546,13 @@ public class PatternParser {
                onType = null;
        }
                
+               String simpleName = name.maybeGetSimpleName();
+               if (simpleName ==  null) {
+                       throw new ParserException("(",tokenSource.peek(-1));
+               }
+
                TypePatternList arguments = parseArgumentsPattern();
-               return new ReferencePointcut(onType, name.maybeGetSimpleName(), arguments);
+               return new ReferencePointcut(onType, simpleName, arguments);
        }
        
        private Pointcut parseDesignatorPointcut(PointcutDesignatorHandler pcdHandler) {
@@ -1325,7 +1330,11 @@ public class PatternParser {
                if (shouldEnd && t!=IToken.EOF) {
                        throw new ParserException("<string>;",token);
                }
-
+               // bug 125027: since we've eaten the ";" we need to set the index
+               // to be one less otherwise the end position isn't set correctly.
+               int currentIndex = tokenSource.getIndex();
+               tokenSource.setIndex(currentIndex-1);
+               
                return result.toString();
                
        }
index 00bebaef9f319d41b4da92b90ef257447b249677..fb06efa5e0fd4e0c13506bf7567e5b5eae351836 100644 (file)
@@ -44,6 +44,13 @@ public class DeclareErrorOrWarningTestCase extends TestCase {
                        
        }
 
+       public void testStartAndEndPositionSet() throws IOException {
+               DeclareErrorOrWarning d =
+                       parse("declare error: call(void foo()): \"that is bad\";");
+               assertEquals("start position should be 0", 0, d.getStart());
+               assertEquals("end position should be 46", 46, d.getEnd());
+       }
+       
        private DeclareErrorOrWarning parse(String string) {
                return (DeclareErrorOrWarning)new PatternParser(string).parseDeclare();
        }