@@ -4,7 +4,7 @@ use ruff_text_size::TextSize;
44use std:: path:: PathBuf ;
55use std:: { cell:: RefCell , rc:: Rc } ;
66
7- use crate :: constants:: SymType ;
7+ use crate :: constants:: { PackageType , SymType } ;
88use crate :: core:: evaluation:: { Evaluation , EvaluationValue } ;
99use crate :: core:: file_mgr:: { FileInfo , FileMgr } ;
1010use crate :: core:: odoo:: SyncOdoo ;
@@ -90,6 +90,33 @@ impl DefinitionFeature {
9090 model_found
9191 }
9292
93+ fn check_for_module_string ( session : & mut SessionInfo , eval : & Evaluation , file_symbol : & Rc < RefCell < Symbol > > , links : & mut Vec < LocationLink > ) -> bool {
94+ if file_symbol. borrow ( ) . typ ( ) != SymType :: PACKAGE ( PackageType :: MODULE ) {
95+ // If not on manifest, we don't check for modules
96+ return false ;
97+ } ;
98+ let value = if let Some ( eval_value) = eval. value . as_ref ( ) {
99+ if let EvaluationValue :: CONSTANT ( Expr :: StringLiteral ( expr) ) = eval_value {
100+ oyarn ! ( "{}" , expr. value. to_string( ) )
101+ } else {
102+ return false ;
103+ }
104+ } else {
105+ return false ;
106+ } ;
107+ let Some ( module) = session. sync_odoo . modules . get ( & oyarn ! ( "{}" , value) ) . and_then ( |m| m. upgrade ( ) ) else {
108+ return false ;
109+ } ;
110+ let path = PathBuf :: from ( module. borrow ( ) . paths ( ) [ 0 ] . clone ( ) ) . join ( "__manifest__.py" ) . sanitize ( ) ;
111+ links. push ( LocationLink {
112+ origin_selection_range : None ,
113+ target_uri : FileMgr :: pathname2uri ( & path) ,
114+ target_selection_range : Range :: default ( ) ,
115+ target_range : Range :: default ( ) ,
116+ } ) ;
117+ true
118+ }
119+
93120 fn check_for_xml_id_string ( session : & mut SessionInfo , eval : & Evaluation , file_symbol : & Rc < RefCell < Symbol > > , links : & mut Vec < LocationLink > ) -> bool {
94121 let value = if let Some ( eval_value) = eval. value . as_ref ( ) {
95122 if let EvaluationValue :: CONSTANT ( Expr :: StringLiteral ( expr) ) = eval_value {
@@ -166,6 +193,7 @@ impl DefinitionFeature {
166193 let eval = evaluations[ index] . clone ( ) ;
167194 if DefinitionFeature :: check_for_domain_field ( session, & eval, file_symbol, & call_expr, offset, & mut links) ||
168195 DefinitionFeature :: check_for_compute_string ( session, & eval, file_symbol, & call_expr, offset, & mut links) ||
196+ DefinitionFeature :: check_for_module_string ( session, & eval, file_symbol, & mut links) ||
169197 DefinitionFeature :: check_for_model_string ( session, & eval, file_symbol, & mut links) ||
170198 DefinitionFeature :: check_for_xml_id_string ( session, & eval, file_symbol, & mut links) {
171199 index += 1 ;
0 commit comments