Package org.aspectj.asm

Examples of org.aspectj.asm.IProgramElement$ExtraInformation


    // Check if already defined in the model
    // IProgramElement filenode =
    // model.getHierarchy().findElementForType(aspect.getPackageName(),
    // aspect.getClassName());
    // SourceLine(typeTransformer.getSourceLocation());
    IProgramElement filenode = model.getHierarchy().findElementForSourceLine(typeTransformer.getSourceLocation());
    if (filenode == null) {
      if (typeTransformer.getKind() == ResolvedTypeMunger.MethodDelegate2
          || typeTransformer.getKind() == ResolvedTypeMunger.FieldHost) {
        // not yet faulting these in
        return;
      }
    }
    // the call to findElementForSourceLine(ISourceLocation) returns a file
    // node
    // if it can't find a node in the hierarchy for the given
    // sourcelocation.
    // Therefore, if this is returned, we know we can't find one and have to
    // // continue to fault in the model.
    // if (filenode != null) { //
    if (!filenode.getKind().equals(IProgramElement.Kind.FILE_JAVA)) {
      return;
    }

    // create the class file node
    ISourceLocation binLocation = getBinarySourceLocation(aspect, aspect.getSourceLocation());
    String f = getBinaryFile(aspect).getName();
    IProgramElement classFileNode = new ProgramElement(model, f, IProgramElement.Kind.FILE, binLocation, 0, null, null);

    // create package ipe if one exists....
    IProgramElement root = model.getHierarchy().getRoot();
    IProgramElement binaries = model.getHierarchy().findElementForLabel(root, IProgramElement.Kind.SOURCE_FOLDER, "binaries");
    if (binaries == null) {
      binaries = new ProgramElement(model, "binaries", IProgramElement.Kind.SOURCE_FOLDER, new ArrayList<IProgramElement>());
      root.addChild(binaries);
    }
    // if (aspect.getPackageName() != null) {
    String packagename = aspect.getPackageName() == null ? "" : aspect.getPackageName();
    // check that there doesn't already exist a node with this name
    IProgramElement pkgNode = model.getHierarchy().findElementForLabel(binaries, IProgramElement.Kind.PACKAGE, packagename);
    // note packages themselves have no source location
    if (pkgNode == null) {
      pkgNode = new ProgramElement(model, packagename, IProgramElement.Kind.PACKAGE, new ArrayList<IProgramElement>());
      binaries.addChild(pkgNode);
      pkgNode.addChild(classFileNode);
    } else {
      // need to add it first otherwise the handle for classFileNode
      // may not be generated correctly if it uses information from
      // it's parent node
      pkgNode.addChild(classFileNode);
      for (IProgramElement element: pkgNode.getChildren()) {
        if (!element.equals(classFileNode) && element.getHandleIdentifier().equals(classFileNode.getHandleIdentifier())) {
          // already added the classfile so have already
          // added the structure for this aspect
          pkgNode.removeChild(classFileNode);
          return;
        }
      }
    }
    // } else {
    // // need to add it first otherwise the handle for classFileNode
    // // may not be generated correctly if it uses information from
    // // it's parent node
    // root.addChild(classFileNode);
    // for (Iterator iter = root.getChildren().iterator(); iter.hasNext();)
    // {
    // IProgramElement element = (IProgramElement) iter.next();
    // if (!element.equals(classFileNode) &&
    // element.getHandleIdentifier().equals
    // (classFileNode.getHandleIdentifier())) {
    // // already added the sourcefile so have already
    // // added the structure for this aspect
    // root.removeChild(classFileNode);
    // return;
    // }
    // }
    // }

    // add and create empty import declaration ipe
    // no import container for binary type - 265693
    // classFileNode.addChild(new ProgramElement(model, "import declarations", IProgramElement.Kind.IMPORT_REFERENCE, null, 0,
    // null, null));

    // add and create aspect ipe
    IProgramElement aspectNode = new ProgramElement(model, aspect.getSimpleName(), IProgramElement.Kind.ASPECT,
        getBinarySourceLocation(aspect, aspect.getSourceLocation()), aspect.getModifiers(), null, null);
    classFileNode.addChild(aspectNode);

    addChildNodes(model, aspect, aspectNode, aspect.getDeclaredPointcuts());
