1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: handle indents

This commit is contained in:
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('_')
} else {
name := short_module(it.name)
//f.write('<$it.name => $name>')
f.write(name)
if name.contains('.') {
f.mark_module_as_used(name)
}
}
}
ast.InfixExpr {
@ -669,6 +673,7 @@ fn (f mut Fmt) expr(node ast.Expr) {
}
ast.StructInit {
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?
if name == 'void' {
name = ''

View File

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

View File

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

View File

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