diff options
author | aclement <aclement> | 2006-01-25 11:28:51 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-01-25 11:28:51 +0000 |
commit | 99eb7f8654eef884dfb204f8fdc0ea00fe849cec (patch) | |
tree | dc89bd9b9dbbfb17b241fc8f5345232a71edf4ae | |
parent | 244a1c78371fab02a6b2a9937fcc27e6cf1bc61d (diff) | |
download | aspectj-99eb7f8654eef884dfb204f8fdc0ea00fe849cec.tar.gz aspectj-99eb7f8654eef884dfb204f8fdc0ea00fe849cec.zip |
fix for 122452 - pattern parser for a duff pointcut definition. Also fix for 125027 (deow length set wrong during parsing). latter fix from Helen.
4 files changed, 28 insertions, 6 deletions
diff --git a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java index cf2e4d742..12ac259bf 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java @@ -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"); diff --git a/tests/src/org/aspectj/systemtest/ajc151/ajc151.xml b/tests/src/org/aspectj/systemtest/ajc151/ajc151.xml index b10528b45..5dffbdc04 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/ajc151.xml +++ b/tests/src/org/aspectj/systemtest/ajc151/ajc151.xml @@ -71,11 +71,17 @@ </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 "*", "(" 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 "*", "(" expected"/> + </compile> </ajc-test> <ajc-test dir="bugs151/pr125080" title="mixing numbers of type parameters"> diff --git a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java index 3d5866203..e37663d3d 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java +++ b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java @@ -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(); } diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java index 00bebaef9..fb06efa5e 100644 --- a/weaver/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/patterns/DeclareErrorOrWarningTestCase.java @@ -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(); } |