mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-08 16:48:18 +00:00
ran the odinfmt - looks good, except for multi line binary operations
This commit is contained in:
@@ -8,7 +8,7 @@ import "core:fmt"
|
||||
import "core:unicode/utf8"
|
||||
import "core:mem"
|
||||
|
||||
Line_Type_Enum :: enum{Line_Comment, Value_Decl, Switch_Stmt, Struct};
|
||||
Line_Type_Enum :: enum {Line_Comment, Value_Decl, Switch_Stmt, Struct}
|
||||
|
||||
Line_Type :: bit_set[Line_Type_Enum];
|
||||
|
||||
@@ -103,7 +103,7 @@ default_style := Config {
|
||||
indent_cases = false,
|
||||
align_switch = true,
|
||||
align_structs = true,
|
||||
newline_style = .LF,
|
||||
newline_style = .CRLF,
|
||||
};
|
||||
|
||||
make_printer :: proc(config: Config, allocator := context.allocator) -> Printer {
|
||||
@@ -194,7 +194,6 @@ fix_lines :: proc(p: ^Printer) {
|
||||
}
|
||||
|
||||
align_var_decls :: proc(p: ^Printer) {
|
||||
|
||||
}
|
||||
|
||||
align_switch_smt :: proc(p: ^Printer, index: int) {
|
||||
@@ -216,9 +215,7 @@ align_switch_smt :: proc(p: ^Printer, index: int) {
|
||||
} else if format_token.kind == .Switch {
|
||||
switch_found = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if !switch_found {
|
||||
@@ -260,7 +257,6 @@ align_switch_smt :: proc(p: ^Printer, index: int) {
|
||||
if case_count >= brace_token.parameter_count {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case_count = 0;
|
||||
@@ -291,14 +287,12 @@ align_switch_smt :: proc(p: ^Printer, index: int) {
|
||||
}
|
||||
|
||||
length += len(format_token.text) + format_token.spaces_before;
|
||||
|
||||
}
|
||||
|
||||
if case_count >= brace_token.parameter_count {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
align_struct :: proc(p: ^Printer, index: int) {
|
||||
@@ -320,9 +314,7 @@ align_struct :: proc(p: ^Printer, index: int) {
|
||||
} else if format_token.kind == .Struct {
|
||||
struct_found = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if !struct_found {
|
||||
@@ -381,7 +373,6 @@ align_struct :: proc(p: ^Printer, index: int) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
align_blocks :: proc(p: ^Printer) {
|
||||
@@ -399,9 +390,7 @@ align_blocks :: proc(p: ^Printer) {
|
||||
if .Struct in line.types && p.config.align_structs {
|
||||
align_struct(p, line_index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
align_comments :: proc(p: ^Printer) {
|
||||
@@ -449,9 +438,7 @@ align_comments :: proc(p: ^Printer) {
|
||||
|
||||
length += format_token.spaces_before + len(format_token.text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (current_info.begin != 0 && current_info.end != 0) || current_info.length > 0 {
|
||||
@@ -482,9 +469,6 @@ align_comments :: proc(p: ^Printer) {
|
||||
|
||||
length += format_token.spaces_before + len(format_token.text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -116,7 +116,6 @@ push_comment :: proc(p: ^Printer, comment: tokenizer.Token) -> int {
|
||||
} else {
|
||||
strings.write_byte(&builder, c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if strings.builder_len(builder) > 0 {
|
||||
@@ -851,7 +850,6 @@ visit_stmt :: proc(p: ^Printer, stmt: ^ast.Stmt, block_type: Block_Type = .Gener
|
||||
set_source_position(p, stmt.end);
|
||||
}
|
||||
|
||||
|
||||
@(private)
|
||||
visit_expr :: proc(p: ^Printer, expr: ^ast.Expr) {
|
||||
|
||||
@@ -1198,7 +1196,6 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
visit_begin_brace :: proc(p: ^Printer, begin: tokenizer.Pos, type: Block_Type, count := 0) {
|
||||
|
||||
set_source_position(p, begin);
|
||||
@@ -1346,7 +1343,6 @@ visit_proc_type :: proc(p: ^Printer, proc_type: ast.Proc_Type) {
|
||||
visit_signature_list(p, proc_type.results);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
visit_binary_expr :: proc(p: ^Printer, binary: ast.Binary_Expr) {
|
||||
@@ -1372,7 +1368,6 @@ visit_binary_expr :: proc(p: ^Printer, binary: ast.Binary_Expr) {
|
||||
} else {
|
||||
visit_expr(p, binary.right);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
visit_call_exprs :: proc(p: ^Printer, list: [] ^ast.Expr, ellipsis := false) {
|
||||
@@ -1401,7 +1396,6 @@ visit_call_exprs :: proc(p: ^Printer, list: []^ast.Expr, ellipsis := false) {
|
||||
//we have to newline the expressions to respect the source
|
||||
move_line_limit(p, expr.pos, 1);
|
||||
|
||||
|
||||
if i == len(list) - 1 && ellipsis {
|
||||
push_generic_token(p, .Ellipsis, 0);
|
||||
}
|
||||
@@ -1415,7 +1409,6 @@ visit_call_exprs :: proc(p: ^Printer, list: []^ast.Expr, ellipsis := false) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
visit_signature_list :: proc(p: ^Printer, list: ^ast.Field_List, remove_blank := true) {
|
||||
|
||||
if list.list == nil {
|
||||
@@ -1454,7 +1447,7 @@ visit_signature_list :: proc(p: ^Printer, list: ^ast.Field_List, remove_blank :=
|
||||
|
||||
if field.type != nil && field.default_value != nil {
|
||||
visit_expr(p, field.type);
|
||||
push_generic_token(p, .Eq, 0);
|
||||
push_generic_token(p, .Eq, 1);
|
||||
visit_expr(p, field.default_value);
|
||||
} else if field.type != nil {
|
||||
visit_expr(p, field.type);
|
||||
@@ -1469,4 +1462,3 @@ visit_signature_list :: proc(p: ^Printer, list: ^ast.Field_List, remove_blank :=
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user