@Override public Void visitFormalParameterList(FormalParameterList node) { String groupEnd = null; writer.print('('); NodeList<FormalParameter> parameters = node.getParameters(); int size = parameters.size(); for (int i = 0; i < size; i++) { FormalParameter parameter = parameters.get(i); if (i > 0) { writer.print(", "); } if (groupEnd == null && parameter instanceof DefaultFormalParameter) { if (parameter.getKind() == ParameterKind.NAMED) { groupEnd = "}"; writer.print('{'); } else { groupEnd = "]"; writer.print('['); } } parameter.accept(this); } if (groupEnd != null) { writer.print(groupEnd); } writer.print(')'); return null; }
public void test_visitFormalParameterList() { ElementHolder holder = new ElementHolder(); ElementBuilder builder = new ElementBuilder(holder); String firstParameterName = "a"; String secondParameterName = "b"; FormalParameterList parameterList = formalParameterList( simpleFormalParameter(firstParameterName), simpleFormalParameter(secondParameterName)); parameterList.accept(builder); ParameterElement[] parameters = holder.getParameters(); assertLength(2, parameters); assertEquals(firstParameterName, parameters[0].getName()); assertEquals(secondParameterName, parameters[1].getName()); }
@Override public R visitFormalParameterList(FormalParameterList node) { node.visitChildren(this); return null; }