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 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

    return pcExpr;
  }

  protected Pointcut resolvePointcutExpression(String expression, Class<?> inScope, PointcutParameter[] formalParameters) {
    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);
      return pc;
    } catch (ParserException pEx) {
View Full Code Here

   * @return a type pattern matcher that matches using the given pattern
   * @throws IllegalArgumentException if the type pattern cannot 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

    return pcExpr;
  }

  protected Pointcut resolvePointcutExpression(String expression, Class inScope, PointcutParameter[] formalParameters) {
    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);
      return pc;
    } catch (ParserException pEx) {
View Full Code Here

   * @return a type pattern matcher that matches using the given pattern
   * @throws IllegalArgumentException if the type pattern cannot 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

  private void registerAspectExclude(final BcelWeaver weaver, final ClassLoader loader, final List<Definition> definitions) {
    String fastMatchInfo = null;
    for (Definition definition : definitions) {
      for (String exclude : definition.getAspectExcludePatterns()) {
        TypePattern excludePattern = new PatternParser(exclude).parseTypePattern();
        m_aspectExcludeTypePattern.add(excludePattern);
        fastMatchInfo = looksLikeStartsWith(exclude);
        if (fastMatchInfo != null) {
          m_aspectExcludeStartsWith.add(fastMatchInfo);
        }
View Full Code Here

  private void registerAspectInclude(final BcelWeaver weaver, final ClassLoader loader, final List<Definition> definitions) {
    String fastMatchInfo = null;
    for (Definition definition : definitions) {
      for (String include : definition.getAspectIncludePatterns()) {
        TypePattern includePattern = new PatternParser(include).parseTypePattern();
        m_aspectIncludeTypePattern.add(includePattern);
        fastMatchInfo = looksLikeStartsWith(include);
        if (fastMatchInfo != null) {
          m_aspectIncludeStartsWith.add(fastMatchInfo);
        }
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.