SVGHMI: Warn at build time when SVG refers to non-existing widget types.
authorEdouard Tisserant
Thu, 14 Jul 2022 11:39:19 +0200
changeset 3556 5d73bed497de
parent 3555 a8b6d5e1fda3
child 3557 59158e360b8c
SVGHMI: Warn at build time when SVG refers to non-existing widget types.
svghmi/widget_list.ysl2
svghmi/widget_textlist.ysl2
svghmi/widget_textstylelist.ysl2
svghmi/widgets_common.ysl2
--- a/svghmi/widget_list.ysl2	Thu Jul 14 11:35:22 2022 +0200
+++ b/svghmi/widget_list.ysl2	Thu Jul 14 11:39:19 2022 +0200
@@ -27,3 +27,4 @@
     |     },
 }
 
+widget_class("List");
--- a/svghmi/widget_textlist.ysl2	Thu Jul 14 11:35:22 2022 +0200
+++ b/svghmi/widget_textlist.ysl2	Thu Jul 14 11:39:19 2022 +0200
@@ -26,3 +26,5 @@
     // could find a proper way in xpath to reverse()
     |     ].reverse(),
 }
+
+widget_class("TextList");
--- a/svghmi/widget_textstylelist.ysl2	Thu Jul 14 11:35:22 2022 +0200
+++ b/svghmi/widget_textstylelist.ysl2	Thu Jul 14 11:39:19 2022 +0200
@@ -26,3 +26,4 @@
     |     },
 }
 
+widget_class("TextStyleList");
--- a/svghmi/widgets_common.ysl2	Thu Jul 14 11:35:22 2022 +0200
+++ b/svghmi/widgets_common.ysl2	Thu Jul 14 11:39:19 2022 +0200
@@ -477,14 +477,17 @@
                                     generate-id() = generate-id(key('TypesKey', @type)) and 
                                     not(@type = $excluded_types)]""";
     apply "$used_widget_types", mode="widget_class";
-}
-
-template "widget", mode="widget_class"
-||
-class «@type»Widget extends Widget{
-    /* empty class, as «@type» widget didn't provide any */
-}
-||
+
+}
+
+template "widget", mode="widget_class" {
+    ||
+    class «@type»Widget extends Widget{
+        /* empty class, as «@type» widget didn't provide any */
+    }
+    ||
+    warning > «@type» widget is used in SVG but widget type is not declared
+}
 
 const "included_ids","$parsed_widgets/widget[not(@type = $excluded_types) and not(@id = $discardable_elements/@id)]/@id";
 const "hmi_widgets","$hmi_elements[@id = $included_ids]";
@@ -494,6 +497,7 @@
     | var hmi_widgets = {
     apply "$hmi_widgets", mode="hmi_widgets";
     | }
+    |
 }
 
 function "defs_by_labels" {