mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vfmt: remove spurious src.
prefix, from import name
becoming import src.name
(#17633)
This commit is contained in:
parent
42732138c6
commit
f18cc6ebb0
@ -367,7 +367,8 @@ pub fn (mut f Fmt) imports(imports []ast.Import) {
|
|||||||
|
|
||||||
pub fn (f Fmt) imp_stmt_str(imp ast.Import) string {
|
pub fn (f Fmt) imp_stmt_str(imp ast.Import) string {
|
||||||
mod := if imp.mod.len == 0 { imp.alias } else { imp.mod }
|
mod := if imp.mod.len == 0 { imp.alias } else { imp.mod }
|
||||||
is_diff := imp.alias != mod && !mod.ends_with('.' + imp.alias)
|
normalized_mod := mod.all_after('src.') // Ignore the 'src.' folder prefix since src/ folder is root of code
|
||||||
|
is_diff := imp.alias != normalized_mod && !normalized_mod.ends_with('.' + imp.alias)
|
||||||
mut imp_alias_suffix := if is_diff { ' as ${imp.alias}' } else { '' }
|
mut imp_alias_suffix := if is_diff { ' as ${imp.alias}' } else { '' }
|
||||||
mut syms := imp.syms.map(it.name).filter(f.import_syms_used[it])
|
mut syms := imp.syms.map(it.name).filter(f.import_syms_used[it])
|
||||||
syms.sort()
|
syms.sort()
|
||||||
@ -378,7 +379,7 @@ pub fn (f Fmt) imp_stmt_str(imp ast.Import) string {
|
|||||||
' {\n\t' + syms.join(',\n\t') + ',\n}'
|
' {\n\t' + syms.join(',\n\t') + ',\n}'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return '${mod}${imp_alias_suffix}'
|
return '${normalized_mod}${imp_alias_suffix}'
|
||||||
}
|
}
|
||||||
|
|
||||||
//=== Node helpers ===//
|
//=== Node helpers ===//
|
||||||
|
Loading…
Reference in New Issue
Block a user