fmt: always use import() syntax

pull/4410/head
Alexander Medvednikov 2020-04-14 18:24:19 +02:00
parent ec10831318
commit 211275ab49
3 changed files with 20 additions and 16 deletions

View File

@ -98,17 +98,18 @@ fn (f mut Fmt) mod(mod ast.Module) {
}
fn (f mut Fmt) imports(imports []ast.Import) {
if f.did_imports {
if f.did_imports || imports.len == 0 {
return
}
f.did_imports = true
// f.import_pos = f.out.len
f.did_imports = true
/*
if imports.len == 1 {
imp_stmt_str := f.imp_stmt_str(imports[0])
f.out_imports.writeln('import ${imp_stmt_str}\n')
} else if imports.len > 1 {
*/
f.out_imports.writeln('import (')
// f.indent++
for imp in imports {
if !(imp.mod in f.used_imports) {
// TODO bring back once only unused imports are removed
@ -117,9 +118,8 @@ fn (f mut Fmt) imports(imports []ast.Import) {
f.out_imports.write('\t')
f.out_imports.writeln(f.imp_stmt_str(imp))
}
// f.indent--
f.out_imports.writeln(')\n')
}
// }
}
fn (f Fmt) imp_stmt_str(imp ast.Import) string {

View File

@ -1,4 +1,6 @@
import os
import (
os
)
fn main() {
}

View File

@ -1,4 +1,6 @@
import time
import (
time
)
fn main() {
println(time.now())