=== modified file 'rules/annotations/menu_scoping.rules'
--- rules/annotations/menu_scoping.rules	2018-12-20 18:16:17 +0000
+++ rules/annotations/menu_scoping.rules	2020-03-20 18:00:42 +0000
@@ -89,6 +89,11 @@
    <variable name="parentId"    type="java.lang.Long" />
    <variable name="defRef"      type="com.goldencode.ast.Aast" />
 
+   <!-- Map menus, submenus, menu items to their javanames -->
+   <variable name="keys_jnames" type="java.util.Map" />
+   <variable name="menukey"     type="java.lang.String" />
+   <variable name="jname"       type="java.lang.String" />
+    
    <!--
       Map of unqualified MENU-ITEMs to their resolved MENUs,
       the map key is MENU-ITEM and the value is DEFINE MENU Ast
@@ -119,7 +124,9 @@
          <return    name="cur"   type="java.lang.String" />
           
          <rule>true
-            <action>parnt = sm_menus.get(sm)</action>
+            <action>menukey = sm.toLowerCase()</action>
+            <action>parnt = sm_menus.get(menukey)</action>
+            <!--<action>printfln("find_sm_menu-> %s = sm_menus.get(%s)", parnt, menukey)</action>-->
             <action>cur = parnt</action>
             <while>parnt != null and sm_menus.containsKey(parnt)
                <!--<action>printfln("parnt: %s, sm_menus.get(parnt): %s", parnt, sm_menus.get(parnt))</action>-->
@@ -135,7 +142,8 @@
          <return    name="res"   type="java.lang.Boolean" />
 
          <rule>true
-            <action>sm = names.convert(smRef.text, names.variable)</action>
+            <action>sm = names.convert(smRef.text.toLowerCase(), names.variable)</action>
+            <!--<action>printfln("is_submenu-> %s = names.convert(%s, names.variable)", sm, smRef.text.toLowerCase())</action>-->
             <action>res = sm_menus.containsKey(sm)</action>
          </rule>
       </function>
@@ -143,6 +151,7 @@
 
    <init-rules>
       <rule>menu_defs = #(java.util.Map) create('java.util.HashMap')</rule>
+      <rule>keys_jnames = #(java.util.Map) create('java.util.HashMap')</rule>
       <rule>sm_menus = #(java.util.Map) create('java.util.HashMap')</rule>
       <rule>items = #(java.util.Map) create('java.util.HashMap')</rule>
       <rule>items_subs = #(java.util.Map) create('java.util.HashMap')</rule>
@@ -157,7 +166,13 @@
    <!-- main processing (once per tree) -->
    <walk-rules>
       <rule>type == prog.define_menu
-         <action>menu_defs.put(getNoteString("name").toLowerCase(), this.id)</action>
+         <action>menukey = getNoteString("name").toLowerCase()</action>
+         <action>menu_defs.put(menukey, this.id)</action>
+         <!--<action>printfln("menu_defs.put(%s, %s)", menukey, this.id)</action>-->
+         <!-- this rule is executed after variable_definition rules that set menu javaname -->
+         <rule>!keys_jnames.containsKey(menukey)
+            <action>keys_jnames.put(menukey, this.getAnnotation("javaname"))</action>
+         </rule>
       </rule>
       <rule>type == prog.wid_menu and menu_defs.containsKey(this.text.toLowerCase())
          <action>putNote("refid", #(long) menu_defs.get(this.text.toLowerCase()))</action>
@@ -169,8 +184,9 @@
       <rule>type == prog.wid_sub_menu and
             parent.type == prog.kw_sub_menu 
            
-         <action>submenu = names.convert(text, names.variable)</action>
- 
+         <action>submenu = names.convert(text.toLowerCase(), names.variable)</action>
+         <!--<action>printfln("%s = names.convert(%s, names.variable)", submenu, text.toLowerCase())</action>-->
+         
          <rule>parent.parent != null and
                (parent.parent.type == prog.define_menu or
                parent.parent.type == prog.define_sub_menu) and 
@@ -191,19 +207,30 @@
             <action>ref = this.getAncestor(2).getImmediateChild(prog.kw_in, null)</action>
             <!-- MENU references in triggers have different AST structure than in assignments -->
             <rule>ref == null
-               <action>ref = this.getAncestor(1).getImmediateChild(prog.kw_in, null)</action>              
+               <action>ref = this.getAncestor(1).getImmediateChild(prog.kw_in, null)</action>
             </rule>
             <rule>ref != null
                <action>ref = ref.getImmediateChild(kw_m_or_sm, null)</action>
                <action>ref = ref.getImmediateChild(wid_m_or_sm, null)</action>
-               <action>
-                  putNote(sprintf("IN_%s", ref.getSymbolicTokenType()), 
-                          names.convert(ref.text, names.variable))
-               </action>
-               <action>
-                  putNote(sprintf("IN_%s_ID", ref.getSymbolicTokenType()), ref.id)
-               </action>
-            </rule>
+               <action>menukey = ref.text.toLowerCase()</action>
+               <action>jname = keys_jnames.get(menukey)</action>
+               <rule>jname == null
+                  <action>jname = names.convert(ref.text, names.variable)</action>
+                  <action>printfln("Not found javaname for %s of %s)", menukey, ref.text)</action>
+               </rule>
+               <action>putNote(sprintf("IN_%s", ref.getSymbolicTokenType()), jname)</action>
+               <action>putNote(sprintf("IN_%s_ID", ref.getSymbolicTokenType()), ref.id)</action>
+            </rule>
+      </rule>
+
+      <rule>type == prog.define_sub_menu
+         <action>menukey = getNoteString("name")</action>
+         <rule> menukey != null
+            <action>menukey = menukey.toLowerCase()</action>
+            <rule>!keys_jnames.containsKey(menukey)
+               <action>keys_jnames.put(menukey, this.getAnnotation("javaname"))</action>
+            </rule>
+         </rule>
       </rule>
 
       <!--
@@ -224,16 +251,28 @@
       -->
       <rule>type == prog.kw_menu_itm and parent.type == prog.define_menu
          <action>item = names.convert(#(java.lang.String) this.getAnnotation("name"), names.variable)</action>
-         <action>items.put(item, parent)</action>
+         <action>items.put(item.toLowerCase(), parent)</action>
+         <!--<action>printfln("items.put(%s, parent)", item.toLowerCase())</action>-->
+         <action>menukey = item.toLowerCase()</action>
+         <rule>!keys_jnames.containsKey(menukey)
+            <action>keys_jnames.put(menukey, this.getAnnotation("javaname"))</action>
+         </rule>
       </rule>
 
+      
       <rule>type == prog.kw_menu_itm and parent.type == prog.define_sub_menu
          <action>item = names.convert(#(java.lang.String) this.getAnnotation("name"), names.variable)</action>
-         <rule>!items.containsKey(item)
-            <action>list = items_subs.get(item)</action>
+         <!--<action>printfln("%s= names.convert(%s, names.variable)", item, this.getAnnotation("name"))</action>-->
+         <action>menukey = item.toLowerCase()</action>
+         <rule>!keys_jnames.containsKey(menukey)
+            <action>keys_jnames.put(menukey, this.getAnnotation("javaname"))</action>
+         </rule>
+         <rule>!items.containsKey(item.toLowerCase())
+            <action>list = items_subs.get(item.toLowerCase())</action>
             <rule>list == null
                <action>list = #(java.util.List) create("java.util.ArrayList")</action>
-               <action>items_subs.put(item, list)</action>
+               <action>items_subs.put(item.toLowerCase(), list)</action>
+               <!--<action>printfln("items_subs.put(%s, list)", item)</action>-->
             </rule>
             <action>list.add(parent)</action>
          </rule>
@@ -245,13 +284,25 @@
             parent.parent.type != prog.define_sub_menu
  
             <action>ref = this.getAncestor(2).getImmediateChild(prog.kw_in, null)</action>
+            <!--<rule>ref != null
+               <action>printfln("1. %s->%s", ref.id, ref.dumpTree())</action>
+            </rule>-->
              <!-- MENU references in triggers have different AST structure than in assignments -->
             <rule>ref == null
-               <action>ref = this.getAncestor(1).getImmediateChild(prog.kw_in, null)</action>              
+               <action>ref = this.getAncestor(1).getImmediateChild(prog.kw_in, null)</action>
+               <!--<rule>ref != null
+                  <action>printfln("2. %s->%s", ref.id, ref.dumpTree())</action>
+               </rule>-->
             </rule>
             <rule>ref != null
                <action>ref = ref.getImmediateChild(kw_m_or_sm, null)</action>
+               <!--<rule>ref != null
+                  <action>printfln("3. %s->%s", ref.id, ref.dumpTree())</action>
+               </rule>-->
                <action>ref = ref.getImmediateChild(wid_m_or_sm, null)</action>
+               <!--<rule>ref != null
+                  <action>printfln("4. %s->%s", ref.id, ref.dumpTree())</action>
+               </rule>-->
                <action>
                   <!--
                      Progress allows the MENU keyword in place of SUB-MENU when qualifying items or
@@ -263,16 +314,24 @@
                   <action>symToken = "wid_sub_menu"</action>
                   <action on="false">symToken = ref.getSymbolicTokenType()</action>
                </rule>
-               <action>
-                  putNote(sprintf("IN_%s", symToken), names.convert(ref.text, names.variable))
-               </action>
-               <action>
-                  putNote(sprintf("IN_%s_ID", symToken), ref.id)
-               </action>
+               <action>menukey = ref.text.toLowerCase()</action>
+               <action>jname = keys_jnames.get(menukey)</action>
+               <rule>jname == null
+                  <action>jname = names.convert(ref.text, names.variable)</action>
+                  <action>printfln("Not found javaname for %s of %s", menukey, ref.text)</action>
+               </rule>
+               <rule>jname != null
+                  <action>putNote(sprintf("IN_%s", symToken), jname)</action>
+               </rule>
+               <action>putNote(sprintf("IN_%s_ID", symToken), ref.id)</action>
             </rule>
 
             <rule>ref == null
-               <action>ref = items.get(names.convert(text, names.variable))</action>
+               <action>ref = items.get(names.convert(text.toLowerCase(), names.variable))</action>
+               <!--<action>printfln("ref = items.get(names.convert(%s, names.variable))", text.toLowerCase())</action>-->
+               <!--<rule>ref != null
+                  <action>printfln("5. %s->%s", ref.id, ref.dumpTree())</action>
+               </rule>-->
             </rule>
 
             <rule>ref != null
@@ -308,7 +367,8 @@
               #(java.lang.Boolean) execLib("is_submenu", this))) and
              parent.parent.type != prog.define_menu and
              parent.parent.type != prog.define_sub_menu
-         <action>menu = execLib("find_sm_menu", names.convert(text, names.variable))</action>
+         <action>menu = execLib("find_sm_menu", names.convert(text.toLowerCase(), names.variable))</action>
+         <!--<action>printfln("%s = execLib('find_sm_menu', names.convert(%s, names.variable))", menu, text.toLowerCase())</action>-->
          <rule>menu != null
             <action>putNote("first-menu-path", menu)</action>
             <action>putNote("in_wid_menu", menu)</action>

=== modified file 'rules/convert/methods_attributes.rules'
--- rules/convert/methods_attributes.rules	2020-03-17 02:40:10 +0000
+++ rules/convert/methods_attributes.rules	2020-03-18 18:59:30 +0000
@@ -4939,6 +4939,7 @@
                     implementation -->
                <rule>ftype == prog.kw_handle and 
                           (evalLib("widgettype", ref.type) or
+                           ref.type == prog.kw_menu_itm    or
                            ref.type == prog.kw_sub_menu    or
                            ref.type == prog.kw_menu)
                   <action>hwrap = "Widget"</action>

=== modified file 'rules/convert/widget_references.rules'
--- rules/convert/widget_references.rules	2019-07-16 10:15:56 +0000
+++ rules/convert/widget_references.rules	2020-03-20 17:12:39 +0000
@@ -316,7 +316,7 @@
                <action>menu_wo_in = false</action>
             </rule>
          
-            <rule>this.getAnnotation("in_wid_sub_menu") != null
+            <rule>menu_wo_in and this.getAnnotation("in_wid_sub_menu") != null
                <action>menu = #(java.lang.String)this.getAnnotation("in_wid_sub_menu")</action> 
                <action>
                   lastid = tw.graft("double_method_call", null, closestPeerId,

