mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: fix module typo detection
This commit is contained in:
parent
075a8e5ccb
commit
5db25352e5
@ -881,8 +881,7 @@ fn (table &Table) identify_typo(name string, current_fn &Fn, fit &FileImportTabl
|
||||
fn (table &Table) find_misspelled_fn(name string, fit &FileImportTable, min_match f32) string {
|
||||
mut closest := f32(0)
|
||||
mut closest_fn := ''
|
||||
is_main_fn := name.starts_with('main__')
|
||||
n1 := if is_main_fn { name.right(6) } else { name }
|
||||
n1 := if name.starts_with('main__') { name.right(6) } else { name }
|
||||
for _, f in table.fns {
|
||||
if n1.len - f.name.len > 2 || f.name.len - n1.len > 2 { continue }
|
||||
if !(f.mod in ['', 'main', 'builtin']) {
|
||||
@ -908,10 +907,10 @@ fn (table &Table) find_misspelled_fn(name string, fit &FileImportTable, min_matc
|
||||
fn (table &Table) find_misspelled_imported_mod(name string, fit &FileImportTable, min_match f32) string {
|
||||
mut closest := f32(0)
|
||||
mut closest_mod := ''
|
||||
n1 := if name.starts_with('main.') { name.right(5) } else { name }
|
||||
for alias, mod in fit.imports {
|
||||
n := '${fit.module_name}.$alias'
|
||||
if !name.starts_with(fit.module_name) || (n.len - name.len > 2 || name.len - n.len > 2) { continue }
|
||||
p := strings.dice_coefficient(name, n)
|
||||
if (n1.len - alias.len > 2 || alias.len - n1.len > 2) { continue }
|
||||
p := strings.dice_coefficient(n1, alias)
|
||||
if p > closest {
|
||||
closest = p
|
||||
closest_mod = '$alias ($mod)'
|
||||
|
Loading…
Reference in New Issue
Block a user