aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.matcher
diff options
context:
space:
mode:
authoraclement <aclement>2010-08-20 00:16:11 +0000
committeraclement <aclement>2010-08-20 00:16:11 +0000
commitbc0c22604c3c1e273f071c0ae1afa06bd835d1b5 (patch)
tree43f488343bdd8cf893f0dd1be79f50aa5f7aed35 /org.aspectj.matcher
parenteab15393e510aeb107faa10f45d9d6b0d4ad4b17 (diff)
downloadaspectj-bc0c22604c3c1e273f071c0ae1afa06bd835d1b5.tar.gz
aspectj-bc0c22604c3c1e273f071c0ae1afa06bd835d1b5.zip
improvements to the positions for a type pattern - more to do here no doubt
Diffstat (limited to 'org.aspectj.matcher')
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java9
-rw-r--r--org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/NamePatternParserTestCase.java23
2 files changed, 24 insertions, 8 deletions
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java
index 2cc6d2036..7bb8593a4 100644
--- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java
@@ -756,6 +756,7 @@ public class PatternParser {
return p;
}
if (maybeEat("(")) {
+ int openParenPos = tokenSource.peek(-1).getStart();
TypePattern p = parseTypePattern(insideTypeParameters, false);
if ((p instanceof NotTypePattern) && !(ap instanceof AnyAnnotationTypePattern)) {
// dont set the annotation on it, we don't want the annotation to be
@@ -766,6 +767,7 @@ public class PatternParser {
p = setAnnotationPatternForTypePattern(p, ap, parameterAnnotationsPossible);
}
eat(")");
+ int closeParenPos = tokenSource.peek(-1).getStart();
boolean isVarArgs = maybeEat("...");
if (isVarArgs) {
p.setIsVarArgs(isVarArgs);
@@ -774,9 +776,14 @@ public class PatternParser {
if (isIncludeSubtypes) {
p.includeSubtypes = true; // need the test because (A+) should not set subtypes to false!
}
+ p.start = openParenPos;
+ p.end = closeParenPos;
return p;
}
int startPos = tokenSource.peek().getStart();
+ if (ap.start!=-1) {
+ startPos = ap.start;
+ }
TypePattern p = parseSingleTypePattern(insideTypeParameters);
int endPos = tokenSource.peek(-1).getEnd();
p = setAnnotationPatternForTypePattern(p, ap, false);
@@ -857,6 +864,7 @@ public class PatternParser {
eat(")");
return ret;
} else {
+ int atPos = tokenSource.peek(-1).getStart();
TypePattern p = parseSingleTypePattern();
if (maybeEatAdjacent("(")) {
values = parseAnnotationValues();
@@ -865,6 +873,7 @@ public class PatternParser {
} else {
ret = new WildAnnotationTypePattern(p);
}
+ ret.start = atPos;
return ret;
}
} else {
diff --git a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/NamePatternParserTestCase.java b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/NamePatternParserTestCase.java
index f224b1737..fe3b0f2d4 100644
--- a/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/NamePatternParserTestCase.java
+++ b/org.aspectj.matcher/testsrc/org/aspectj/weaver/patterns/NamePatternParserTestCase.java
@@ -17,8 +17,10 @@ import junit.framework.TestCase;
/**
* @author hugunin
*
- * To change this generated comment edit the template variable "typecomment": Window>Preferences>Java>Templates. To enable
- * and disable the creation of type comments go to Window>Preferences>Java>Code Generation.
+ * To change this generated comment edit the template variable
+ * "typecomment": Window>Preferences>Java>Templates. To enable and
+ * disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
*/
public class NamePatternParserTestCase extends TestCase {
/**
@@ -39,11 +41,15 @@ public class NamePatternParserTestCase extends TestCase {
assertEquals(new NamePattern("abc"), p);
}
- // public void testTypePattern() {
- // TypePattern tp = new PatternParser(" (@Ann *) ").parseTypePattern();
- // assertEquals(2, tp.start);
- // assertEquals(9, tp.end);
- // }
+ public void testTypePattern() {
+ TypePattern tp = null;
+ tp = new PatternParser(" @Ann * ").parseTypePattern();
+ assertEquals(1, tp.start);
+ assertEquals(6, tp.end);
+ tp = new PatternParser(" (@Ann *) ").parseTypePattern();
+ assertEquals(2, tp.start);
+ assertEquals(9, tp.end);
+ }
/**
* Method checkMatch.
@@ -55,7 +61,8 @@ public class NamePatternParserTestCase extends TestCase {
private void checkMatch(String[] patterns) {
for (int i = 0, len = patterns.length; i < len; i++) {
String pattern = patterns[i];
- ITokenSource tokenSource = BasicTokenSource.makeTokenSource(pattern, null);
+ ITokenSource tokenSource = BasicTokenSource.makeTokenSource(
+ pattern, null);
NamePattern p1 = new PatternParser(tokenSource).parseNamePattern();
NamePattern p2 = new NamePattern(pattern);
assertEquals("pattern: " + pattern, p2, p1);