@@ -6,7 +6,7 @@ use weak_table::PtrWeakHashSet;
66use std:: collections:: { HashMap , HashSet } ;
77
88use 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 } ;
1010use crate :: core:: import_resolver:: find_module;
1111use crate :: core:: model:: Model ;
1212use crate :: core:: odoo:: SyncOdoo ;
@@ -33,7 +33,7 @@ pub struct ModuleSymbol {
3333 loaded : bool ,
3434 module_name : OYarn ,
3535 pub dir_name : OYarn ,
36- depends : Vec < OYarn > ,
36+ depends : Vec < ( OYarn , TextRange ) > ,
3737 all_depends : HashSet < OYarn > , //computed all depends to avoid too many recomputations
3838 data : Vec < String > , // TODO
3939 pub module_symbols : HashMap < OYarn , Rc < RefCell < Symbol > > > ,
@@ -72,7 +72,7 @@ impl ModuleSymbol {
7272 loaded : false ,
7373 module_name : OYarn :: from ( "" ) ,
7474 dir_name : OYarn :: from ( "" ) ,
75- depends : vec ! ( OYarn :: from( "base" ) ) ,
75+ depends : vec ! ( ( OYarn :: from( "base" ) , TextRange :: default ( ) ) ) ,
7676 all_depends : HashSet :: new ( ) ,
7777 data : Vec :: new ( ) ,
7878 weak_self : None ,
@@ -199,7 +199,7 @@ impl ModuleSymbol {
199199 if depend_value == self . dir_name {
200200 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 ) ;
201201 } else {
202- self . depends . push ( depend_value) ;
202+ self . depends . push ( ( depend_value, depend . range ( ) . clone ( ) ) ) ;
203203 }
204204 }
205205 }
@@ -266,19 +266,19 @@ impl ModuleSymbol {
266266 Returns list of diagnostics to publish in manifest file */
267267 fn _load_depends ( symbol : & mut Symbol , session : & mut SessionInfo , odoo_addons : Rc < RefCell < Symbol > > ) -> ( Vec < Diagnostic > , Vec < OYarn > ) {
268268 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 < _ > > ( ) ;
270270 symbol. as_module_package_mut ( ) . all_depends . extend ( all_depends) ;
271271 let mut diagnostics: Vec < Diagnostic > = vec ! [ ] ;
272272 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 ( ) {
274274 //TODO: raise an error on dependency cycle
275275 if !session. sync_odoo . modules . contains_key ( depend) {
276276 let module = find_module ( session, odoo_addons. clone ( ) , depend) ;
277277 if module. is_none ( ) {
278278 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" ) ) ;
279279 symbol. not_found_paths_mut ( ) . push ( ( BuildSteps :: ARCH , vec ! [ Sy !( "odoo" ) , Sy !( "addons" ) , depend. clone( ) ] ) ) ;
280280 add_diagnostic ( & mut diagnostics, Diagnostic :: new (
281- Range :: new ( Position :: new ( 0 , 0 ) , Position :: new ( 0 , 1 ) ) ,
281+ FileMgr :: textRange_to_temporary_Range ( range ) ,
282282 Some ( DiagnosticSeverity :: ERROR ) ,
283283 Some ( NumberOrString :: String ( S ! ( "OLS30210" ) ) ) ,
284284 Some ( EXTENSION_NAME . to_string ( ) ) ,
0 commit comments