Skip to content

Commit 7e5ebc9

Browse files
committed
[IMP] server: support for @language in XML fields
1 parent a8be098 commit 7e5ebc9

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

server/src/core/xml_validation.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use std::{cell::RefCell, collections::HashMap, hash::Hash, path::PathBuf, rc::Rc};
1+
use std::{cell::RefCell, cmp::Ordering, collections::HashMap, hash::Hash, path::PathBuf, rc::Rc};
22

33
use lsp_types::{Diagnostic, Position, Range};
44
use tracing::{info, trace};
55

6-
use crate::{constants::{BuildSteps, OYarn, SymType, DEBUG_STEPS, EXTENSION_NAME}, core::{diagnostics::{create_diagnostic, DiagnosticCode}, entry_point::{EntryPoint, EntryPointType}, evaluation::ContextValue, file_mgr::FileInfo, model::Model, odoo::SyncOdoo, symbols::symbol::Symbol, xml_data::{XmlData, XmlDataDelete, XmlDataMenuItem, XmlDataRecord, XmlDataTemplate}}, threads::SessionInfo, Sy, S};
6+
use crate::{constants::{BuildSteps, OYarn, SymType, DEBUG_STEPS, EXTENSION_NAME}, core::{diagnostics::{create_diagnostic, DiagnosticCode}, entry_point::{EntryPoint, EntryPointType}, evaluation::ContextValue, file_mgr::FileInfo, model::Model, odoo::SyncOdoo, symbols::symbol::Symbol, xml_data::{XmlData, XmlDataDelete, XmlDataMenuItem, XmlDataRecord, XmlDataTemplate}}, threads::SessionInfo, utils::compare_semver, Sy, S};
77

88

99

@@ -111,6 +111,16 @@ impl XmlValidator {
111111
}
112112
//check each field in the record
113113
for field in &xml_data_record.fields {
114+
let mut field_name = field.name.clone();
115+
let mut has_translation = false;
116+
if compare_semver(&session.sync_odoo.full_version, "18.2.0") >= Ordering::Equal {
117+
let translation = field.name.split("@").collect::<Vec<&str>>();
118+
if translation.len() > 1 {
119+
field_name = translation[0].to_string();
120+
has_translation = true;
121+
//TODO check that the language exists
122+
}
123+
}
114124
//Check that the field belong to the model
115125
let declared_field = all_fields.get(&field.name);
116126
if let Some(_declared_field) = declared_field {
@@ -140,6 +150,9 @@ impl XmlValidator {
140150
}
141151
//TODO check type
142152
} else {
153+
if has_translation {
154+
continue;
155+
}
143156
if let Some(diagnostic) = create_diagnostic(session, DiagnosticCode::OLS05057, &[&field.name, &xml_data_record.model.0]) {
144157
diagnostics.push(Diagnostic {
145158
range: Range { start: Position::new(field.range.start.try_into().unwrap(), 0), end: Position::new(field.range.end.try_into().unwrap(), 0) },

0 commit comments

Comments
 (0)