mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
ran odinfmt
This commit is contained in:
@@ -242,26 +242,22 @@ format_value_decl :: proc(p: ^Printer, index: int) {
|
|||||||
if !align_next {
|
if !align_next {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
find_last_token :: proc(format_tokens: [dynamic]Format_Token) -> Format_Token {
|
find_last_token :: proc(format_tokens: [dynamic]Format_Token) -> Format_Token {
|
||||||
|
|
||||||
for i := len(format_tokens)-1; i >= 0; i -= 1 {
|
for i := len(format_tokens) - 1; i >= 0; i -= 1 {
|
||||||
|
|
||||||
if format_tokens[i].kind != .Comment {
|
if format_tokens[i].kind != .Comment {
|
||||||
return format_tokens[i];
|
return format_tokens[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
panic("not possible");
|
panic("not possible");
|
||||||
}
|
}
|
||||||
|
|
||||||
format_assignment :: proc(p: ^Printer, index: int) {
|
format_assignment :: proc(p: ^Printer, index: int) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
format_call :: proc(p: ^Printer, line_index: int, format_index: int) {
|
format_call :: proc(p: ^Printer, line_index: int, format_index: int) {
|
||||||
@@ -292,7 +288,7 @@ format_call :: proc(p: ^Printer, line_index: int, format_index: int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !paren_found {
|
if !paren_found {
|
||||||
panic("Should not be possible");;
|
panic("Should not be possible");
|
||||||
}
|
}
|
||||||
|
|
||||||
paren_count := 1;
|
paren_count := 1;
|
||||||
@@ -323,7 +319,6 @@ format_call :: proc(p: ^Printer, line_index: int, format_index: int) {
|
|||||||
if paren_count == 0 {
|
if paren_count == 0 {
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if line_index != 0 {
|
if line_index != 0 {
|
||||||
@@ -389,7 +384,6 @@ format_keyword_to_brace :: proc(p: ^Printer, line_index: int, format_index: int,
|
|||||||
if brace_count == 1 {
|
if brace_count == 1 {
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if line_index != 0 {
|
if line_index != 0 {
|
||||||
@@ -399,9 +393,7 @@ format_keyword_to_brace :: proc(p: ^Printer, line_index: int, format_index: int,
|
|||||||
if done {
|
if done {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
format_generic :: proc(p: ^Printer) {
|
format_generic :: proc(p: ^Printer) {
|
||||||
@@ -414,13 +406,12 @@ format_generic :: proc(p: ^Printer) {
|
|||||||
|
|
||||||
for format_token, token_index in line.format_tokens {
|
for format_token, token_index in line.format_tokens {
|
||||||
|
|
||||||
if format_token.kind == .For || format_token.kind == .If
|
if format_token.kind == .For || format_token.kind == .If ||
|
||||||
|| format_token.kind == .When || format_token.kind == .Switch {
|
format_token.kind == .When || format_token.kind == .Switch {
|
||||||
format_keyword_to_brace(p, line_index, token_index, format_token.kind);
|
format_keyword_to_brace(p, line_index, token_index, format_token.kind);
|
||||||
} else if format_token.type == .Call {
|
} else if format_token.type == .Call {
|
||||||
format_call(p, line_index, token_index);
|
format_call(p, line_index, token_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if .Switch_Stmt in line.types && p.config.align_switch {
|
if .Switch_Stmt in line.types && p.config.align_switch {
|
||||||
@@ -438,15 +429,10 @@ format_generic :: proc(p: ^Printer) {
|
|||||||
if .Assign in line.types {
|
if .Assign in line.types {
|
||||||
format_assignment(p, line_index);
|
format_assignment(p, line_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
align_var_decls_and_assignments :: proc(p: ^Printer) {
|
align_var_decls_and_assignments :: proc(p: ^Printer) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
align_switch_stmt :: proc(p: ^Printer, index: int) {
|
align_switch_stmt :: proc(p: ^Printer, index: int) {
|
||||||
@@ -650,7 +636,7 @@ align_comments :: proc(p: ^Printer) {
|
|||||||
if .Line_Comment in line.types {
|
if .Line_Comment in line.types {
|
||||||
|
|
||||||
if current_info.end + 1 != line_index || current_info.depth != line.depth ||
|
if current_info.end + 1 != line_index || current_info.depth != line.depth ||
|
||||||
(current_info.begin == current_info.end && current_info.length == 0) {
|
(current_info.begin == current_info.end && current_info.length == 0) {
|
||||||
|
|
||||||
if (current_info.begin != 0 && current_info.end != 0) || current_info.length > 0 {
|
if (current_info.begin != 0 && current_info.end != 0) || current_info.length > 0 {
|
||||||
append(&comment_infos, current_info);
|
append(&comment_infos, current_info);
|
||||||
|
|||||||
@@ -195,8 +195,8 @@ append_format_token :: proc(p: ^Printer, format_token: Format_Token) -> ^Format_
|
|||||||
format_token := format_token;
|
format_token := format_token;
|
||||||
|
|
||||||
if p.last_token != nil && (p.last_token.kind == .Ellipsis || p.last_token.kind == .Range_Half ||
|
if p.last_token != nil && (p.last_token.kind == .Ellipsis || p.last_token.kind == .Range_Half ||
|
||||||
p.last_token.kind == .Open_Paren || p.last_token.kind == .Period ||
|
p.last_token.kind == .Open_Paren || p.last_token.kind == .Period ||
|
||||||
p.last_token.kind == .Open_Brace || p.last_token.kind == .Open_Bracket) {
|
p.last_token.kind == .Open_Brace || p.last_token.kind == .Open_Bracket) {
|
||||||
format_token.spaces_before = 0;
|
format_token.spaces_before = 0;
|
||||||
} else if p.merge_next_token {
|
} else if p.merge_next_token {
|
||||||
format_token.spaces_before = 0;
|
format_token.spaces_before = 0;
|
||||||
@@ -1101,10 +1101,10 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr) {
|
|||||||
visit_expr(p, v.expr);
|
visit_expr(p, v.expr);
|
||||||
|
|
||||||
push_format_token(p, Format_Token {
|
push_format_token(p, Format_Token {
|
||||||
kind = .Open_Paren,
|
kind = .Open_Paren,
|
||||||
type = .Call,
|
type = .Call,
|
||||||
text = "(",
|
text = "(",
|
||||||
});
|
});
|
||||||
|
|
||||||
hint_current_line(p, {.Call});
|
hint_current_line(p, {.Call});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user