@@ -6,7 +6,7 @@ use weak_table::PtrWeakHashSet;
6
6
use std:: collections:: { HashMap , HashSet } ;
7
7
8
8
use crate :: { constants:: * , oyarn, Sy } ;
9
- use crate :: core:: file_mgr:: { add_diagnostic, FileInfo , NoqaInfo } ;
9
+ use crate :: core:: file_mgr:: { add_diagnostic, FileInfo , FileMgr , NoqaInfo } ;
10
10
use crate :: core:: import_resolver:: find_module;
11
11
use crate :: core:: model:: Model ;
12
12
use crate :: core:: odoo:: SyncOdoo ;
@@ -33,7 +33,7 @@ pub struct ModuleSymbol {
33
33
loaded : bool ,
34
34
module_name : OYarn ,
35
35
pub dir_name : OYarn ,
36
- depends : Vec < OYarn > ,
36
+ depends : Vec < ( OYarn , TextRange ) > ,
37
37
all_depends : HashSet < OYarn > , //computed all depends to avoid too many recomputations
38
38
data : Vec < String > , // TODO
39
39
pub module_symbols : HashMap < OYarn , Rc < RefCell < Symbol > > > ,
@@ -72,7 +72,7 @@ impl ModuleSymbol {
72
72
loaded : false ,
73
73
module_name : OYarn :: from ( "" ) ,
74
74
dir_name : OYarn :: from ( "" ) ,
75
- depends : vec ! ( OYarn :: from( "base" ) ) ,
75
+ depends : vec ! ( ( OYarn :: from( "base" ) , TextRange :: default ( ) ) ) ,
76
76
all_depends : HashSet :: new ( ) ,
77
77
data : Vec :: new ( ) ,
78
78
weak_self : None ,
@@ -199,7 +199,7 @@ impl ModuleSymbol {
199
199
if depend_value == self . dir_name {
200
200
add_diagnostic ( & mut res, self . _create_diagnostic_for_manifest_key ( "A module cannot depends on itself" , S ! ( "OLS30206" ) , & depend. range ( ) , Some ( DiagnosticSeverity :: ERROR ) ) , & session. current_noqa ) ;
201
201
} else {
202
- self . depends . push ( depend_value) ;
202
+ self . depends . push ( ( depend_value, depend . range ( ) . clone ( ) ) ) ;
203
203
}
204
204
}
205
205
}
@@ -266,19 +266,19 @@ impl ModuleSymbol {
266
266
Returns list of diagnostics to publish in manifest file */
267
267
fn _load_depends ( symbol : & mut Symbol , session : & mut SessionInfo , odoo_addons : Rc < RefCell < Symbol > > ) -> ( Vec < Diagnostic > , Vec < OYarn > ) {
268
268
symbol. as_module_package_mut ( ) . all_depends . clear ( ) ;
269
- let all_depends = symbol. as_module_package ( ) . depends . clone ( ) ;
269
+ let all_depends = symbol. as_module_package ( ) . depends . iter ( ) . map ( | ( depend , _ ) | depend . clone ( ) ) . collect :: < Vec < _ > > ( ) ;
270
270
symbol. as_module_package_mut ( ) . all_depends . extend ( all_depends) ;
271
271
let mut diagnostics: Vec < Diagnostic > = vec ! [ ] ;
272
272
let mut loaded: Vec < OYarn > = vec ! [ ] ;
273
- for depend in symbol. as_module_package ( ) . depends . clone ( ) . iter ( ) {
273
+ for ( depend, range ) in symbol. as_module_package ( ) . depends . clone ( ) . iter ( ) {
274
274
//TODO: raise an error on dependency cycle
275
275
if !session. sync_odoo . modules . contains_key ( depend) {
276
276
let module = find_module ( session, odoo_addons. clone ( ) , depend) ;
277
277
if module. is_none ( ) {
278
278
symbol. get_entry ( ) . unwrap ( ) . borrow_mut ( ) . not_found_symbols . insert ( symbol. weak_self ( ) . as_ref ( ) . unwrap ( ) . upgrade ( ) . expect ( "The symbol must be in the tree" ) ) ;
279
279
symbol. not_found_paths_mut ( ) . push ( ( BuildSteps :: ARCH , vec ! [ Sy !( "odoo" ) , Sy !( "addons" ) , depend. clone( ) ] ) ) ;
280
280
add_diagnostic ( & mut diagnostics, Diagnostic :: new (
281
- Range :: new ( Position :: new ( 0 , 0 ) , Position :: new ( 0 , 1 ) ) ,
281
+ FileMgr :: textRange_to_temporary_Range ( range ) ,
282
282
Some ( DiagnosticSeverity :: ERROR ) ,
283
283
Some ( NumberOrString :: String ( S ! ( "OLS30210" ) ) ) ,
284
284
Some ( EXTENSION_NAME . to_string ( ) ) ,
0 commit comments