public OutlineClass getClazz() { RemoveDuplicates(); clazz.setFields(fields); clazz.setMethod(methods); clazz.setChildren_classes(children_classes); return clazz; }
private void recursiveGetChildrenMethodsAndFields( OutlineClass oc, ArrayList<OutlineMethod> childrenMethods, ArrayList<OutlineField> childrenFields) { childrenMethods.addAll(oc.getMethods()); childrenFields.addAll(oc.getFields()); if (oc.getChildren_classes().isEmpty()) return; for (OutlineClass coc : children_classes) recursiveGetChildrenMethodsAndFields(coc, childrenMethods, childrenFields); }
@Override public boolean visit(EnumDeclaration node) { int flags = node.getModifiers(); if (Modifier.isPublic(flags)) { clazz.setVisibility(Visibility.PUBLIC); } else { clazz.setVisibility(Visibility.PACKAGE_PRIVATE); } clazz.setEnum(true); for (Object constant : node.enumConstants()) { fields.add(new OutlineField(constant.toString(), clazz)); } clazz.checkVisibility(flags); clazz.setImg(); return super.visit(node); }
@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; }
@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); }
public void addToFieldList(OutlineClass outlineClass, OutlineField out) { outlineClass.getFields().add(out); }
public void addToMethodList(OutlineClass outlineClass, OutlineMethod out) { outlineClass.getMethods().add(out); }