Package org.aspectj.weaver.patterns

Examples of org.aspectj.weaver.patterns.PatternParser


    public void addScopedAspect(String aspectName, String scope) {
      ensureInitialized();
      resolvedIncludedAspects.add(aspectName);
      try {
        TypePattern scopePattern = new PatternParser(scope).parseTypePattern();
        scopePattern.resolve(world);
        scopes.put(aspectName, scopePattern);
        if (!world.getMessageHandler().isIgnoring(IMessage.INFO)) {
          world.getMessageHandler().handleMessage(
              MessageUtil.info("Aspect '" + aspectName + "' is scoped to apply against types matching pattern '"
View Full Code Here


              // }
              String scope = definition.getScopeForAspect(name);
              if (scope != null) {
                // Resolve the type pattern
                try {
                  TypePattern scopePattern = new PatternParser(scope).parseTypePattern();
                  scopePattern.resolve(world);
                  scopes.put(name, scopePattern);
                  if (!world.getMessageHandler().isIgnoring(IMessage.INFO)) {
                    world.getMessageHandler().handleMessage(
                        MessageUtil.info("Aspect '" + name
                            + "' is scoped to apply against types matching pattern '"
                            + scopePattern.toString() + "'"));
                  }
                } catch (Exception e) {
                  // TODO definitions should remember which file they came from, for inclusion in this message
                  world.getMessageHandler().handleMessage(
                      MessageUtil.error("Unable to parse scope as type pattern.  Scope was '" + scope + "': "
                          + e.getMessage()));
                }
              }
            }
            try {
              List<String> includePatterns = definition.getIncludePatterns();
              if (includePatterns.size() > 0) {
                includedPatterns = new ArrayList<TypePattern>();
                includedFastMatchPatterns = new ArrayList<String>();
              }
              for (String includePattern : includePatterns) {
                if (includePattern.endsWith("..*")) {
                  // from 'blah.blah.blah..*' leave the 'blah.blah.blah.'
                  includedFastMatchPatterns.add(includePattern.substring(0, includePattern.length() - 2));
                } else {
                  TypePattern includedPattern = new PatternParser(includePattern).parseTypePattern();
                  includedPatterns.add(includedPattern);
                }
              }
              List<String> excludePatterns = definition.getExcludePatterns();
              if (excludePatterns.size() > 0) {
                excludedPatterns = new ArrayList<TypePattern>();
                excludedFastMatchPatterns = new ArrayList<String>();
              }
              for (String excludePattern : excludePatterns) {
                if (excludePattern.endsWith("..*")) {
                  // from 'blah.blah.blah..*' leave the 'blah.blah.blah.'
                  excludedFastMatchPatterns.add(excludePattern.substring(0, excludePattern.length() - 2));
                } else {
                  TypePattern excludedPattern = new PatternParser(excludePattern).parseTypePattern();
                  excludedPatterns.add(excludedPattern);
                }
              }
            } catch (ParserException pe) {
              // TODO definitions should remember which file they came from, for inclusion in this message
View Full Code Here

        Class inScope,
        PointcutParameter[] formalParameters)
    throws UnsupportedPointcutPrimitiveException, IllegalArgumentException {
       PointcutExpressionImpl pcExpr = null;
         try {
           PatternParser parser = new PatternParser(expression);
           parser.setPointcutDesignatorHandlers(pointcutDesignators, world);
             Pointcut pc = parser.parsePointcut();
             validateAgainstSupportedPrimitives(pc,expression);
             IScope resolutionScope = buildResolutionScope((inScope == null ? Object.class : inScope),formalParameters);
             pc = pc.resolve(resolutionScope);
             ResolvedType declaringTypeForResolution = null;
             if (inScope != null) {
View Full Code Here

     * be successfully parsed.
     */
    public TypePatternMatcher parseTypePattern(String typePattern)
    throws IllegalArgumentException {
        try {
          TypePattern tp = new PatternParser(typePattern).parseTypePattern();
          tp.resolve(world);
          return new TypePatternMatcherImpl(tp,world);
        } catch (ParserException pEx) {
            throw new IllegalArgumentException(buildUserMessageFromParserException(typePattern,pEx));
        } catch (ReflectionWorld.ReflectionWorldException rwEx) {
View Full Code Here

    sourceStart = tokens[0].sourceStart;
    sourceEnd = tokens[tokens.length-2].sourceEnd;
  }
 
  public Pointcut parsePointcut(Parser parser) {
    PatternParser patternParser = new PatternParser(tokenSource);
    try {
      Pointcut ret = patternParser.parsePointcut();
      checkEof(parser);
      return ret;
    } catch (ParserException pe) {
      reportError(parser, pe);
      return Pointcut.makeMatchesNothing(Pointcut.SYMBOLIC);
View Full Code Here

                                        new String[] {pe.getMessage()});
  }
 
 
  public TypePattern maybeParseDominatesPattern(Parser parser) {
    PatternParser patternParser = new PatternParser(tokenSource);
    try {
      if (patternParser.maybeEatIdentifier("dominates")) {
        // there is no eof check here
        return patternParser.parseTypePattern();
      } else {
        return null;
      }
    } catch (ParserException pe) {
      reportError(parser, pe);
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 aspectDecl = new 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) {
      typeDecl.scope.problemReporter().parseError(
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.