fmt: handle indents

pull/4385/head
Alexander Medvednikov 2020-04-13 16:36:32 +02:00
parent 2bd22aa4a4
commit c36984cc94
5 changed files with 29 additions and 4 deletions

View File

@ -529,7 +529,11 @@ fn (f mut Fmt) expr(node ast.Expr) {
f.write('_') f.write('_')
} else { } else {
name := short_module(it.name) name := short_module(it.name)
//f.write('<$it.name => $name>')
f.write(name) f.write(name)
if name.contains('.') {
f.mark_module_as_used(name)
}
} }
} }
ast.InfixExpr { ast.InfixExpr {
@ -669,6 +673,7 @@ fn (f mut Fmt) expr(node ast.Expr) {
} }
ast.StructInit { ast.StructInit {
type_sym := f.table.get_type_symbol(it.typ) type_sym := f.table.get_type_symbol(it.typ)
//f.write('<old name: $type_sym.name>')
mut name := short_module(type_sym.name).replace(f.cur_mod + '.', '') // TODO f.type_to_str? mut name := short_module(type_sym.name).replace(f.cur_mod + '.', '') // TODO f.type_to_str?
if name == 'void' { if name == 'void' {
name = '' name = ''

View File

@ -3,5 +3,10 @@ import (
os os
) )
const (
mypi = math.pi
)
fn main() { fn main() {
println(os.path_separator)
} }

View File

@ -1,5 +1,10 @@
import math import math
import os import os
const (
mypi = math.pi
)
fn main() { fn main() {
println(os.path_separator)
} }

View File

@ -1,8 +1,13 @@
import ( import (
math as m
os os
math.complex as c math
) )
fn main() { fn main() {
// println(m.pi)
println(os.path_separator)
println(math.pi)
// math as m
// import math.complex as c
// num := c.Complex{} TODO
} }

View File

@ -1,6 +1,11 @@
import math as m
import os import os
import math.complex as c import math
fn main() { fn main() {
// println(m.pi)
println(os.path_separator)
println(math.pi)
// math as m
// import math.complex as c
// num := c.Complex{} TODO
} }