Package org.aspectj.weaver.patterns

Examples of org.aspectj.weaver.patterns.PatternParser


   * @param allowIf
   * @return pointcut, unresolved
   */
  private static Pointcut parsePointcut(String pointcutString, AjAttributeStruct struct, boolean allowIf) {
    try {
      PatternParser parser = new PatternParser(pointcutString, struct.context);
      Pointcut pointcut = parser.parsePointcut();
      parser.checkEof();
      pointcut.check(null, struct.enclosingType.getWorld());
      if (!allowIf && pointcutString.indexOf("if()") >= 0 && hasIf(pointcut)) {
        reportError("if() pointcut is not allowed at this pointcut location '" + pointcutString + "'", struct);
        return null;
      }
View Full Code Here


   * @param location
   * @return type pattern
   */
  private static TypePattern parseTypePattern(String patternString, AjAttributeStruct location) {
    try {
      TypePattern typePattern = new PatternParser(patternString).parseTypePattern();
      typePattern.setLocation(location.context, -1, -1);// FIXME -1,-1 is
      // not good
      // enough
      return typePattern;
    } catch (ParserException e) {
View Full Code Here

    }
  }   
 
 
  public PerClause parsePerClause(Parser parser) {
    PatternParser patternParser = new PatternParser(tokenSource);
    try {
      PerClause ret = patternParser.maybeParsePerClause();
      checkEof(parser);
      if (ret == null) return new PerSingleton();
      else return ret;
    } catch (ParserException pe) {
      reportError(parser, pe);
View Full Code Here

 
//  public TypePattern parseTypePattern(Parser parser) {
//  }
// 
  public Declare parseDeclare(Parser parser) {
    PatternParser patternParser = new PatternParser(tokenSource);
    try {
      Declare ret = patternParser.parseDeclare();
      checkEof(parser);
      return ret;
    } catch (ParserException pe) {
      reportError(parser, pe);
      return null;
View Full Code Here

      return null;
    }
  }
 
  public Declare parseAnnotationDeclare(Parser parser) {
    PatternParser patternParser = new PatternParser(tokenSource);
    try {
      Declare ret = patternParser.parseDeclareAnnotation();
      checkEof(parser);
      return ret;
    } catch (ParserException pe) {
      reportError(parser, pe);
      return null;
View Full Code Here

    // AspectDeclaration(typeDecl.compilationResult);

    try {
      if (perClause != null && !perClause.equals("")) {
        ISourceContext context = new EclipseSourceContext(unit.compilationResult, pcLoc[0]);
        Pointcut pc = new PatternParser(perClause, context).maybeParsePerClause();
        FormalBinding[] bindings = new FormalBinding[0];
        if (pc != null)
          pc.resolve(new EclipseScope(bindings, typeDecl.scope));
      }
    } catch (ParserException pEx) {
View Full Code Here

    if (pointcutExpression == null)
      pointcutExpression = getStringLiteralFor("value", adviceAnn, pcLocation);
    try {
      // +1 to give first char of pointcut string
      ISourceContext context = new EclipseSourceContext(unit.compilationResult, pcLocation[0] + 1);
      PatternParser pp = new PatternParser(pointcutExpression, context);
      Pointcut pc = pp.parsePointcut();
      pp.checkEof();
      FormalBinding[] bindings = buildFormalAdviceBindingsFrom(methodDeclaration);
      pc.resolve(new EclipseScope(bindings, methodDeclaration.scope));
      EclipseFactory factory = EclipseFactory.fromScopeLookupEnvironment(methodDeclaration.scope);
      // now create a ResolvedPointcutDefinition,make an attribute out of
      // it, and add it to the method
View Full Code Here

      Pointcut pc = null;// abstract
      if (pointcutExpression == null || pointcutExpression.length() == 0) {
        noValueSupplied = true; // matches nothing pointcut
      } else {
        noValueSupplied = false;
        pc = new PatternParser(pointcutExpression, context).parsePointcut();
      }
      pcDecl.pointcutDesignator = (pc == null) ? null : new PointcutDesignator(pc);
      pcDecl.setGenerateSyntheticPointcutMethod();
      TypeDeclaration onType = (TypeDeclaration) typeStack.peek();
      pcDecl.postParse(onType);
View Full Code Here


  public AspectJTypeFilter(String typePatternExpression, ClassLoader classLoader) {
    this.world = new BcelWorld(classLoader, IMessageHandler.THROW, null);
    this.world.setBehaveInJava5Way(true);
    PatternParser patternParser = new PatternParser(typePatternExpression);
    TypePattern typePattern = patternParser.parseTypePattern();
    typePattern.resolve(this.world);
    IScope scope = new SimpleScope(this.world, new FormalBinding[0]);
    this.typePattern = typePattern.resolveBindings(scope, Bindings.NONE, false, false);
  }
View Full Code Here

    AnnotationGen aspect = getAnnotation(runtimeAnnotations, AjcMemberMaker.DECLAREPRECEDENCE_ANNOTATION);
    if (aspect != null) {
      NameValuePair precedence = getAnnotationElement(aspect, VALUE);
      if (precedence != null) {
        String precedencePattern = precedence.getValue().stringifyValue();
        PatternParser parser = new PatternParser(precedencePattern);
        DeclarePrecedence ajPrecedence = parser.parseDominates();
        struct.ajAttributes.add(new AjAttribute.DeclareAttribute(ajPrecedence));
        return true;
      }
    }
    return false;
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.patterns.PatternParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.