import { BaseVisitor } from "@wapc/widl/ast";
import { expandType, fieldName, isReference } from "./helpers";
import { formatComment } from "../utils";
export class StructVisitor extends BaseVisitor {
    constructor(writer) {
        super(writer);
    }
    visitObjectBefore(context) {
        super.triggerObjectBefore(context);
        this.write(formatComment("// ", context.object.description));
        this.write(`type ${context.object.name.value} struct {\n`);
    }
    visitObjectField(context) {
        const field = context.field;
        this.write(formatComment("// ", field.description));
        this.write(`\t${fieldName(field.name.value)} ${expandType(field.type, undefined, true, isReference(field.annotations))} \`json:"${field.name.value}" msgpack:"${field.name.value}"\`\n`);
        super.triggerObjectField(context);
    }
    visitObjectAfter(context) {
        this.write(`}\n\n`);
        super.triggerObjectAfter(context);
    }
}
//# sourceMappingURL=struct_visitor.js.map