@Override public String getHtml(HtmlFormatter formatter) { formatter.appendText(node.getName()); if ((kind == ElementKind.METHOD) || (kind == ElementKind.CONSTRUCTOR)) { // Append parameters ASTMethod jn = (ASTMethod) node; Collection<String> parameters = jn.getParameters(); if ((parameters != null) && (parameters.size() > 0)) { formatter.appendHtml("("); formatter.parameters(true); for (Iterator<String> it = parameters.iterator(); it.hasNext(); ) { String ve = it.next(); // TODO - if I know types, list the type here instead. For now, just use the parameter // name instead formatter.appendText(ve); if (it.hasNext()) { formatter.appendHtml(", "); } } formatter.parameters(false); formatter.appendHtml(")"); } else { formatter.appendHtml("()"); } } return formatter.getText(); }
private static boolean isVisible(ASTElement element) { // FIXME perhaps we should store synthetic atributte in AstElement if ((element.getKind() == ElementKind.METHOD)) { ASTMethod method = (ASTMethod) element; ASTNode node = method.getNode(); return !(node instanceof MethodNode) || (!((MethodNode) node).isSynthetic() && ((MethodNode) node).getLineNumber() >= 0); } return true; }
private void scan( GroovyParserResult result, ASTNode node, AstPath path, String in, Set<String> includes, ASTElement parent) { if (node instanceof AnnotatedNode && !((AnnotatedNode) node).hasNoRealSourcePosition()) { if (node instanceof ClassNode) { ASTClass co = new ASTClass(result, node); co.setFqn(((ClassNode) node).getName()); if (parent != null) { parent.addChild(co); } else { structure.add(co); } parent = co; } else if (node instanceof FieldNode) { if (parent instanceof ASTClass) { // We don't have unique declarations, only assignments (possibly many) // so stash these in a map and extract unique fields when we're done Set<FieldNode> assignments = fields.get(parent); if (assignments == null) { assignments = new HashSet<FieldNode>(); fields.put((ASTClass) parent, assignments); } assignments.add((FieldNode) node); } } else if (node instanceof MethodNode) { ASTMethod co = new ASTMethod(result, node); methods.add(co); co.setIn(in); // TODO - don't add this to the top level! Make a nested list if (parent != null) { parent.addChild(co); } else { structure.add(co); } } else if (node instanceof PropertyNode) { Set<PropertyNode> declarations = properties.get(parent); if (declarations == null) { declarations = new HashSet<PropertyNode>(); properties.put((ASTClass) parent, declarations); } declarations.add((PropertyNode) node); } } @SuppressWarnings("unchecked") List<ASTNode> list = ASTUtils.children(node); for (ASTNode child : list) { path.descend(child); scan(result, child, path, in, includes, parent); path.ascend(); } }