Exemplo n.º 1
0
  @Override
  public Type getSuperType() {
    val extends_ = type.get().getExtends();

    if (extends_ == null || extends_.isEmpty()) return null;

    return getContext().resolve(extends_.get(0));
  }
Exemplo n.º 2
0
  private com.github.javaparser.ast.type.Type setType(
      Type newType, com.github.javaparser.ast.type.Type currentType) {
    val newType_ = toType(newType);

    if (currentType instanceof ClassOrInterfaceType && newType_ instanceof ClassOrInterfaceType) {
      val annotations = currentType.getAnnotations();
      if (annotations != null && !annotations.isEmpty()) newType_.setAnnotations(annotations);
    }
    return newType_;
  }
Exemplo n.º 3
0
  @Override
  public void add(MethodInfo method) {
    MethodDeclaration methodDeclaration;

    if (method instanceof MethodDeclarationWrapper) {
      val wrapper = (MethodDeclarationWrapper) method;
      methodDeclaration = (MethodDeclaration) wrapper.declaration.clone();
      methodDeclaration.setAnnotations(Collections.emptyList());
      wrapper
          .getClassInfo()
          .changeTypeContext(wrapper.getContext(), getContext(), methodDeclaration);
    } else {
      methodDeclaration = new MethodDeclaration();
      new MethodDeclarationWrapper(methodDeclaration).setAll(method);
    }

    addMember(methodDeclaration);
  }
Exemplo n.º 4
0
  @Override
  public void add(FieldInfo field) {
    FieldDeclaration fieldDeclaration;

    if (field instanceof FieldDeclarationWrapper) {
      val wrapper = (FieldDeclarationWrapper) field;
      fieldDeclaration = (FieldDeclaration) wrapper.declaration.clone();
      fieldDeclaration.setAnnotations(Collections.emptyList());
      changeTypeContext(wrapper.getContext(), getContext(), fieldDeclaration);
    } else {
      fieldDeclaration = new FieldDeclaration();
      val vars = new ArrayList<VariableDeclarator>();
      vars.add(new VariableDeclarator(new VariableDeclaratorId("unknown")));
      fieldDeclaration.setVariables(vars);
      new FieldDeclarationWrapper(fieldDeclaration).setAll(field);
    }

    addMember(fieldDeclaration);

    val result = new FieldDeclarationWrapper(fieldDeclaration);
    if (!field.similar(result))
      throw new TransformationException(
          "After adding to class, didn't match. added: " + field + " result: " + result);
  }