Examples of TypePattern


Examples of org.aspectj.weaver.patterns.TypePattern

  /**
   * All overriding methods should call super
   */
  public boolean match(Shadow shadow, World world) {
    if (world.isXmlConfigured() && world.isAspectIncluded(declaringType)) {
      TypePattern scoped = world.getAspectScope(declaringType);
      if (scoped != null) {
        // Check the 'cached' exclusion map
        Set<ResolvedType> excludedTypes = world.getExclusionMap().get(declaringType);
        ResolvedType type = shadow.getEnclosingType().resolve(world);
        if (excludedTypes != null && excludedTypes.contains(type)) {
          return false;
        }
        boolean b = scoped.matches(type, TypePattern.STATIC).alwaysTrue();
        if (!b) {
          if (!world.getMessageHandler().isIgnoring(IMessage.INFO)) {
            world.getMessageHandler().handleMessage(
                MessageUtil.info("Type '" + type.getName() + "' not woven by aspect '" + declaringType.getName()
                    + "' due to scope exclusion in XML definition"));
View Full Code Here

Examples of org.aspectj.weaver.patterns.TypePattern

        String kindOfDP = null;
        StringBuffer details = new StringBuffer("");
        TypePattern[] newParents = dp.getParents().getTypePatterns();
        for (int i = 0; i < newParents.length; i++) {
          TypePattern tp = newParents[i];
          UnresolvedType tx = tp.getExactType();
          if (kindOfDP == null) {
            kindOfDP = "implements ";
            try {
              ResolvedType rtx = tx.resolve(((AjLookupEnvironment) declare.scope.environment()).factory.getWorld());
              if (!rtx.isInterface()) {
                kindOfDP = "extends ";
              }
            } catch (Throwable t) {
              // What can go wrong???? who knows!
            }

          }
          String typename = tp.toString();
          if (typename.lastIndexOf(".") != -1) {
            typename = typename.substring(typename.lastIndexOf(".") + 1);
          }
          details.append(typename);
          if ((i + 1) < newParents.length) {
View Full Code Here

Examples of org.aspectj.weaver.patterns.TypePattern

    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 '"
                  + scopePattern.toString() + "'"));
        }
      } catch (Exception e) {
        world.getMessageHandler().handleMessage(
            MessageUtil.error("Unable to parse scope as type pattern.  Scope was '" + scope + "': " + e.getMessage()));
      }
View Full Code Here

Examples of org.aspectj.weaver.patterns.TypePattern

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

Examples of org.aspectj.weaver.patterns.TypePattern

  public org.aspectj.org.eclipse.jdt.core.dom.PatternNode convert(
      PatternNode patternNode) {
    org.aspectj.org.eclipse.jdt.core.dom.PatternNode pNode = null;
    if (patternNode instanceof TypePattern) {
      TypePattern weaverTypePattern = (TypePattern) patternNode;
      return convert(weaverTypePattern);

    } else if (patternNode instanceof SignaturePattern) {
      SignaturePattern sigPat = (SignaturePattern) patternNode;
      pNode = new org.aspectj.org.eclipse.jdt.core.dom.SignaturePattern(this.ast, sigPat.toString());
View Full Code Here

Examples of org.aspectj.weaver.patterns.TypePattern

            convert(compilerAndType.getRight()));
      } else if (weaverNode instanceof org.aspectj.weaver.patterns.NotTypePattern) {
        //NOTE: the source range for not type patterns is the source range of the negated type pattern
        // EXCLUDING the "!" character. Example: !A. If A starts at 1, the source starting point for the
        // nottypepattern is 1, NOT 0.
        TypePattern negatedTypePattern = ((org.aspectj.weaver.patterns.NotTypePattern) weaverNode)
            .getNegatedPattern();
        org.aspectj.org.eclipse.jdt.core.dom.TypePattern negatedDomTypePattern = convert(negatedTypePattern);
        domNode = new org.aspectj.org.eclipse.jdt.core.dom.NotTypePattern(
            ast, negatedDomTypePattern);
      } else if (weaverNode instanceof org.aspectj.weaver.patterns.TypeCategoryTypePattern) {
View Full Code Here

Examples of org.aspectj.weaver.patterns.TypePattern

  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

Examples of org.aspectj.weaver.patterns.TypePattern

  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

Examples of org.aspectj.weaver.patterns.TypePattern

        } 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

Examples of org.aspectj.weaver.patterns.TypePattern

  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
TOP
Copyright © 2018 www.massapi.com. 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.