@Override public void visitDeclarations(Declarations decls) { implode(decls.getDeclarations(), "\n" + indent); }
public void visitSourceFile(SourceFile e) { implode(e.getDeclarations(), "\n" + indent); }
protected Printer modifiersStringPrefix(ModifiableElement e, boolean addSpace) { List<Modifier> modifiers = e.getModifiers(); if (modifiers != null && !modifiers.isEmpty()) { implode(modifiers, " "); if (addSpace) { space(); } } return this; }
public void visitQualifiedIdentifier(QualifiedIdentifier e) { implode(e.getIdentifiers(), String.valueOf(e.getSeparator())); }
public void visitExpressionSequence(ExpressionSequence e) { expressionPre(e); implode(e.getExpressions(), ", "); expressionPost(e); }
protected void bracketsToString(ArrayRef e) { append("[").implode(e.getDimensions(), "][").append("]"); }
public void visitSimpleIdentifier(SimpleIdentifier e) { append(e.getName()); if (!e.getTemplateArguments().isEmpty()) { append("<"); implode(e.getTemplateArguments(), ", "); append(" >"); } }
public void visitExpressionsBlock(ExpressionsBlock e) { expressionPre(e); append("{ "); implode(e.getExpressions(), ", "); append(" }"); expressionPost(e); }
public void visitProperty(Property e) { append("@property"); if (!e.getModifiers().isEmpty()) { append("(").implode(e.getModifiers(), ", ").append(")"); } append(" ", e.getDeclaration()); }
public void visitTemplate(Template template) { append("template <").implode(template.getArgs(), ", ").append(" >\n"); append(indent, template.getDeclaration()); }
public void visitBlock(Block e) { append("{"); if (!e.getStatements().isEmpty()) { if (e.isCompact()) { append(' '); implode(e.getStatements(), ", "); append(' '); } else { indent(); append("\n", indent); implode(e.getStatements(), "\n" + indent); deindent(); append("\n", indent); } } append('}'); }
public void visitExternDeclarations(ExternDeclarations e) { append("extern \"", e.getLanguage(), "\" {\n"); indent(); implode(e.getDeclarations(), "\n" + indent); deindent(); append("\n", indent, "}"); }
protected void valueTypeAndStorageSuffix(StoredDeclarations e) { if (e.getValueType() instanceof FunctionSignature) { FunctionSignature sig = (FunctionSignature) e.getValueType(); if (sig.getFunction() != null) { Identifier name = sig.getFunction().getName(); if (name != null && e.declarators.size() == 1) { String stoName = e.declarators.get(0).resolveName(); if (name.equals(stoName) || stoName == null) { append(sig); return; } } } } append(e.getValueType()).space(!e.getDeclarators().isEmpty()).implode(e.getDeclarators(), ", "); }
public void visitVariablesDeclaration(VariablesDeclaration e) { formatComments(e, false, true, true); if (!e.getAnnotations().isEmpty()) { implode(e.getAnnotations(), "\n" + indent).append("\n", indent); } modifiersStringPrefix(e); valueTypeAndStorageSuffix(e); if (!(e.getParentElement() instanceof Catch)) { append(";"); } if (e.getCommentAfter() != null) { space().append(e.getCommentAfter()); } }
public void visitNewArray(NewArray e) { expressionPre(e); boolean noDims = e.getDimensions().isEmpty(); boolean noVals = e.getInitialValues().isEmpty(); boolean isAnn = e.isAnnotationValue(); if (!isAnn) { append("new ").append(e.getType()).append("["); if (noDims && noVals) { append("0"); } else { implode(e.getDimensions(), "]["); } append("]"); } if (isAnn || noDims && !noVals) { append("{").implode(e.getInitialValues(), ", ").append("}"); } expressionPost(e); }
@Override public void visitNamespace(Namespace ns) { append("namespace ").append(ns.getName()).append(" {\n"); indent(); implode(ns.getDeclarations(), "\n" + indent); deindent(); append("\n", indent, "}"); }
public void visitEnumItem(EnumItem e) { formatComments(e, false, true, true); append(e.getName()); if (!e.getArguments().isEmpty()) { if (e.getType() == Type.C) { append(" = ", e.getArguments().get(0)); } else { append("("); implode(e.getArguments(), ", "); append(")"); } } if (e.getBody() != null) { append(" {\n\t", indent); indent(); implode(e.getBody().getDeclarations(), "\n" + indent); deindent(); append("\n", indent, "}"); } space(e.getCommentAfter() != null).append(e.getCommentAfter()); }
public void visitTry(Try e) { append("try {\n"); indent(); append(indent, e.getTryStatement()); deindent(); append("\n", indent, "}"); implode(e.getCatches(), " "); if (e.getFinallyStatement() != null) { append(" finally {\n"); indent(); append(indent); append(e.getFinallyStatement()); deindent(); append("\n", indent, "}"); } }
public void visitArg(Arg e) { implode(e.getAnnotations(), "\n"); if (e.getValueType() != null) { if (e.getName() != null) { variableDeclarationToString(e.getValueType(), e.getName(), e.isVarArg()); if (e.getDefaultValue() != null) { append(" = ").append(e.getDefaultValue()); } } else { append(e.getValueType()).append(e.isVarArg() ? "..." : null); } } else { append("..."); } }