From 99eb7f8654eef884dfb204f8fdc0ea00fe849cec Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 25 Jan 2006 11:28:51 +0000 Subject: [PATCH] fix for 122452 - pattern parser for a duff pointcut definition. Also fix for 125027 (deow length set wrong during parsing). latter fix from Helen. --- .../org/aspectj/systemtest/ajc151/Ajc151Tests.java | 4 ++-- tests/src/org/aspectj/systemtest/ajc151/ajc151.xml | 10 ++++++++-- .../org/aspectj/weaver/patterns/PatternParser.java | 13 +++++++++++-- .../patterns/DeclareErrorOrWarningTestCase.java | 7 +++++++ 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 @@ - + + + + + - + + + 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(";",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(); } -- 2.39.5