Package org.aspectj.asm

Examples of org.aspectj.asm.IProgramElement$Modifiers


  // return deowNode;
  // }

  private static IProgramElement createDeclareErrorOrWarningChild(AsmManager model, ResolvedType aspect,
      DeclareErrorOrWarning decl, int count) {
    IProgramElement deowNode = new ProgramElement(model, decl.getName(), decl.isError() ? IProgramElement.Kind.DECLARE_ERROR
        : IProgramElement.Kind.DECLARE_WARNING, getBinarySourceLocation(aspect, decl.getSourceLocation()), decl
        .getDeclaringType().getModifiers(), null, null);
    deowNode.setDetails("\"" + AsmRelationshipUtils.genDeclareMessage(decl.getMessage()) + "\"");
    if (count != -1) {
      deowNode.setBytecodeName(decl.getName() + "_" + count);
    }
    return deowNode;
  }
View Full Code Here


    }
    return deowNode;
  }

  private static IProgramElement createAdviceChild(AsmManager model, Advice advice) {
    IProgramElement adviceNode = new ProgramElement(model, advice.getKind().getName(), IProgramElement.Kind.ADVICE,
        advice.getBinarySourceLocation(advice.getSourceLocation()), advice.getSignature().getModifiers(), null,
        Collections.EMPTY_LIST);
    adviceNode.setDetails(AsmRelationshipUtils.genPointcutDetails(advice.getPointcut()));
    adviceNode.setBytecodeName(advice.getSignature().getName());
    return adviceNode;
  }
View Full Code Here

      // String name = rtMunger.getSignature().toString();
      String name = sig.getDeclaringType().getClassName() + "." + sig.getName();
      if (name.indexOf("$") != -1) {
        name = name.substring(name.indexOf("$") + 1);
      }
      IProgramElement pe = new ProgramElement(model, name, IProgramElement.Kind.INTER_TYPE_FIELD, getBinarySourceLocation(
          aspect, itd.getSourceLocation()), rtMunger.getSignature().getModifiers(), null, Collections.EMPTY_LIST);
      pe.setCorrespondingType(sig.getReturnType().getName());
      return pe;
    } else if (kind == ResolvedTypeMunger.Method) { // ITD
      // METHOD
      String name = sig.getDeclaringType().getClassName() + "." + sig.getName();
      if (name.indexOf("$") != -1) {
        name = name.substring(name.indexOf("$") + 1);
      }
      IProgramElement pe = new ProgramElement(model, name, IProgramElement.Kind.INTER_TYPE_METHOD, getBinarySourceLocation(
          aspect, itd.getSourceLocation()), rtMunger.getSignature().getModifiers(), null, Collections.EMPTY_LIST);
      setParams(pe, sig);
      return pe;
    } else if (kind == ResolvedTypeMunger.Constructor) {
      String name = sig.getDeclaringType().getClassName() + "." + sig.getDeclaringType().getClassName();
      if (name.indexOf("$") != -1) {
        name = name.substring(name.indexOf("$") + 1);
      }
      IProgramElement pe = new ProgramElement(model, name, IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR,
          getBinarySourceLocation(aspect, itd.getSourceLocation()), rtMunger.getSignature().getModifiers(), null,
          Collections.EMPTY_LIST);
      setParams(pe, sig);
      return pe;
      // } else if (kind == ResolvedTypeMunger.MethodDelegate2) {
View Full Code Here

    }
    pe.setCorrespondingType(sig.getReturnType().getName());
  }

  private static IProgramElement createDeclareParentsChild(AsmManager model, DeclareParents decp) {
    IProgramElement decpElement = new ProgramElement(model, "declare parents", IProgramElement.Kind.DECLARE_PARENTS,
        getBinarySourceLocation(decp.getDeclaringType(), decp.getSourceLocation()), Modifier.PUBLIC, null,
        Collections.EMPTY_LIST);
    return decpElement;
  }
View Full Code Here

  public static String getHandle(AsmManager asm, Advice advice) {
    if (null == advice.handle) {
      ISourceLocation sl = advice.getSourceLocation();
      if (sl != null) {
        IProgramElement ipe = asm.getHierarchy().findElementForSourceLine(sl);
        advice.handle = ipe.getHandleIdentifier();
      }
    }
    return advice.handle;
  }
