checker: remove mod_file_cacher exception
parent
3d83934caf
commit
86862d6a94
|
@ -197,7 +197,8 @@ fn module_path(mod string) string {
|
||||||
|
|
||||||
pub fn (b Builder) find_module_path(mod, fpath string) ?string {
|
pub fn (b Builder) find_module_path(mod, fpath string) ?string {
|
||||||
// support @VROOT/v.mod relative paths:
|
// support @VROOT/v.mod relative paths:
|
||||||
vmod_file_location := vmod.mod_file_cacher.get_by_file(fpath)
|
mcache := vmod.get_cache()
|
||||||
|
vmod_file_location := mcache.get_by_file(fpath)
|
||||||
mod_path := module_path(mod)
|
mod_path := module_path(mod)
|
||||||
mut module_lookup_paths := []string{}
|
mut module_lookup_paths := []string{}
|
||||||
if vmod_file_location.vmod_file.len != 0 && vmod_file_location.vmod_folder !in b.module_search_paths {
|
if vmod_file_location.vmod_file.len != 0 && vmod_file_location.vmod_folder !in b.module_search_paths {
|
||||||
|
|
|
@ -583,10 +583,7 @@ fn (mut c Checker) fail_if_immutable(expr ast.Expr) {
|
||||||
c.error('`$it.name` is immutable, declare it with `mut` to make it mutable',
|
c.error('`$it.name` is immutable, declare it with `mut` to make it mutable',
|
||||||
it.pos)
|
it.pos)
|
||||||
}
|
}
|
||||||
} else if it.name in c.const_names {
|
} else if it.name in c.const_names {
|
||||||
if it.name .contains('mod_file_cacher') {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.error('cannot modify constant `$it.name`', it.pos)
|
c.error('cannot modify constant `$it.name`', it.pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,8 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
fn (mut p Parser)resolve_vroot(flag string) string {
|
fn (mut p Parser)resolve_vroot(flag string) string {
|
||||||
vmod_file_location := vmod.mod_file_cacher.get_by_folder(p.file_name_dir)
|
mcache := vmod.get_cache()
|
||||||
|
vmod_file_location := mcache.get_by_folder(p.file_name_dir)
|
||||||
if vmod_file_location.vmod_file.len == 0 {
|
if vmod_file_location.vmod_file.len == 0 {
|
||||||
// There was no actual v.mod file found.
|
// There was no actual v.mod file found.
|
||||||
p.error('To use @VROOT, you need' + ' to have a "v.mod" file in ${p.file_name_dir},' +
|
p.error('To use @VROOT, you need' + ' to have a "v.mod" file in ${p.file_name_dir},' +
|
||||||
|
|
|
@ -807,7 +807,8 @@ pub fn (mut s Scanner) scan() token.Token {
|
||||||
}
|
}
|
||||||
if name == 'VMOD_FILE' {
|
if name == 'VMOD_FILE' {
|
||||||
if s.vmod_file_content.len == 0 {
|
if s.vmod_file_content.len == 0 {
|
||||||
vmod_file_location := vmod.mod_file_cacher.get_by_file( s.file_path )
|
mcache := vmod.get_cache()
|
||||||
|
vmod_file_location := mcache.get_by_file( s.file_path )
|
||||||
if vmod_file_location.vmod_file.len == 0 {
|
if vmod_file_location.vmod_file.len == 0 {
|
||||||
s.error('@VMOD_FILE can be used only in projects, that have v.mod file')
|
s.error('@VMOD_FILE can be used only in projects, that have v.mod file')
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ pub:
|
||||||
vmod_folder string
|
vmod_folder string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ref_only]
|
||||||
pub struct ModFileCacher {
|
pub struct ModFileCacher {
|
||||||
mut:
|
mut:
|
||||||
cache map[string]ModFileAndFolder
|
cache map[string]ModFileAndFolder
|
||||||
|
@ -155,6 +156,8 @@ fn (mut mcache ModFileCacher) get_files(cfolder string) []string {
|
||||||
return files
|
return files
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const (
|
// used during lookup for v.mod to support @VROOT
|
||||||
mod_file_cacher = new_mod_file_cacher() // used during lookup for v.mod to support @VROOT
|
const ( private_file_cacher = new_mod_file_cacher() )
|
||||||
)
|
pub fn get_cache() &ModFileCacher {
|
||||||
|
return private_file_cacher
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue