@@ -11,7 +11,7 @@ use std::path::PathBuf;
1111use std:: rc:: Weak ;
1212use std:: { cell:: RefCell , rc:: Rc } ;
1313
14- use crate :: constants:: SymType ;
14+ use crate :: constants:: { PackageType , SymType } ;
1515use crate :: constants:: OYarn ;
1616use crate :: core:: evaluation:: { Context , ContextValue , Evaluation , EvaluationSymbolPtr , EvaluationSymbolWeak , EvaluationValue } ;
1717use crate :: core:: symbols:: symbol:: Symbol ;
@@ -320,7 +320,14 @@ impl FeaturesUtils {
320320 vec ! [ ]
321321 }
322322
323- pub fn build_markdown_description ( session : & mut SessionInfo , file_symbol : Option < Rc < RefCell < Symbol > > > , evals : & Vec < Evaluation > , call_expr : & Option < ExprCall > , offset : Option < usize > ) -> String {
323+ pub fn build_markdown_description (
324+ session : & mut SessionInfo ,
325+ file_symbol : Option < Rc < RefCell < Symbol > > > ,
326+ file_path : Option < & String > ,
327+ evals : & Vec < Evaluation > ,
328+ call_expr : & Option < ExprCall > ,
329+ offset : Option < usize >
330+ ) -> String {
324331 #[ derive( Debug , Eq , PartialEq , Hash ) ]
325332 struct SymbolKey {
326333 name : OYarn ,
@@ -339,6 +346,21 @@ impl FeaturesUtils {
339346 if let Some ( EvaluationValue :: CONSTANT ( Expr :: StringLiteral ( expr) ) ) = eval. value . as_ref ( ) {
340347 let mut block = S ! ( "" ) ;
341348 let str = expr. value . to_string ( ) ;
349+ if let Some ( SymType :: PACKAGE ( PackageType :: MODULE ) ) = file_symbol. as_ref ( ) . map ( |fs| fs. borrow ( ) . typ ( ) )
350+ && file_path. map_or ( false , |fp| fp. ends_with ( "__manifest__.py" ) ) {
351+ // If we are in manifest, we check if the string is a module and list the underlying module dependencies
352+ if let Some ( module) = session. sync_odoo . modules . get ( & oyarn ! ( "{}" , str ) ) . and_then ( |m| m. upgrade ( ) ) {
353+ block += format ! ( "Module: {}" , module. borrow( ) . name( ) ) . as_str ( ) ;
354+ let module_ref = module. borrow ( ) ;
355+ let dependencies = module_ref. as_module_package ( ) . get_all_depends ( ) ;
356+ if !dependencies. is_empty ( ) {
357+ block += " \n *** \n Dependencies: \n " ;
358+ block += & dependencies. iter ( ) . map ( |dep| format ! ( "- {}" , dep) ) . join ( " \n " ) ;
359+ }
360+ }
361+ blocks. push ( block) ;
362+ continue ;
363+ }
342364 let from_module = file_symbol. as_ref ( ) . and_then ( |file_symbol| file_symbol. borrow ( ) . find_module ( ) ) ;
343365 if let ( Some ( call_expression) , Some ( file_sym) , Some ( offset) ) = ( call_expr, file_symbol. as_ref ( ) , offset) {
344366 let mut special_string_syms = FeaturesUtils :: check_for_string_special_syms ( session, & str, call_expression, offset, expr. range , file_sym) ;
@@ -365,7 +387,7 @@ impl FeaturesUtils {
365387 . chain ( evals. iter ( ) . take ( index) . cloned ( ) )
366388 . chain ( evals. iter ( ) . skip ( index + 1 ) . cloned ( ) )
367389 . collect ( ) ;
368- let r = FeaturesUtils :: build_markdown_description ( session, file_symbol, & string_domain_fields_evals, call_expr, Some ( offset) ) ;
390+ let r = FeaturesUtils :: build_markdown_description ( session, file_symbol, file_path , & string_domain_fields_evals, call_expr, Some ( offset) ) ;
369391 // remove the injected `base_attr` context value
370392 special_string_syms. iter_mut ( ) . for_each ( |sym_rc| {
371393 sym_rc. borrow_mut ( ) . evaluations_mut ( ) . into_iter ( ) . flatten ( ) . for_each ( |eval| {
0 commit comments