Package org.aspectj.asm

Examples of org.aspectj.asm.IHierarchy


      }
    }
  }

  private static String findOrFakeUpNode(AsmManager model, ResolvedType onType) {
    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 (packageSeparator != -1) {
      pkg = affectedTypeName.substring(0, packageSeparator);
      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;
      }
View Full Code Here

    int packageSeparator = affectedTypeName.lastIndexOf(".");
    if (packageSeparator != -1) {
      pkg = affectedTypeName.substring(0, packageSeparator);
      type = affectedTypeName.substring(packageSeparator + 1);
    }
    IHierarchy hierarchy = model.getHierarchy();
    IProgramElement typeElem = hierarchy.findElementForType(pkg, type);
    if (typeElem == null) {
      return;
    }

    IProgramElement fieldElem = hierarchy.findElementForSignature(typeElem, IProgramElement.Kind.FIELD, affectedFieldName
        .getName());
    if (fieldElem == null) {
      return;
    }

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

    IProgramElement sourceNode = hierarchy.findElementForSourceLine(declareLocation);
    String sourceHandle = sourceNode.getHandleIdentifier();
    if (sourceHandle == null) {
      return;
    }
View Full Code Here

   *
   * @param deow
   * @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);
View Full Code Here

       AsmManager.setCreatingModel(config.isEmacsSymMode() || config.isGenerateModelMode());
       if (!AsmManager.isCreatingModel()) return;

    AsmManager.getDefault().createNewASM();
    // AsmManager.getDefault().getRelationshipMap().clear();
    IHierarchy model = AsmManager.getDefault().getHierarchy();
        String rootLabel = "<root>";
         
   
        IProgramElement.Kind kind = IProgramElement.Kind.FILE_JAVA;
        if (buildConfig.getConfigFile() != null) {
             rootLabel = buildConfig.getConfigFile().getName();
             model.setConfigFile(buildConfig.getConfigFile().getAbsolutePath());
             kind = IProgramElement.Kind.FILE_LST; 
        }
        model.setRoot(new ProgramElement(rootLabel, kind, new ArrayList()));
               
        model.setFileMap(new HashMap());
        setStructureModel(model);
    state.setStructureModel(model);
    state.setRelationshipMap(AsmManager.getDefault().getRelationshipMap());
    }
View Full Code Here

    return aspects;
  }

  public static List getPackagesInModel() {
    List packages = new ArrayList();
    IHierarchy model =
      Ajde.getDefault().getStructureModelManager().getHierarchy();
    if (model.getRoot().equals(IHierarchy.NO_STRUCTURE)) {
      return null;
    } else {
      return getPackagesHelper(
        (IProgramElement) model.getRoot(),
        IProgramElement.Kind.PACKAGE,
        null,
        packages);
    }
  }
View Full Code Here

TOP

Related Classes of org.aspectj.asm.IHierarchy

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.