View Full Code Here

      if (World.createInjarHierarchy) {
        createHierarchyForBinaryAspect(model, advice);
      }

      IRelationshipMap mapper = model.getRelationshipMap();
      IProgramElement targetNode = getNode(model, matchedShadow);
      if (targetNode == null) {
        return;
      }
      boolean runtimeTest = advice.hasDynamicTests();

      IProgramElement.ExtraInformation extra = new IProgramElement.ExtraInformation();

      String adviceHandle = getHandle(model, advice);
      if (adviceHandle == null) {
        return;
      }

      extra.setExtraAdviceInformation(advice.getKind().getName());
      IProgramElement adviceElement = model.getHierarchy().findElementForHandle(adviceHandle);
      if (adviceElement != null) {
        adviceElement.setExtraInfo(extra);
      }
      String targetHandle = targetNode.getHandleIdentifier();
      if (advice.getKind().equals(AdviceKind.Softener)) {
        IRelationship foreward = mapper.get(adviceHandle, IRelationship.Kind.DECLARE_SOFT, SOFTENS, runtimeTest, true);
        if (foreward != null) {
          foreward.addTarget(targetHandle);
        }

        IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE, SOFTENED_BY, runtimeTest, true);
        if (back != null) {
          back.addTarget(adviceHandle);
        }
      } else {
        IRelationship foreward = mapper.get(adviceHandle, IRelationship.Kind.ADVICE, ADVISES, runtimeTest, true);
        if (foreward != null) {
          foreward.addTarget(targetHandle);
        }

        IRelationship back = mapper.get(targetHandle, IRelationship.Kind.ADVICE, ADVISED_BY, runtimeTest, true);
        if (back != null) {
          back.addTarget(adviceHandle);
        }
      }
      if (adviceElement.getSourceLocation() != null) {
        model.addAspectInEffectThisBuild(adviceElement.getSourceLocation().getSourceFile());
      }
    }
  }
View Full Code Here

    // that shadow.getEnclosingCodeSignature() will return a member
    // representing the ITD as it will
    // appear in the target type. So here, we do an extra bit of analysis to
    // make sure we
    // do the right thing in the ITD case.
    IProgramElement enclosingNode = null;
    if (shadow instanceof BcelShadow) {
      Member actualEnclosingMember = ((BcelShadow) shadow).getRealEnclosingCodeSignature();

      if (actualEnclosingMember == null) {
        enclosingNode = lookupMember(model.getHierarchy(), shadow.getEnclosingType(), enclosingMember);
      } else {
        UnresolvedType type = enclosingMember.getDeclaringType();
        UnresolvedType actualType = actualEnclosingMember.getDeclaringType();

        // if these are not the same, it is an ITD and we need to use
        // the latter to lookup
        if (type.equals(actualType)) {
          enclosingNode = lookupMember(model.getHierarchy(), shadow.getEnclosingType(), enclosingMember);
        } else {
          enclosingNode = lookupMember(model.getHierarchy(), shadow.getEnclosingType(), actualEnclosingMember);
        }
      }
    } else {
      enclosingNode = lookupMember(model.getHierarchy(), shadow.getEnclosingType(), enclosingMember);
    }

    if (enclosingNode == null) {
      Lint.Kind err = shadow.getIWorld().getLint().shadowNotInStructure;
      if (err.isEnabled()) {
        err.signal(shadow.toString(), shadow.getSourceLocation());
      }
      return null;
    }

    Member shadowSig = shadow.getSignature();
    // pr235204
    if (shadow.getKind() == Shadow.MethodCall || shadow.getKind() == Shadow.ConstructorCall
        || !shadowSig.equals(enclosingMember)) {
      IProgramElement bodyNode = findOrCreateCodeNode(model, enclosingNode, shadowSig, shadow);
      return bodyNode;
    } else {
      return enclosingNode;
    }
  }
