Ejemplo n.º 1
0
  @Override
  public boolean visit(TypeDeclaration node) {
    if (!node.isPackageMemberTypeDeclaration()) {
      OutlineClass tmpNestedClass =
          new OutlineClass(node.getName().toString(), clazz.getName(), true, false);
      tmpNestedClass.performChecks();
      children_classes.add(tmpNestedClass);
      node.accept(
          new ASTVisitor() {
            @Override
            public boolean visit(MethodDeclaration node) {
              OutlineMethod tmpNestedMethod =
                  new OutlineMethod(
                      node.getName().toString(),
                      node.getReturnType2(),
                      node.isConstructor(),
                      node.getModifiers(),
                      node.parameters(),
                      children_classes.get(children_classes.size() - 1));
              Visitor.this.addToMethodList(
                  children_classes.get(children_classes.size() - 1), tmpNestedMethod);
              return false;
            }

            @Override
            public boolean visit(FieldDeclaration node) {
              OutlineField tmpNestedField =
                  new OutlineField(
                      node.toString().replaceAll("[;\\n]", "").split("=")[0],
                      node.getType(),
                      node.getModifiers(),
                      children_classes.get(children_classes.size() - 1));
              Visitor.this.addToFieldList(
                  children_classes.get(children_classes.size() - 1), tmpNestedField);
              return false;
            }
          });
    } else {
      clazz.setModifiers(node.getModifiers());
      clazz.performChecks();
      clazz.setInterface(node.isInterface());
      clazz.setEnum(false);
    }
    return super.visit(node);
  }
Ejemplo n.º 2
0
  @Override
  public boolean visit(AnonymousClassDeclaration node) {
    String classname =
        node.getParent()
            .toString()
            .subSequence(0, node.getParent().toString().indexOf("{"))
            .toString();
    OutlineClass tmpAnonClass =
        new OutlineClass(classname + " {...}", clazz.getName(), false, true);
    tmpAnonClass.performChecks();
    children_classes.add(tmpAnonClass);
    node.accept(
        new ASTVisitor() {
          @Override
          public boolean visit(MethodDeclaration node) {
            OutlineMethod tmpNestedMethod =
                new OutlineMethod(
                    node.getName().toString(),
                    node.getReturnType2(),
                    node.isConstructor(),
                    node.getModifiers(),
                    node.parameters(),
                    null);
            Visitor.this.addToMethodList(
                children_classes.get(children_classes.size() - 1), tmpNestedMethod);
            return false;
          }

          @Override
          public boolean visit(FieldDeclaration node) {
            OutlineField tmpNestedField =
                new OutlineField(
                    node.toString().replaceAll("[;\\n]", "").split("=")[0],
                    node.getType(),
                    node.getModifiers(),
                    children_classes.get(children_classes.size() - 1));
            Visitor.this.addToFieldList(
                children_classes.get(children_classes.size() - 1), tmpNestedField);
            return false;
          }
        });
    // TODO:isto devia estar dentro do metodo q chamou -> idk como se faz
    return false;
  }