fmt: fix import alias

pull/3807/head
Alexander Medvednikov 2020-02-21 20:12:55 +01:00
parent 9be87d03f5
commit 7acf8efde3
1 changed files with 3 additions and 1 deletions

View File

@ -84,7 +84,8 @@ fn (f mut Fmt) imports(imports []ast.Import) {
} }
fn (f Fmt) imp_stmt_str(imp ast.Import) string { fn (f Fmt) imp_stmt_str(imp ast.Import) string {
imp_alias_suffix := if imp.alias != imp.mod { ' as ${imp.alias}' } else { '' } is_diff := imp.alias != imp.mod && !imp.mod.ends_with('.' + imp.alias)
imp_alias_suffix := if is_diff { ' as ${imp.alias}' } else { '' }
return '${imp.mod}${imp_alias_suffix}' return '${imp.mod}${imp_alias_suffix}'
} }
@ -127,6 +128,7 @@ fn (f mut Fmt) stmt(node ast.Stmt) {
for i, field in it.fields { for i, field in it.fields {
f.write('$field.name = ') f.write('$field.name = ')
f.expr(it.exprs[i]) f.expr(it.exprs[i])
f.writeln('')
} }
f.indent-- f.indent--
f.writeln('\n)\n') f.writeln('\n)\n')