Package org.aspectj.asm

Examples of org.aspectj.asm.IProgramElement$Accessibility


    if (initializer == inInitializer) {
      return false;
    }
    inInitializer = initializer;

    IProgramElement peNode = new ProgramElement(activeStructureModel, "...", IProgramElement.Kind.INITIALIZER,
        makeLocation(initializer), initializer.modifiers, null, null);
    // "",
    // new ArrayList());
    ((IProgramElement) stack.peek()).addChild(peNode);
    stack.push(peNode);
View Full Code Here


   * @param struct
   */
  private static void setDeclareErrorOrWarningLocation(AsmManager model, DeclareErrorOrWarning deow, AjAttributeFieldStruct struct) {
    IHierarchy top = (model == null ? null : model.getHierarchy());
    if (top != null && top.getRoot() != null) {
      IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.FIELD, struct.field.getName());
      if (ipe != null && ipe.getSourceLocation() != null) {
        ISourceLocation sourceLocation = ipe.getSourceLocation();
        int start = sourceLocation.getOffset();
        int end = start + struct.field.getName().length();
        deow.setLocation(struct.context, start, end);
        return;
      }
View Full Code Here

            // Might be the case the declaring aspect is generic and thisAspect is parameterizing it. In that case
            // record the actual parameterizations

            ResolvedType target = weaver.getLazyClassGen().getType();
            ResolvedType newParent = nptMunger.getNewParent();
            IProgramElement thisAspectNode = model.getHierarchy().findElementForType(thisAspect.getPackageName(),
                thisAspect.getClassName());
            Map<String, List<String>> declareParentsMap = thisAspectNode.getDeclareParentsMap();
            if (declareParentsMap == null) {
              declareParentsMap = new HashMap<String, List<String>>();
              thisAspectNode.setDeclareParentsMap(declareParentsMap);
            }
            String tname = target.getName();
            String pname = newParent.getName();
            List<String> newparents = declareParentsMap.get(tname);
            if (newparents == null) {
View Full Code Here

      AsmManager model = world.getModelAsAsmManager();
      if (world.isMinimalModel() && model != null && !classType.isAspect()) {
        AspectJElementHierarchy hierarchy = (AspectJElementHierarchy) model.getHierarchy();
        String pkgname = classType.getResolvedTypeX().getPackageName();
        String tname = classType.getResolvedTypeX().getSimpleBaseName();
        IProgramElement typeElement = hierarchy.findElementForType(pkgname, tname);
        if (typeElement != null && hasInnerType(typeElement)) {
          // Cannot remove it right now (has inner type), schedule it
          // for possible deletion later if all inner types are
          // removed
          candidatesForRemoval.add(typeElement);
        }
        if (typeElement != null && !hasInnerType(typeElement)) {
          IProgramElement parent = typeElement.getParent();
          // parent may have children: PACKAGE DECL, IMPORT-REFERENCE, TYPE_DECL
          if (parent != null) {
            // if it was the only type we should probably remove
            // the others too.
            parent.removeChild(typeElement);
            if (parent.getKind().isSourceFile()) {
              removeSourceFileIfNoMoreTypeDeclarationsInside(hierarchy, typeElement, parent);
            } else {
              hierarchy.forget(null, typeElement);
              // At this point, the child has been removed. We
              // should now check if the parent is in our
View Full Code Here

    }
    // now typeThatHasChildRemoved points to the type or sourcefile that has
    // had something removed
    if (candidatesForRemoval.contains(typeThatHasChildRemoved) && !hasInnerType(typeThatHasChildRemoved)) {
      // now we can get rid of it
      IProgramElement parent = typeThatHasChildRemoved.getParent();
      if (parent != null) {
        parent.removeChild(typeThatHasChildRemoved);
        candidatesForRemoval.remove(typeThatHasChildRemoved);
        if (parent.getKind().isSourceFile()) {
          removeSourceFileIfNoMoreTypeDeclarationsInside(hierarchy, typeThatHasChildRemoved, parent);
          // System.out.println("Removed on second pass: " +
          // typeThatHasChildRemoved.getName());
        } else {
          // System.out.println("On later pass, parent of type " +
View Full Code Here

    }
  }

  private void removeSourceFileIfNoMoreTypeDeclarationsInside(AspectJElementHierarchy hierarchy, IProgramElement typeElement,
      IProgramElement sourceFileNode) {
    IProgramElement compilationUnit = sourceFileNode;
    boolean anyOtherTypeDeclarations = false;
    for (IProgramElement child : compilationUnit.getChildren()) {
      IProgramElement.Kind k = child.getKind();
      if (k.isType()) {
        anyOtherTypeDeclarations = true;
        break;
      }
    }
    // If the compilation unit node contained no
    // other types, there is no need to keep it
    if (!anyOtherTypeDeclarations) {
      IProgramElement cuParent = compilationUnit.getParent();
      if (cuParent != null) {
        compilationUnit.setParent(null);
        cuParent.removeChild(compilationUnit);
      }
      // need to update some caches and structures too?
      hierarchy.forget(sourceFileNode, typeElement);
    } else {
      hierarchy.forget(null, typeElement);
View Full Code Here

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

    IProgramElement targetNode = getNode(model, affectedShadow);
    if (targetNode == null) {
      return;
    }
    String targetHandle = targetNode.getHandleIdentifier();
    if (targetHandle == null) {
      return;
    }

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

    IRelationshipMap relmap = model.getRelationshipMap();
    IRelationship foreward = relmap.get(sourceHandle, IRelationship.Kind.DECLARE, MATCHED_BY, false, true);
    foreward.addTarget(targetHandle);

    IRelationship back = relmap.get(targetHandle, IRelationship.Kind.DECLARE, MATCHES_DECLARE, false, true);
    if (back != null && back.getTargets() != null) {
      back.addTarget(sourceHandle);
    }
    if (sourceNode.getSourceLocation() != null) {
      model.addAspectInEffectThisBuild(sourceNode.getSourceLocation().getSourceFile());
    }
  }
View Full Code Here

      createHierarchy(model, typeTransformer, originatingAspect);
    }

    if (originatingAspect.getSourceLocation() != null) {
      String sourceHandle = "";
      IProgramElement sourceNode = null;
      if (typeTransformer.getSourceLocation() != null && typeTransformer.getSourceLocation().getOffset() != -1
          && !isMixinRelated(typeTransformer)) {
        sourceNode = model.getHierarchy().findElementForType(originatingAspect.getPackageName(),
            originatingAspect.getClassName());
        IProgramElement closer = model.getHierarchy().findCloserMatchForLineNumber(sourceNode,
            typeTransformer.getSourceLocation().getLine());
        if (closer != null) {
          sourceNode = closer;
        }
        if (sourceNode == null) {
          // This can be caused by the aspect defining the type munger actually being on the classpath and not the
          // inpath or aspectpath. Rather than NPE at the next line, let's have another go at faulting it in.
          // This inner loop is a small duplicate of the outer loop that attempts to find something closer than
          // the type declaration
          if (World.createInjarHierarchy) {
            createHierarchy(model, typeTransformer, originatingAspect);
            if (typeTransformer.getSourceLocation() != null && typeTransformer.getSourceLocation().getOffset() != -1
                && !isMixinRelated(typeTransformer)) {
              sourceNode = model.getHierarchy().findElementForType(originatingAspect.getPackageName(),
                  originatingAspect.getClassName());
              IProgramElement closer2 = model.getHierarchy().findCloserMatchForLineNumber(sourceNode,
                  typeTransformer.getSourceLocation().getLine());
              if (closer2 != null) {
                sourceNode = closer2;
              }
            } else {
View Full Code Here

    IHierarchy hierarchy = model.getHierarchy();
    ISourceLocation sourceLocation = onType.getSourceLocation();
    String canonicalFilePath = model.getCanonicalFilePath(sourceLocation.getSourceFile());
    int lineNumber = sourceLocation.getLine();
    // Find the relevant source file node first
    IProgramElement node = hierarchy.findNodeForSourceFile(hierarchy.getRoot(), canonicalFilePath);
    if (node == null) {
      // Does not exist in the model - probably an inpath
      String bpath = onType.getBinaryPath();
      if (bpath == null) {
        return model.getHandleProvider().createHandleIdentifier(createFileStructureNode(model, canonicalFilePath));
      } else {
        IProgramElement programElement = model.getHierarchy().getRoot();
        // =Foo/,<g(G.class[G
        StringBuffer phantomHandle = new StringBuffer();

        // =Foo
        phantomHandle.append(programElement.getHandleIdentifier());

        // /, - the comma is a 'well defined char' that means inpath
        phantomHandle.append(HandleProviderDelimiter.PACKAGEFRAGMENTROOT.getDelimiter()).append(
            HandleProviderDelimiter.PHANTOM.getDelimiter());

        int pos = bpath.indexOf('!');
        if (pos != -1) {
          // jar or dir
          String jarPath = bpath.substring(0, pos);
          String element = model.getHandleElementForInpath(jarPath);
          if (element != null) {
            phantomHandle.append(element);
          }
        }

        // <g
        String packageName = onType.getPackageName();
        phantomHandle.append(HandleProviderDelimiter.PACKAGEFRAGMENT.getDelimiter()).append(packageName);

        // (G.class
        // could fix the binary path to only be blah.class bit
        int dotClassPosition = bpath.lastIndexOf(".class");// what to do if -1
        if (dotClassPosition == -1) {
          phantomHandle.append(HandleProviderDelimiter.CLASSFILE.getDelimiter()).append("UNKNOWN.class");
        } else {
          int startPosition = dotClassPosition;
          char ch;
          while (startPosition > 0 && ((ch = bpath.charAt(startPosition)) != '/' && ch != '\\' && ch != '!')) {
            startPosition--;
          }
          String classFile = bpath.substring(startPosition + 1, dotClassPosition + 6);
          phantomHandle.append(HandleProviderDelimiter.CLASSFILE.getDelimiter()).append(classFile);
        }

        // [G
        phantomHandle.append(HandleProviderDelimiter.TYPE.getDelimiter()).append(onType.getClassName());

        return phantomHandle.toString();
      }
    } else {
      // Check if there is a more accurate child node of that source file node:
      IProgramElement closernode = hierarchy.findCloserMatchForLineNumber(node, lineNumber);
      if (closernode == null) {
        return node.getHandleIdentifier();
      } else {
        return closernode.getHandleIdentifier();
      }
    }

  }
View Full Code Here

    if (i > lastSlash && i != -1 && j != -1) {
      // we are a binary aspect in the default package
      lastSlash = i;
    }
    String fileName = sourceFilePath.substring(lastSlash + 1);
    IProgramElement fileNode = new ProgramElement(asm, fileName, IProgramElement.Kind.FILE_JAVA, new SourceLocation(new File(
        sourceFilePath), 1, 1), 0, null, null);
    // fileNode.setSourceLocation();
    fileNode.addChild(IHierarchy.NO_STRUCTURE);
    return fileNode;
  }
View Full Code Here

TOP

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

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.