Examples of IHierarchy


Examples of org.aspectj.asm.IHierarchy

   * @return null if a corresponding node was not found
   */
  public List findMatches(String pattern, IProgramElement.Kind kind) {

    List matches = new ArrayList();
    IHierarchy model = AsmManager.lastActiveStructureModel.getHierarchy();
    if (model.getRoot().equals(IHierarchy.NO_STRUCTURE)) {
      return null;
    } else {
      return findMatchesHelper(model.getRoot(), pattern, kind, matches);
    }
  }
View Full Code Here

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

Examples of org.aspectj.asm.IHierarchy

    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

Examples of org.aspectj.asm.IHierarchy

    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

Examples of org.aspectj.asm.IHierarchy

    // return;

    CompilationResultDestinationManager crdm = config.getCompilationResultDestinationManager();
    AsmManager structureModel = AsmManager.createNewStructureModel(crdm == null ? Collections.EMPTY_MAP : crdm.getInpathMap());
    // AsmManager.getDefault().getRelationshipMap().clear();
    IHierarchy model = structureModel.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(structureModel, rootLabel, kind, new ArrayList()));

    model.setFileMap(new HashMap<String, IProgramElement>());
    // setStructureModel(model);
    state.setStructureModel(structureModel);
    // state.setRelationshipMap(AsmManager.getDefault().getRelationshipMap());
  }
View Full Code Here

Examples of org.aspectj.asm.IHierarchy

   *
   * @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

Examples of org.aspectj.asm.IHierarchy

   *
   * @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

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

Examples of org.aspectj.asm.IHierarchy

    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;
    }
    if (!typeElem.getKind().isType()) {
      throw new IllegalStateException("Did not find a type element, found a "+typeElem.getKind()+" element");
    }

    StringBuilder parmString = new StringBuilder("(");
    UnresolvedType[] args = affectedMethod.getParameterTypes();
    for (int i = 0; i < args.length; i++) {
      parmString.append(args[i].getName());
      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

Examples of org.aspectj.asm.IHierarchy

    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
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.