View Full Code Here

   * Moreover, if the body of the enclosingShadow is changed, then the model for this is rebuilt from scratch.
   */
  private static IProgramElement findOrCreateCodeNode(AsmManager asm, IProgramElement enclosingNode, Member shadowSig,
      Shadow shadow) {
    for (Iterator it = enclosingNode.getChildren().iterator(); it.hasNext();) {
      IProgramElement node = (IProgramElement) it.next();
      int excl = node.getBytecodeName().lastIndexOf('!');
      if (((excl != -1 && shadowSig.getName().equals(node.getBytecodeName().substring(0, excl))) || shadowSig.getName()
          .equals(node.getBytecodeName()))
          && shadowSig.getSignature().equals(node.getBytecodeSignature())
          && sourceLinesMatch(node.getSourceLocation(), shadow.getSourceLocation())) {
        return node;
      }
    }

    ISourceLocation sl = shadow.getSourceLocation();

    // XXX why not use shadow file? new SourceLocation(sl.getSourceFile(),
    // sl.getLine()),
    SourceLocation peLoc = new SourceLocation(enclosingNode.getSourceLocation().getSourceFile(), sl.getLine());
    peLoc.setOffset(sl.getOffset());
    IProgramElement peNode = new ProgramElement(asm, shadow.toString(), IProgramElement.Kind.CODE, peLoc, 0, null, null);

    // check to see if the enclosing shadow already has children with the
    // same name. If so we want to add a counter to the byteCodeName
    // otherwise
    // we wont get unique handles
    int numberOfChildrenWithThisName = 0;
    for (Iterator it = enclosingNode.getChildren().iterator(); it.hasNext();) {
      IProgramElement child = (IProgramElement) it.next();
      if (child.getName().equals(shadow.toString())) {
        numberOfChildrenWithThisName++;
      }
    }
    peNode.setBytecodeName(shadowSig.getName() + "!" + String.valueOf(numberOfChildrenWithThisName + 1));
    peNode.setBytecodeSignature(shadowSig.getSignature());
View Full Code Here

    enclosingNode.addChild(peNode);
    return peNode;
  }

  private static IProgramElement lookupMember(IHierarchy model, UnresolvedType declaringType, Member member) {
    IProgramElement typeElement = model.findElementForType(declaringType.getPackageName(), declaringType.getClassName());
    if (typeElement == null) {
      return null;
    }
    for (Iterator it = typeElement.getChildren().iterator(); it.hasNext();) {
      IProgramElement element = (IProgramElement) it.next();
      if (member.getName().equals(element.getBytecodeName()) && member.getSignature().equals(element.getBytecodeSignature())) {
        return element;
      }
    }
    // if we can't find the member, we'll just put it in the class
    return typeElement;
View Full Code Here

      type = affectedTypeName.substring(packageSeparator + 1);
    }

    IHierarchy hierarchy = model.getHierarchy();

    IProgramElement typeElem = hierarchy.findElementForType(pkg, type);
    if (typeElem == null) {
      return;
    }

    StringBuffer parmString = new StringBuffer("(");
    UnresolvedType[] args = affectedMethod.getParameterTypes();
    // Type[] args = method.getArgumentTypes();
    for (int i = 0; i < args.length; i++) {
      String s = args[i].getName();// Utility.signatureToString(args[i].
      // getName()getSignature(), false);
      parmString.append(s);
      if ((i + 1) < args.length) {
        parmString.append(",");
      }
    }
    parmString.append(")");
    IProgramElement methodElem = null;

    if (affectedMethod.getName().startsWith("<init>")) {
      // its a ctor
      methodElem = hierarchy.findElementForSignature(typeElem, IProgramElement.Kind.CONSTRUCTOR, type + parmString);
      if (methodElem == null && args.length == 0) {
        methodElem = typeElem; // assume default ctor
      }
    } else {
      // its a method
      methodElem = hierarchy.findElementForSignature(typeElem, IProgramElement.Kind.METHOD, affectedMethod.getName()
          + parmString);
    }

    if (methodElem == null) {
      return;
    }

    try {
      String targetHandle = methodElem.getHandleIdentifier();
      if (targetHandle == null) {
        return;
      }

      IProgramElement sourceNode = hierarchy.findElementForSourceLine(sourceLocation);
      String sourceHandle = sourceNode.getHandleIdentifier();
      if (sourceHandle == null) {
        return;
      }

      IRelationshipMap mapper = model.getRelationshipMap();
View Full Code Here

TOP

Related Classes of org.aspectj.asm.IProgramElement$Modifiers

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.