View Full Code Here


      ISourceLocation annotatedLocation, boolean isRemove) {
    if (model == null) {
      return;
    }

    IProgramElement sourceNode = model.getHierarchy().findElementForSourceLine(declareAnnotationLocation);
    String sourceHandle = sourceNode.getHandleIdentifier();
    if (sourceHandle == null) {
      return;
    }

    IProgramElement targetNode = model.getHierarchy().findElementForSourceLine(annotatedLocation);
    String targetHandle = targetNode.getHandleIdentifier();
    if (targetHandle == null) {
      return;
    }

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

  public static void createHierarchyForBinaryAspect(AsmManager asm, ShadowMunger munger) {
    if (!munger.isBinary()) {
      return;
    }

    IProgramElement sourceFileNode = asm.getHierarchy().findElementForSourceLine(munger.getSourceLocation());
    // the call to findElementForSourceLine(ISourceLocation) returns a file
    // node if it can't find a node in the hierarchy for the given sourcelocation.
    // Therefore, if this is returned, we know we can't find one and have to
    // continue to fault in the model.
    if (!sourceFileNode.getKind().equals(IProgramElement.Kind.FILE_JAVA)) {
      return;
    }

    ResolvedType aspect = munger.getDeclaringType();

    // create the class file node
    IProgramElement classFileNode = new ProgramElement(asm, sourceFileNode.getName(), IProgramElement.Kind.FILE,
        munger.getBinarySourceLocation(aspect.getSourceLocation()), 0, null, null);

    // create package ipe if one exists....
    IProgramElement root = asm.getHierarchy().getRoot();
    IProgramElement binaries = asm.getHierarchy().findElementForLabel(root, IProgramElement.Kind.SOURCE_FOLDER, "binaries");
    if (binaries == null) {
      binaries = new ProgramElement(asm, "binaries", IProgramElement.Kind.SOURCE_FOLDER, new ArrayList<IProgramElement>());
      root.addChild(binaries);
    }
    // if (aspect.getPackageName() != null) {
    String packagename = aspect.getPackageName() == null ? "" : aspect.getPackageName();
    // check that there doesn't already exist a node with this name
    IProgramElement pkgNode = asm.getHierarchy().findElementForLabel(binaries, IProgramElement.Kind.PACKAGE, packagename);
    // note packages themselves have no source location
    if (pkgNode == null) {
      pkgNode = new ProgramElement(asm, packagename, IProgramElement.Kind.PACKAGE, new ArrayList<IProgramElement>());
      binaries.addChild(pkgNode);
      pkgNode.addChild(classFileNode);
    } else {
      // need to add it first otherwise the handle for classFileNode
      // may not be generated correctly if it uses information from
      // it's parent node
      pkgNode.addChild(classFileNode);
      for (IProgramElement element: pkgNode.getChildren()) {
        if (!element.equals(classFileNode) && element.getHandleIdentifier().equals(classFileNode.getHandleIdentifier())) {
          // already added the classfile so have already
          // added the structure for this aspect
          pkgNode.removeChild(classFileNode);
          return;
        }
      }
    }
    // } else {
    // // need to add it first otherwise the handle for classFileNode
    // // may not be generated correctly if it uses information from
    // // it's parent node
    // root.addChild(classFileNode);
    // for (Iterator iter = root.getChildren().iterator(); iter.hasNext();)
    // {
    // IProgramElement element = (IProgramElement) iter.next();
    // if (!element.equals(classFileNode) &&
    // element.getHandleIdentifier().equals
    // (classFileNode.getHandleIdentifier())) {
    // // already added the sourcefile so have already
    // // added the structure for this aspect
    // root.removeChild(classFileNode);
    // return;
    // }
    // }
    // }

    // add and create empty import declaration ipe
    // classFileNode.addChild(new ProgramElement(asm, "import declarations", IProgramElement.Kind.IMPORT_REFERENCE, null, 0,
    // null,
    // null));

    // add and create aspect ipe
    IProgramElement aspectNode = new ProgramElement(asm, aspect.getSimpleName(), IProgramElement.Kind.ASPECT,
        munger.getBinarySourceLocation(aspect.getSourceLocation()), aspect.getModifiers(), null, null);
    classFileNode.addChild(aspectNode);

    String sourcefilename = getSourceFileName(aspect);
    addPointcuts(asm, sourcefilename, aspect, aspectNode, aspect.getDeclaredPointcuts());
View Full Code Here

        Advice advice = (Advice) element;
        parent.addChild(createAdviceChild(asm, advice));
      } else if (element instanceof DeclareParents) {
        parent.addChild(createDeclareParentsChild(asm, (DeclareParents) element));
      } else if (element instanceof BcelTypeMunger) {
        IProgramElement newChild = createIntertypeDeclaredChild(asm, aspect, (BcelTypeMunger) element);
        // newChild==null means it is something that could not be handled by createIntertypeDeclaredChild()
        if (newChild != null) {
          parent.addChild(newChild);
        }
      }
View Full Code Here

  // 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.<IProgramElement>emptyList());
    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.<IProgramElement>emptyList());
      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.<IProgramElement>emptyList());
      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.<IProgramElement>emptyList());
      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.<IProgramElement>emptyList());
    setParentTypesOnDeclareParentsNode(decp, decpElement);
    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

TOP

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

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.