@@ -3,7 +3,7 @@ use std::{cell::RefCell, collections::HashMap, hash::Hash, path::PathBuf, rc::Rc
3
3
use lsp_types:: { Diagnostic , Position , Range } ;
4
4
use tracing:: { info, trace} ;
5
5
6
- use crate :: { constants:: { BuildSteps , SymType , DEBUG_STEPS , EXTENSION_NAME } , core:: { entry_point:: { EntryPoint , EntryPointType } , file_mgr:: FileInfo , model:: Model , odoo:: SyncOdoo , symbols:: symbol:: Symbol , xml_data:: { XmlData , XmlDataActWindow , XmlDataDelete , XmlDataMenuItem , XmlDataRecord , XmlDataReport , XmlDataTemplate } } , threads:: SessionInfo , S } ;
6
+ use crate :: { constants:: { BuildSteps , SymType , DEBUG_STEPS , EXTENSION_NAME } , core:: { entry_point:: { EntryPoint , EntryPointType } , evaluation :: ContextValue , file_mgr:: FileInfo , model:: Model , odoo:: SyncOdoo , symbols:: symbol:: Symbol , xml_data:: { XmlData , XmlDataActWindow , XmlDataDelete , XmlDataMenuItem , XmlDataRecord , XmlDataReport , XmlDataTemplate } } , threads:: SessionInfo , S } ;
7
7
8
8
9
9
@@ -89,9 +89,30 @@ impl XmlValidator {
89
89
dependencies. push ( main_sym. borrow ( ) . get_file ( ) . unwrap ( ) . upgrade ( ) . unwrap ( ) ) ;
90
90
}
91
91
let all_fields = Symbol :: all_fields ( & main_symbols[ 0 ] , session, Some ( module. clone ( ) ) ) ;
92
+ let mut mandatory_fields: Vec < String > = vec ! [ ] ;
93
+ // for (field_name, field_sym) in all_fields.iter() {
94
+ // for (fs, deps) in field_sym.iter() {
95
+ // if deps.is_none() {
96
+ // let has_required = fs.borrow().evaluations().unwrap_or(&vec![]).iter()
97
+ // .any(|eval|
98
+ // eval.symbol.get_symbol_as_weak(session, &mut None, diagnostics, None)
99
+ // .context.get("required").unwrap_or(&ContextValue::BOOLEAN(false)).as_bool()
100
+ // );
101
+ // let has_default = fs.borrow().evaluations().unwrap_or(&vec![]).iter()
102
+ // .any(|eval|
103
+ // eval.symbol.get_symbol_as_weak(session, &mut None, diagnostics, None)
104
+ // .context.contains_key("default")
105
+ // );
106
+ // if has_required && !has_default {
107
+ // mandatory_fields.push(field_name.clone());
108
+ // }
109
+ // }
110
+ // }
111
+ // }
92
112
for field in & xml_data_record. fields {
93
113
let declared_field = all_fields. get ( & field. name ) ;
94
114
if let Some ( declared_field) = declared_field {
115
+ mandatory_fields. retain ( |f| f != & field. name ) ;
95
116
//TODO Check type
96
117
} else {
97
118
@@ -106,6 +127,17 @@ impl XmlValidator {
106
127
) ) ;
107
128
}
108
129
}
130
+ // if mandatory_fields.len() > 0 {
131
+ // diagnostics.push(Diagnostic::new(
132
+ // Range::new(Position::new(xml_data_record.range.start.try_into().unwrap(), 0), Position::new(xml_data_record.range.end.try_into().unwrap(), 0)),
133
+ // Some(lsp_types::DiagnosticSeverity::ERROR),
134
+ // Some(lsp_types::NumberOrString::String(S!("OLS30452"))),
135
+ // Some(EXTENSION_NAME.to_string()),
136
+ // format!("Some mandatory fields are not declared in the record: {:?}", mandatory_fields),
137
+ // None,
138
+ // None
139
+ // ));
140
+ // }
109
141
}
110
142
111
143
fn validate_menu_item ( & self , session : & mut SessionInfo , module : & Rc < RefCell < Symbol > > , xml_data_menu_item : & XmlDataMenuItem , diagnostics : & mut Vec < Diagnostic > , dependencies : & mut Vec < Rc < RefCell < Symbol > > > , model_dependencies : & mut Vec < Rc < RefCell < Model > > > ) {
0 commit comments