Skip to content

Commit 7863e72

Browse files
committed
[IMP] server: xml - menuitem - check validity of action attribute
1 parent 1d7e54d commit 7863e72

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

server/src/core/diagnostic_codes_list.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,4 +404,8 @@ OLS05051, DiagnosticSetting::Error, "Invalid XML ID '{0}'. It should not contain
404404
* The given parent_id does not exists in the dependents modules, or is not a menuitem
405405
*/
406406
OLS05052, DiagnosticSetting::Error, "Parent menuitem with id '{0}' does not exist",
407+
/**
408+
* A menuitem is specifying an action that has not been declared before the menuitem.
409+
*/
410+
OLS05053, DiagnosticSetting::Error, "Action with id '{0}' does not exist",
407411
}

server/src/core/xml_arch_builder_rng_validation.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,16 @@ impl XmlArchBuilder {
8989
}
9090
}
9191
}
92-
},
92+
//check that action exists
93+
if self.get_xml_ids(session, attr.value(), &attr, diagnostics).is_empty() {
94+
if let Some(diagnostic) = create_diagnostic(session, DiagnosticCode::OLS05053, &[]) {
95+
diagnostics.push(Diagnostic {
96+
range: Range { start: Position::new(attr.range().start as u32, 0), end: Position::new(attr.range().end as u32, 0) },
97+
..diagnostic.clone()
98+
});
99+
}
100+
}
101+
}
93102
"parent" => {
94103
if is_submenu {
95104
if let Some(diagnostic) = create_diagnostic(session, DiagnosticCode::OLS05012, &[]) {

0 commit comments

Comments
 (0)