Ejemplo n.º 1
0
  public static String resolveName(CtTypeMember castedElement) {

    int pos = castedElement.getSignature().indexOf("(");
    String st = castedElement.getSignature().substring(0, pos);
    pos = st.lastIndexOf(' ');

    if (castedElement instanceof CtConstructor) return castedElement.getSignature();
    else if (castedElement instanceof CtMethod) {
      return castedElement.getDeclaringType().getQualifiedName()
          + "."
          + castedElement.getSignature().substring(pos + 1);
    } else if (castedElement instanceof CtAnonymousExecutable) {
      String qualifiedName = castedElement.getParent(CtClass.class).getQualifiedName();

      if (castedElement.getModifiers().contains(ModifierKind.STATIC)) qualifiedName += ".{static}";
      else qualifiedName += ".{}";

      logger.info("The analyzed program contains Anonymous Executable blocks");
      // TODO: Remove for propagation or think about propagation of Anonymous Executable blocs
      // (statics or not)
      return qualifiedName;
    } else {
      logger.warn("Missing type for resolution name: %s", castedElement.getClass().getSimpleName());
      return null;
    }
  }
Ejemplo n.º 2
0
  public static String notFullyQualifiedName(CtTypeMember castedElement) {

    int pos = castedElement.getSignature().indexOf("(");
    String st = castedElement.getSignature().substring(0, pos);

    if (castedElement instanceof CtConstructor) {
      pos = st.lastIndexOf('.');
      return castedElement.getSignature().substring(pos + 1);
    } else if (castedElement instanceof CtMethod) {
      pos = st.lastIndexOf(' ');
      return castedElement.getSignature().substring(pos + 1);
    } else return null;
  }