private TypePattern[] maybeParseAdditionalInterfaceBounds() { List<TypePattern> boundsList = new ArrayList<TypePattern>(); while (maybeEat("&")) { TypePattern tp = parseTypePattern(); boundsList.add(tp); } if (boundsList.size() == 0) { return null; } TypePattern[] ret = new TypePattern[boundsList.size()]; boundsList.toArray(ret); return ret; }
private boolean maybeEatNew(TypePattern returnType) { if (returnType instanceof WildTypePattern) { WildTypePattern p = (WildTypePattern) returnType; if (p.maybeExtractName("new")) { return true; } } int start = tokenSource.getIndex(); if (maybeEat(".")) { String id = maybeEatIdentifier(); if (id != null && id.equals("new")) { return true; } tokenSource.setIndex(start); } return false; }
public String[] maybeParseSimpleTypeVariableList() { if (!maybeEat("<")) { return null; } List<String> typeVarNames = new ArrayList<String>(); do { typeVarNames.add(parseIdentifier()); } while (maybeEat(",")); eat(">", "',' or '>'"); String[] tvs = new String[typeVarNames.size()]; typeVarNames.toArray(tvs); return tvs; }
public TypePatternList maybeParseTypeParameterList() { if (!maybeEat("<")) { return null; } List<TypePattern> typePats = new ArrayList<TypePattern>(); do { TypePattern tp = parseTypePattern(true, false); typePats.add(tp); } while (maybeEat(",")); eat(">"); TypePattern[] tps = new TypePattern[typePats.size()]; typePats.toArray(tps); return new TypePatternList(tps); }
public List<String> parseDottedIdentifier() { List<String> ret = new ArrayList<String>(); ret.add(parseIdentifier()); while (maybeEat(".")) { ret.add(parseIdentifier()); } return ret; }
public DeclarePrecedence parseDominates() { List<TypePattern> l = new ArrayList<TypePattern>(); do { l.add(parseTypePattern()); } while (maybeEat(",")); return new DeclarePrecedence(l); }
public AnnotationPatternList parseArgumentsAnnotationPattern() { List<AnnotationTypePattern> patterns = new ArrayList<AnnotationTypePattern>(); eat("("); if (maybeEat(")")) { return new AnnotationPatternList(); } do { if (maybeEat(".")) { eat("."); patterns.add(AnnotationTypePattern.ELLIPSIS); } else if (maybeEat("*")) { patterns.add(AnnotationTypePattern.ANY); } else { patterns.add(parseAnnotationNameOrVarTypePattern()); } } while (maybeEat(",")); eat(")"); return new AnnotationPatternList(patterns); }
public TypePatternList parseArgumentsPattern(boolean parameterAnnotationsPossible) { List<TypePattern> patterns = new ArrayList<TypePattern>(); eat("("); // () if (maybeEat(")")) { return new TypePatternList(); } do { if (maybeEat(".")) { // .. eat("."); patterns.add(TypePattern.ELLIPSIS); } else { patterns.add(parseTypePattern(false, parameterAnnotationsPossible)); } } while (maybeEat(",")); eat(")"); return new TypePatternList(patterns); }
/** * @return */ private ExactAnnotationTypePattern parseSimpleAnnotationName() { // the @ has already been eaten... ExactAnnotationTypePattern p; StringBuffer annotationName = new StringBuffer(); annotationName.append(parseIdentifier()); while (maybeEat(".")) { annotationName.append('.'); annotationName.append(parseIdentifier()); } UnresolvedType type = UnresolvedType.forName(annotationName.toString()); p = new ExactAnnotationTypePattern(type, null); return p; }
public TypePattern parseTypePattern(boolean insideTypeParameters, boolean parameterAnnotationsPossible) { TypePattern p = parseAtomicTypePattern(insideTypeParameters, parameterAnnotationsPossible); if (maybeEat("&&")) { p = new AndTypePattern(p, parseNotOrTypePattern(insideTypeParameters, parameterAnnotationsPossible)); } if (maybeEat("||")) { p = new OrTypePattern(p, parseTypePattern(insideTypeParameters, parameterAnnotationsPossible)); } return p; }
private Pointcut parseNotOrPointcut() { Pointcut p = parseAtomicPointcut(); if (maybeEat("&&")) { p = new AndPointcut(p, parseNotOrPointcut()); } return p; }
private TypePattern parseNotOrTypePattern(boolean insideTypeParameters, boolean parameterAnnotationsPossible) { TypePattern p = parseAtomicTypePattern(insideTypeParameters, parameterAnnotationsPossible); if (maybeEat("&&")) { p = new AndTypePattern(p, parseTypePattern(insideTypeParameters, parameterAnnotationsPossible)); } return p; }
public ISignaturePattern parseCompoundMethodOrConstructorSignaturePattern(boolean isMethod) { ISignaturePattern atomicMethodCtorSignaturePattern = parseMaybeParenthesizedMethodOrConstructorSignaturePattern(isMethod); while (isEitherAndOrOr()) { if (maybeEat("&&")) { atomicMethodCtorSignaturePattern = new AndSignaturePattern(atomicMethodCtorSignaturePattern, parseMaybeParenthesizedMethodOrConstructorSignaturePattern(isMethod)); } if (maybeEat("||")) { atomicMethodCtorSignaturePattern = new OrSignaturePattern(atomicMethodCtorSignaturePattern, parseMaybeParenthesizedMethodOrConstructorSignaturePattern(isMethod)); } } return atomicMethodCtorSignaturePattern; }
private Pointcut parseThisOrTargetAnnotationPointcut() { String kind = parseIdentifier(); eat("("); if (maybeEat(")")) { throw new ParserException("expecting @AnnotationName or parameter, but found ')'", tokenSource.peek()); } ExactAnnotationTypePattern type = parseAnnotationNameOrVarTypePattern(); eat(")"); return new ThisOrTargetAnnotationPointcut(kind.equals("this"), type); }
public ISignaturePattern parseMaybeParenthesizedFieldSignaturePattern() { boolean negated = tokenSource.peek().getString().equals("!") && tokenSource.peek(1).getString().equals("("); if (negated) { eat("!"); } ISignaturePattern result = null; if (maybeEat("(")) { result = parseCompoundFieldSignaturePattern(); eat(")", "missing ')' - unbalanced parentheses around field signature pattern in declare @field"); if (negated) { result = new NotSignaturePattern(result); } } else { result = parseFieldSignaturePattern(); } return result; }
protected ExactAnnotationTypePattern parseAnnotationNameOrVarTypePattern() { ExactAnnotationTypePattern p = null; int startPos = tokenSource.peek().getStart(); if (maybeEat("@")) { throw new ParserException("@Foo form was deprecated in AspectJ 5 M2: annotation name or var ", tokenSource.peek(-1)); } p = parseSimpleAnnotationName(); int endPos = tokenSource.peek(-1).getEnd(); p.setLocation(sourceContext, startPos, endPos); // For optimized syntax that allows binding directly to annotation values (pr234943) if (maybeEat("(")) { String formalName = parseIdentifier(); p = new ExactAnnotationFieldTypePattern(p, formalName); eat(")"); } return p; }
private Pointcut parseAtAnnotationPointcut() { parseIdentifier(); eat("("); if (maybeEat(")")) { throw new ParserException("@AnnotationName or parameter", tokenSource.peek()); } ExactAnnotationTypePattern type = parseAnnotationNameOrVarTypePattern(); eat(")"); return new AnnotationPointcut(type); }
private Pointcut parseWithinAnnotationPointcut() { /* String kind = */parseIdentifier(); eat("("); if (maybeEat(")")) { throw new ParserException("expecting @AnnotationName or parameter, but found ')'", tokenSource.peek()); } AnnotationTypePattern type = parseAnnotationNameOrVarTypePattern(); eat(")"); return new WithinAnnotationPointcut(type); }
private Pointcut parseWithinCodeAnnotationPointcut() { /* String kind = */parseIdentifier(); eat("("); if (maybeEat(")")) { throw new ParserException("expecting @AnnotationName or parameter, but found ')'", tokenSource.peek()); } ExactAnnotationTypePattern type = parseAnnotationNameOrVarTypePattern(); eat(")"); return new WithinCodeAnnotationPointcut(type); }