v.fmt #

fn fmt #

fn fmt(file ast.File, table &ast.Table, pref &pref.Preferences, is_debug bool) string

enum CommentsLevel #

enum CommentsLevel {
	keep
	indent
}

struct AttrsOptions #

struct AttrsOptions {
	inline bool
}

struct CommentsOptions #

struct CommentsOptions {
	has_nl    bool = true
	inline    bool
	level     CommentsLevel
	iembed    bool
	prev_line int = -1
}

CommentsOptions defines the way comments are going to be written - has_nl: adds an newline at the end of a list of comments - inline: line comments will be on the same line as the last statement - level: either .keep (don't indent), or .indent (increment indentation) - iembed: a /* ... */ block comment used inside expressions; // comments the whole line - prev_line: the line number of the previous token to save linebreaks

struct Fmt #

struct Fmt {
pub mut:
	file               ast.File
	table              &ast.Table
	pref               &pref.Preferences
	is_debug           bool
	out                strings.Builder
	out_imports        strings.Builder
	indent             int
	empty_line         bool
	line_len           int
	buffering          bool
	par_level          int
	array_init_break   []bool
	array_init_depth   int
	single_line_if     bool
	cur_mod            string
	did_imports        bool
	is_assign          bool
	is_struct_init     bool
	auto_imports       []string
	import_pos         int
	used_imports       []string
	import_syms_used   map[string]bool
	mod2alias          map[string]string
	use_short_fn_args  bool
	single_line_fields bool
	it_name            string
	inside_lambda      bool
	inside_const       bool
	is_mbranch_expr    bool
}

fn (Fmt) alias_type_decl #

fn (mut f Fmt) alias_type_decl(node ast.AliasTypeDecl)

fn (Fmt) array_decompose #

fn (mut f Fmt) array_decompose(node ast.ArrayDecompose)

=== Specific Expr methods ===//

fn (Fmt) array_init #

fn (mut f Fmt) array_init(node ast.ArrayInit)

fn (Fmt) as_cast #

fn (mut f Fmt) as_cast(node ast.AsCast)

fn (Fmt) assert_stmt #

fn (mut f Fmt) assert_stmt(node ast.AssertStmt)

=== Specific Stmt methods ===//

fn (Fmt) assign_stmt #

fn (mut f Fmt) assign_stmt(node ast.AssignStmt)

fn (Fmt) assoc #

fn (mut f Fmt) assoc(node ast.Assoc)

fn (Fmt) at_expr #

fn (mut f Fmt) at_expr(node ast.AtExpr)

fn (Fmt) attrs #

fn (mut f Fmt) attrs(attrs []ast.Attr)

fn (Fmt) block #

fn (mut f Fmt) block(node ast.Block)

fn (Fmt) branch_stmt #

fn (mut f Fmt) branch_stmt(node ast.BranchStmt)

fn (Fmt) call_args #

fn (mut f Fmt) call_args(args []ast.CallArg)

fn (Fmt) call_expr #

fn (mut f Fmt) call_expr(node ast.CallExpr)

fn (Fmt) cast_expr #

fn (mut f Fmt) cast_expr(node ast.CastExpr)

fn (Fmt) chan_init #

fn (mut f Fmt) chan_init(mut node ast.ChanInit)

fn (Fmt) comment #

fn (mut f Fmt) comment(node ast.Comment, options CommentsOptions)

fn (Fmt) comments #

fn (mut f Fmt) comments(comments []ast.Comment, options CommentsOptions)

fn (Fmt) comments_after_last_field #

fn (mut f Fmt) comments_after_last_field(comments []ast.Comment)

fn (Fmt) comments_before_field #

fn (mut f Fmt) comments_before_field(comments []ast.Comment)

fn (Fmt) comp_for #

fn (mut f Fmt) comp_for(node ast.CompFor)

fn (Fmt) comptime_call #

fn (mut f Fmt) comptime_call(node ast.ComptimeCall)

fn (Fmt) comptime_selector #

fn (mut f Fmt) comptime_selector(node ast.ComptimeSelector)

fn (Fmt) concat_expr #

fn (mut f Fmt) concat_expr(node ast.ConcatExpr)

fn (Fmt) const_decl #

fn (mut f Fmt) const_decl(node ast.ConstDecl)

fn (Fmt) defer_stmt #

fn (mut f Fmt) defer_stmt(node ast.DeferStmt)

fn (Fmt) dump_expr #

fn (mut f Fmt) dump_expr(node ast.DumpExpr)

fn (Fmt) enum_decl #

fn (mut f Fmt) enum_decl(node ast.EnumDecl)

fn (Fmt) enum_val #

fn (mut f Fmt) enum_val(node ast.EnumVal)

fn (Fmt) expr #

fn (mut f Fmt) expr(node ast.Expr)

=== General Expr-related methods and helpers ===//

fn (Fmt) expr_stmt #

fn (mut f Fmt) expr_stmt(node ast.ExprStmt)

fn (Fmt) fn_decl #

fn (mut f Fmt) fn_decl(node ast.FnDecl)

fn (Fmt) fn_type_decl #

fn (mut f Fmt) fn_type_decl(node ast.FnTypeDecl)

fn (Fmt) for_c_stmt #

fn (mut f Fmt) for_c_stmt(node ast.ForCStmt)

fn (Fmt) for_in_stmt #

fn (mut f Fmt) for_in_stmt(node ast.ForInStmt)

fn (Fmt) for_stmt #

fn (mut f Fmt) for_stmt(node ast.ForStmt)

fn (Fmt) global_decl #

fn (mut f Fmt) global_decl(node ast.GlobalDecl)

fn (Fmt) go_expr #

fn (mut f Fmt) go_expr(node ast.GoExpr)

fn (Fmt) goto_label #

fn (mut f Fmt) goto_label(node ast.GotoLabel)

fn (Fmt) goto_stmt #

fn (mut f Fmt) goto_stmt(node ast.GotoStmt)

fn (Fmt) hash_stmt #

fn (mut f Fmt) hash_stmt(node ast.HashStmt)

fn (Fmt) ident #

fn (mut f Fmt) ident(node ast.Ident)

fn (Fmt) if_expr #

fn (mut f Fmt) if_expr(node ast.IfExpr)

fn (Fmt) if_guard_expr #

fn (mut f Fmt) if_guard_expr(node ast.IfGuardExpr)

fn (Fmt) imp_stmt_str #

fn (f Fmt) imp_stmt_str(imp ast.Import) string

fn (Fmt) import_comments #

fn (mut f Fmt) import_comments(comments []ast.Comment, options CommentsOptions)

fn (Fmt) imports #

fn (mut f Fmt) imports(imports []ast.Import)

fn (Fmt) index_expr #

fn (mut f Fmt) index_expr(node ast.IndexExpr)

fn (Fmt) infix_expr #

fn (mut f Fmt) infix_expr(node ast.InfixExpr)

fn (Fmt) interface_decl #

fn (mut f Fmt) interface_decl(node ast.InterfaceDecl)

fn (Fmt) is_ref_type #

fn (mut f Fmt) is_ref_type(node ast.IsRefType)

fn (Fmt) likely #

fn (mut f Fmt) likely(node ast.Likely)

fn (Fmt) lock_expr #

fn (mut f Fmt) lock_expr(node ast.LockExpr)

fn (Fmt) map_init #

fn (mut f Fmt) map_init(node ast.MapInit)

fn (Fmt) mark_import_as_used #

fn (mut f Fmt) mark_import_as_used(name string)

name is a function (foo.bar()) or type (foo.Bar{})

fn (Fmt) mark_types_import_as_used #

fn (mut f Fmt) mark_types_import_as_used(typ ast.Type)

=== Import-related methods ===//

fn (Fmt) match_expr #

fn (mut f Fmt) match_expr(node ast.MatchExpr)

fn (Fmt) mod #

fn (mut f Fmt) mod(mod ast.Module)

fn (Fmt) no_cur_mod #

fn (mut f Fmt) no_cur_mod(typename string) string

fn (Fmt) node_str #

fn (mut f Fmt) node_str(node ast.Node) string

fn (Fmt) offset_of #

fn (mut f Fmt) offset_of(node ast.OffsetOf)

fn (Fmt) or_expr #

fn (mut f Fmt) or_expr(node ast.OrExpr)

fn (Fmt) par_expr #

fn (mut f Fmt) par_expr(node ast.ParExpr)

fn (Fmt) postfix_expr #

fn (mut f Fmt) postfix_expr(node ast.PostfixExpr)

fn (Fmt) prefix_expr #

fn (mut f Fmt) prefix_expr(node ast.PrefixExpr)

fn (Fmt) prefix_expr_cast_expr #

fn (mut f Fmt) prefix_expr_cast_expr(node ast.Expr)

fn (Fmt) process_file_imports #

fn (mut f Fmt) process_file_imports(file &ast.File)

fn (Fmt) range_expr #

fn (mut f Fmt) range_expr(node ast.RangeExpr)

fn (Fmt) remove_new_line #

fn (mut f Fmt) remove_new_line(cfg RemoveNewLineConfig)

fn (Fmt) return_stmt #

fn (mut f Fmt) return_stmt(node ast.Return)

fn (Fmt) select_expr #

fn (mut f Fmt) select_expr(node ast.SelectExpr)

fn (Fmt) selector_expr #

fn (mut f Fmt) selector_expr(node ast.SelectorExpr)

fn (Fmt) set_current_module_name #

fn (mut f Fmt) set_current_module_name(cmodname string)

=== Module handling helper methods ===//

fn (Fmt) short_module #

fn (mut f Fmt) short_module(name string) string

foo.bar.fn() => bar.fn()

fn (Fmt) single_line_attrs #

fn (mut f Fmt) single_line_attrs(attrs []ast.Attr, options AttrsOptions)

fn (Fmt) size_of #

fn (mut f Fmt) size_of(node ast.SizeOf)

fn (Fmt) sql_expr #

fn (mut f Fmt) sql_expr(node ast.SqlExpr)

fn (Fmt) sql_stmt #

fn (mut f Fmt) sql_stmt(node ast.SqlStmt)

fn (Fmt) sql_stmt_line #

fn (mut f Fmt) sql_stmt_line(node ast.SqlStmtLine)

fn (Fmt) stmt #

fn (mut f Fmt) stmt(node ast.Stmt)

fn (Fmt) stmts #

fn (mut f Fmt) stmts(stmts []ast.Stmt)

=== General Stmt-related methods and helpers ===//

fn (Fmt) string_inter_literal #

fn (mut f Fmt) string_inter_literal(node ast.StringInterLiteral)

fn (Fmt) string_literal #

fn (mut f Fmt) string_literal(node ast.StringLiteral)

fn (Fmt) struct_decl #

fn (mut f Fmt) struct_decl(node ast.StructDecl)

fn (Fmt) struct_init #

fn (mut f Fmt) struct_init(node ast.StructInit)

fn (Fmt) sum_type_decl #

fn (mut f Fmt) sum_type_decl(node ast.SumTypeDecl)

fn (Fmt) type_decl #

fn (mut f Fmt) type_decl(node ast.TypeDecl)

fn (Fmt) type_expr #

fn (mut f Fmt) type_expr(node ast.TypeNode)

fn (Fmt) type_of #

fn (mut f Fmt) type_of(node ast.TypeOf)

fn (Fmt) unsafe_expr #

fn (mut f Fmt) unsafe_expr(node ast.UnsafeExpr)

fn (Fmt) wrap_infix #

fn (mut f Fmt) wrap_infix(start_pos int, start_len int, is_cond bool)

fn (Fmt) wrap_long_line #

fn (mut f Fmt) wrap_long_line(penalty_idx int, add_indent bool) bool

fn (Fmt) write #

fn (mut f Fmt) write(s string)

=== Basic buffer write operations ===//

fn (Fmt) writeln #

fn (mut f Fmt) writeln(s string)

struct RemoveNewLineConfig #

struct RemoveNewLineConfig {
	imports_buffer bool
}