mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
make sure to print comments at the end of the file
This commit is contained in:
@@ -118,6 +118,12 @@ print :: proc(p: ^Printer, file: ^ast.File) -> string {
|
|||||||
visit_decl(p, cast(^ast.Decl)decl);
|
visit_decl(p, cast(^ast.Decl)decl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(p.comments) > 0 {
|
||||||
|
infinite := p.comments[len(p.comments)-1].end;
|
||||||
|
infinite.offset = 9999999;
|
||||||
|
push_comments(p, infinite);
|
||||||
|
}
|
||||||
|
|
||||||
fix_lines(p);
|
fix_lines(p);
|
||||||
|
|
||||||
builder := strings.make_builder(p.allocator);
|
builder := strings.make_builder(p.allocator);
|
||||||
@@ -163,12 +169,17 @@ print :: proc(p: ^Printer, file: ^ast.File) -> string {
|
|||||||
fix_lines :: proc(p: ^Printer) {
|
fix_lines :: proc(p: ^Printer) {
|
||||||
align_comments(p);
|
align_comments(p);
|
||||||
align_var_decls(p);
|
align_var_decls(p);
|
||||||
|
align_blocks(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
align_var_decls :: proc(p: ^Printer) {
|
align_var_decls :: proc(p: ^Printer) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
align_blocks :: proc(p: ^Printer) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
align_comments :: proc(p: ^Printer) {
|
align_comments :: proc(p: ^Printer) {
|
||||||
|
|
||||||
Comment_Align_Info :: struct {
|
Comment_Align_Info :: struct {
|
||||||
@@ -222,6 +233,10 @@ align_comments :: proc(p: ^Printer) {
|
|||||||
|
|
||||||
for info in comment_infos {
|
for info in comment_infos {
|
||||||
|
|
||||||
|
if info.begin == info.end {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for i := info.begin; i <= info.end; i += 1 {
|
for i := info.begin; i <= info.end; i += 1 {
|
||||||
|
|
||||||
l := p.lines[i];
|
l := p.lines[i];
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ push_comment :: proc(p: ^Printer, comment: tokenizer.Token) -> int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@(private)
|
@(private)
|
||||||
push_comments :: proc(p: ^Printer, pos: tokenizer.Pos, format_token: Format_Token) {
|
push_comments :: proc(p: ^Printer, pos: tokenizer.Pos) {
|
||||||
|
|
||||||
prev_comment: ^tokenizer.Token;
|
prev_comment: ^tokenizer.Token;
|
||||||
prev_comment_lines: int;
|
prev_comment_lines: int;
|
||||||
@@ -183,7 +183,7 @@ append_format_token :: proc(p: ^Printer, format_token: Format_Token) -> ^Format_
|
|||||||
p.space_next_token = false;
|
p.space_next_token = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
push_comments(p, p.source_position, format_token);
|
push_comments(p, p.source_position);
|
||||||
|
|
||||||
unwrapped_line := p.current_line;
|
unwrapped_line := p.current_line;
|
||||||
unwrapped_line.used = true;
|
unwrapped_line.used = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user