Package org.aspectj.weaver.patterns

Examples of org.aspectj.weaver.patterns.PatternParser


    EclipseSourceContext eSourceContext = new EclipseSourceContext(md.compilationResult);
    Pointcut pc = null;
    if (!md.isAbstract()) {
      String expression = getPointcutStringFromAnnotationStylePointcut(md);
      try {
        pc = new PatternParser(expression, eSourceContext).parsePointcut();
      } catch (ParserException pe) { // error will be reported by other
        // means...
        pc = Pointcut.makeMatchesNothing(Pointcut.SYMBOLIC);
      }
    }
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

    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

  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

        } else if (include.equals("*")) {
          includeStar = true;
        } else if ((fastMatchInfo = looksLikeExactName(include)) != null) {
          includeExactName.add(fastMatchInfo);
        } else {
          TypePattern includePattern = new PatternParser(include).parseTypePattern();
          includeTypePattern.add(includePattern);
        }
      }
      for (Iterator iterator1 = definition.getExcludePatterns().iterator(); iterator1.hasNext();) {
        hasExcludes = true;
        String exclude = (String) iterator1.next();
        fastMatchInfo = looksLikeStartsWith(exclude);
        if (fastMatchInfo != null) {
          excludeStartsWith.add(fastMatchInfo);
        } else if ((fastMatchInfo = looksLikeStarDotDotStarExclude(exclude)) != null) {
          excludeStarDotDotStar.add(fastMatchInfo);
        } else if ((fastMatchInfo = looksLikeExactName(exclude)) != null) {
          excludeExactName.add(exclude);
        } else if ((fastMatchInfo = looksLikeEndsWith(exclude)) != null) {
          excludeEndsWith.add(fastMatchInfo);
        } else if (exclude
            .equals("org.codehaus.groovy..* && !org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsController*")) {
          // TODO need a more sophisticated analysis here, to allow for similar situations
          excludeSpecial.add(new String[] { "org.codehaus.groovy.",
              "org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsController" });
          // for the related test:
          // } else if (exclude.equals("testdata..* && !testdata.sub.Oran*")) {
          // excludeSpecial.add(new String[] { "testdata.", "testdata.sub.Oran" });
        } else {
          TypePattern excludePattern = new PatternParser(exclude).parseTypePattern();
          excludeTypePattern.add(excludePattern);
        }
      }
    }
  }
View Full Code Here

  private void registerDump(final BcelWeaver weaver, final ClassLoader loader, final List definitions) {
    for (Iterator iterator = definitions.iterator(); iterator.hasNext();) {
      Definition definition = (Definition) iterator.next();
      for (Iterator iterator1 = definition.getDumpPatterns().iterator(); iterator1.hasNext();) {
        String dump = (String) iterator1.next();
        TypePattern pattern = new PatternParser(dump).parseTypePattern();
        m_dumpTypePattern.add(pattern);
      }
      if (definition.shouldDumpBefore()) {
        m_dumpBefore = true;
      }
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.