@@ -3,7 +3,7 @@ use std::{cell::RefCell, cmp::Ordering, collections::{HashMap, HashSet}, rc::Rc}
33use lsp_types:: { Diagnostic , Position , Range } ;
44use tracing:: { info, trace} ;
55
6- use crate :: { constants:: { BuildSteps , OYarn , DEBUG_STEPS } , core:: { diagnostics:: { create_diagnostic , DiagnosticCode } , entry_point:: { EntryPoint , EntryPointType } , evaluation:: ContextValue , file_mgr:: FileInfo , model:: Model , odoo:: SyncOdoo , symbols:: symbol:: Symbol , xml_data:: { OdooData , XmlDataDelete , XmlDataMenuItem , OdooDataRecord , XmlDataTemplate } } , oyarn, threads:: SessionInfo , utils:: compare_semver, Sy } ;
6+ use crate :: { Sy , constants:: { BuildSteps , DEBUG_STEPS , OYarn } , core:: { diagnostics:: { DiagnosticCode , create_diagnostic } , entry_point:: { EntryPoint , EntryPointType } , evaluation:: ContextValue , file_mgr:: { FileInfo , FileMgr } , model:: Model , odoo:: SyncOdoo , symbols:: symbol:: Symbol , xml_data:: { OdooData , OdooDataRecord , XmlDataDelete , XmlDataMenuItem , XmlDataTemplate } } , oyarn, threads:: SessionInfo , utils:: compare_semver} ;
77
88
99
@@ -128,6 +128,21 @@ impl XmlValidator {
128128 //TODO check that the language exists
129129 }
130130 }
131+ // Validate field ref_key
132+ if let Some ( ( ref_key_val, ref_key_range) ) = field. ref_key . as_ref ( ) {
133+ let xml_id_split: Vec < _ > = ref_key_val. split ( '.' ) . collect ( ) ;
134+ if xml_id_split. len ( ) > 1 {
135+ let module_name = xml_id_split[ 0 ] ;
136+ if session. sync_odoo . modules . get ( module_name) . is_none ( ) {
137+ if let Some ( diagnostic) = create_diagnostic ( session, DiagnosticCode :: OLS05003 , & [ ] ) {
138+ diagnostics. push ( Diagnostic {
139+ range : Range { start : Position :: new ( ref_key_range. start . try_into ( ) . unwrap ( ) , 0 ) , end : Position :: new ( ref_key_range. end . try_into ( ) . unwrap ( ) , 0 ) } ,
140+ ..diagnostic
141+ } ) ;
142+ }
143+ }
144+ }
145+ }
131146 //Check that the field belong to the model
132147 if all_fields. contains_key ( & field_name) {
133148 mandatory_fields. retain ( |f| f != & field_name. to_string ( ) ) ;
0 commit comments