From 6c3063b50f9b34b3103e738122034b81c483f7ff Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 27 Oct 2010 16:06:40 +0000 Subject: [PATCH] 328840 --- .../weaver/patterns/PatternParser.java | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 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 7bb8593a4..320fe2121 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java @@ -202,19 +202,34 @@ public class PatternParser { } public ISignaturePattern parseCompoundFieldSignaturePattern() { - ISignaturePattern atomicFieldSignaturePattern = parseMaybeParenthesizedFieldSignaturePattern(); + int index = tokenSource.getIndex(); + try { + ISignaturePattern atomicFieldSignaturePattern = parseMaybeParenthesizedFieldSignaturePattern(); - while (isEitherAndOrOr()) { - if (maybeEat("&&")) { - atomicFieldSignaturePattern = new AndSignaturePattern(atomicFieldSignaturePattern, - parseMaybeParenthesizedFieldSignaturePattern()); + while (isEitherAndOrOr()) { + if (maybeEat("&&")) { + atomicFieldSignaturePattern = new AndSignaturePattern(atomicFieldSignaturePattern, + parseMaybeParenthesizedFieldSignaturePattern()); + } + if (maybeEat("||")) { + atomicFieldSignaturePattern = new OrSignaturePattern(atomicFieldSignaturePattern, + parseMaybeParenthesizedFieldSignaturePattern()); + } } - if (maybeEat("||")) { - atomicFieldSignaturePattern = new OrSignaturePattern(atomicFieldSignaturePattern, - parseMaybeParenthesizedFieldSignaturePattern()); + return atomicFieldSignaturePattern; + } catch (ParserException e) { + // fallback in the case of a regular single field signature pattern that just happened to start with '(' + int nowAt = tokenSource.getIndex(); + tokenSource.setIndex(index); + try { + ISignaturePattern fsp = parseFieldSignaturePattern(); + return fsp; + } catch (Exception e2) { + tokenSource.setIndex(nowAt); + // throw the original + throw e; } } - return atomicFieldSignaturePattern; } private boolean isEitherAndOrOr() { @@ -781,7 +796,7 @@ public class PatternParser { return p; } int startPos = tokenSource.peek().getStart(); - if (ap.start!=-1) { + if (ap.start != -1) { startPos = ap.start; } TypePattern p = parseSingleTypePattern(insideTypeParameters); -- 2.39.5