Project

General

Profile

4589_6.patch

Sergey Ivanovskiy, 03/20/2020 02:02 PM

Download (12.3 KB)

View differences:

rules/annotations/menu_scoping.rules 2020-03-20 18:00:42 +0000
89 89
   <variable name="parentId"    type="java.lang.Long" />
90 90
   <variable name="defRef"      type="com.goldencode.ast.Aast" />
91 91

  
92
   <!-- Map menus, submenus, menu items to their javanames -->
93
   <variable name="keys_jnames" type="java.util.Map" />
94
   <variable name="menukey"     type="java.lang.String" />
95
   <variable name="jname"       type="java.lang.String" />
96
    
92 97
   <!--
93 98
      Map of unqualified MENU-ITEMs to their resolved MENUs,
94 99
      the map key is MENU-ITEM and the value is DEFINE MENU Ast
......
119 124
         <return    name="cur"   type="java.lang.String" />
120 125
          
121 126
         <rule>true
122
            <action>parnt = sm_menus.get(sm)</action>
127
            <action>menukey = sm.toLowerCase()</action>
128
            <action>parnt = sm_menus.get(menukey)</action>
129
            <!--<action>printfln("find_sm_menu-> %s = sm_menus.get(%s)", parnt, menukey)</action>-->
123 130
            <action>cur = parnt</action>
124 131
            <while>parnt != null and sm_menus.containsKey(parnt)
125 132
               <!--<action>printfln("parnt: %s, sm_menus.get(parnt): %s", parnt, sm_menus.get(parnt))</action>-->
......
135 142
         <return    name="res"   type="java.lang.Boolean" />
136 143

  
137 144
         <rule>true
138
            <action>sm = names.convert(smRef.text, names.variable)</action>
145
            <action>sm = names.convert(smRef.text.toLowerCase(), names.variable)</action>
146
            <!--<action>printfln("is_submenu-> %s = names.convert(%s, names.variable)", sm, smRef.text.toLowerCase())</action>-->
139 147
            <action>res = sm_menus.containsKey(sm)</action>
140 148
         </rule>
141 149
      </function>
......
143 151

  
144 152
   <init-rules>
145 153
      <rule>menu_defs = #(java.util.Map) create('java.util.HashMap')</rule>
154
      <rule>keys_jnames = #(java.util.Map) create('java.util.HashMap')</rule>
146 155
      <rule>sm_menus = #(java.util.Map) create('java.util.HashMap')</rule>
147 156
      <rule>items = #(java.util.Map) create('java.util.HashMap')</rule>
148 157
      <rule>items_subs = #(java.util.Map) create('java.util.HashMap')</rule>
......
157 166
   <!-- main processing (once per tree) -->
158 167
   <walk-rules>
159 168
      <rule>type == prog.define_menu
160
         <action>menu_defs.put(getNoteString("name").toLowerCase(), this.id)</action>
169
         <action>menukey = getNoteString("name").toLowerCase()</action>
170
         <action>menu_defs.put(menukey, this.id)</action>
171
         <!--<action>printfln("menu_defs.put(%s, %s)", menukey, this.id)</action>-->
172
         <!-- this rule is executed after variable_definition rules that set menu javaname -->
173
         <rule>!keys_jnames.containsKey(menukey)
174
            <action>keys_jnames.put(menukey, this.getAnnotation("javaname"))</action>
175
         </rule>
161 176
      </rule>
162 177
      <rule>type == prog.wid_menu and menu_defs.containsKey(this.text.toLowerCase())
163 178
         <action>putNote("refid", #(long) menu_defs.get(this.text.toLowerCase()))</action>
......
169 184
      <rule>type == prog.wid_sub_menu and
170 185
            parent.type == prog.kw_sub_menu 
171 186
           
172
         <action>submenu = names.convert(text, names.variable)</action>
173
 
187
         <action>submenu = names.convert(text.toLowerCase(), names.variable)</action>
188
         <!--<action>printfln("%s = names.convert(%s, names.variable)", submenu, text.toLowerCase())</action>-->
189
         
174 190
         <rule>parent.parent != null and
175 191
               (parent.parent.type == prog.define_menu or
176 192
               parent.parent.type == prog.define_sub_menu) and 
......
191 207
            <action>ref = this.getAncestor(2).getImmediateChild(prog.kw_in, null)</action>
192 208
            <!-- MENU references in triggers have different AST structure than in assignments -->
193 209
            <rule>ref == null
194
               <action>ref = this.getAncestor(1).getImmediateChild(prog.kw_in, null)</action>              
210
               <action>ref = this.getAncestor(1).getImmediateChild(prog.kw_in, null)</action>
195 211
            </rule>
196 212
            <rule>ref != null
197 213
               <action>ref = ref.getImmediateChild(kw_m_or_sm, null)</action>
198 214
               <action>ref = ref.getImmediateChild(wid_m_or_sm, null)</action>
199
               <action>
200
                  putNote(sprintf("IN_%s", ref.getSymbolicTokenType()), 
201
                          names.convert(ref.text, names.variable))
202
               </action>
203
               <action>
204
                  putNote(sprintf("IN_%s_ID", ref.getSymbolicTokenType()), ref.id)
205
               </action>
206
            </rule>
215
               <action>menukey = ref.text.toLowerCase()</action>
216
               <action>jname = keys_jnames.get(menukey)</action>
217
               <rule>jname == null
218
                  <action>jname = names.convert(ref.text, names.variable)</action>
219
                  <action>printfln("Not found javaname for %s of %s)", menukey, ref.text)</action>
220
               </rule>
221
               <action>putNote(sprintf("IN_%s", ref.getSymbolicTokenType()), jname)</action>
222
               <action>putNote(sprintf("IN_%s_ID", ref.getSymbolicTokenType()), ref.id)</action>
223
            </rule>
224
      </rule>
225

  
226
      <rule>type == prog.define_sub_menu
227
         <action>menukey = getNoteString("name")</action>
228
         <rule> menukey != null
229
            <action>menukey = menukey.toLowerCase()</action>
230
            <rule>!keys_jnames.containsKey(menukey)
231
               <action>keys_jnames.put(menukey, this.getAnnotation("javaname"))</action>
232
            </rule>
233
         </rule>
207 234
      </rule>
208 235

  
209 236
      <!--
......
224 251
      -->
225 252
      <rule>type == prog.kw_menu_itm and parent.type == prog.define_menu
226 253
         <action>item = names.convert(#(java.lang.String) this.getAnnotation("name"), names.variable)</action>
227
         <action>items.put(item, parent)</action>
254
         <action>items.put(item.toLowerCase(), parent)</action>
255
         <!--<action>printfln("items.put(%s, parent)", item.toLowerCase())</action>-->
256
         <action>menukey = item.toLowerCase()</action>
257
         <rule>!keys_jnames.containsKey(menukey)
258
            <action>keys_jnames.put(menukey, this.getAnnotation("javaname"))</action>
259
         </rule>
228 260
      </rule>
229 261

  
262
      
230 263
      <rule>type == prog.kw_menu_itm and parent.type == prog.define_sub_menu
231 264
         <action>item = names.convert(#(java.lang.String) this.getAnnotation("name"), names.variable)</action>
232
         <rule>!items.containsKey(item)
233
            <action>list = items_subs.get(item)</action>
265
         <!--<action>printfln("%s= names.convert(%s, names.variable)", item, this.getAnnotation("name"))</action>-->
266
         <action>menukey = item.toLowerCase()</action>
267
         <rule>!keys_jnames.containsKey(menukey)
268
            <action>keys_jnames.put(menukey, this.getAnnotation("javaname"))</action>
269
         </rule>
270
         <rule>!items.containsKey(item.toLowerCase())
271
            <action>list = items_subs.get(item.toLowerCase())</action>
234 272
            <rule>list == null
235 273
               <action>list = #(java.util.List) create("java.util.ArrayList")</action>
236
               <action>items_subs.put(item, list)</action>
274
               <action>items_subs.put(item.toLowerCase(), list)</action>
275
               <!--<action>printfln("items_subs.put(%s, list)", item)</action>-->
237 276
            </rule>
238 277
            <action>list.add(parent)</action>
239 278
         </rule>
......
245 284
            parent.parent.type != prog.define_sub_menu
246 285
 
247 286
            <action>ref = this.getAncestor(2).getImmediateChild(prog.kw_in, null)</action>
287
            <!--<rule>ref != null
288
               <action>printfln("1. %s->%s", ref.id, ref.dumpTree())</action>
289
            </rule>-->
248 290
             <!-- MENU references in triggers have different AST structure than in assignments -->
249 291
            <rule>ref == null
250
               <action>ref = this.getAncestor(1).getImmediateChild(prog.kw_in, null)</action>              
292
               <action>ref = this.getAncestor(1).getImmediateChild(prog.kw_in, null)</action>
293
               <!--<rule>ref != null
294
                  <action>printfln("2. %s->%s", ref.id, ref.dumpTree())</action>
295
               </rule>-->
251 296
            </rule>
252 297
            <rule>ref != null
253 298
               <action>ref = ref.getImmediateChild(kw_m_or_sm, null)</action>
299
               <!--<rule>ref != null
300
                  <action>printfln("3. %s->%s", ref.id, ref.dumpTree())</action>
301
               </rule>-->
254 302
               <action>ref = ref.getImmediateChild(wid_m_or_sm, null)</action>
303
               <!--<rule>ref != null
304
                  <action>printfln("4. %s->%s", ref.id, ref.dumpTree())</action>
305
               </rule>-->
255 306
               <action>
256 307
                  <!--
257 308
                     Progress allows the MENU keyword in place of SUB-MENU when qualifying items or
......
263 314
                  <action>symToken = "wid_sub_menu"</action>
264 315
                  <action on="false">symToken = ref.getSymbolicTokenType()</action>
265 316
               </rule>
266
               <action>
267
                  putNote(sprintf("IN_%s", symToken), names.convert(ref.text, names.variable))
268
               </action>
269
               <action>
270
                  putNote(sprintf("IN_%s_ID", symToken), ref.id)
271
               </action>
317
               <action>menukey = ref.text.toLowerCase()</action>
318
               <action>jname = keys_jnames.get(menukey)</action>
319
               <rule>jname == null
320
                  <action>jname = names.convert(ref.text, names.variable)</action>
321
                  <action>printfln("Not found javaname for %s of %s", menukey, ref.text)</action>
322
               </rule>
323
               <rule>jname != null
324
                  <action>putNote(sprintf("IN_%s", symToken), jname)</action>
325
               </rule>
326
               <action>putNote(sprintf("IN_%s_ID", symToken), ref.id)</action>
272 327
            </rule>
273 328

  
274 329
            <rule>ref == null
275
               <action>ref = items.get(names.convert(text, names.variable))</action>
330
               <action>ref = items.get(names.convert(text.toLowerCase(), names.variable))</action>
331
               <!--<action>printfln("ref = items.get(names.convert(%s, names.variable))", text.toLowerCase())</action>-->
332
               <!--<rule>ref != null
333
                  <action>printfln("5. %s->%s", ref.id, ref.dumpTree())</action>
334
               </rule>-->
276 335
            </rule>
277 336

  
278 337
            <rule>ref != null
......
308 367
              #(java.lang.Boolean) execLib("is_submenu", this))) and
309 368
             parent.parent.type != prog.define_menu and
310 369
             parent.parent.type != prog.define_sub_menu
311
         <action>menu = execLib("find_sm_menu", names.convert(text, names.variable))</action>
370
         <action>menu = execLib("find_sm_menu", names.convert(text.toLowerCase(), names.variable))</action>
371
         <!--<action>printfln("%s = execLib('find_sm_menu', names.convert(%s, names.variable))", menu, text.toLowerCase())</action>-->
312 372
         <rule>menu != null
313 373
            <action>putNote("first-menu-path", menu)</action>
314 374
            <action>putNote("in_wid_menu", menu)</action>
rules/convert/methods_attributes.rules 2020-03-18 18:59:30 +0000
4939 4939
                    implementation -->
4940 4940
               <rule>ftype == prog.kw_handle and 
4941 4941
                          (evalLib("widgettype", ref.type) or
4942
                           ref.type == prog.kw_menu_itm    or
4942 4943
                           ref.type == prog.kw_sub_menu    or
4943 4944
                           ref.type == prog.kw_menu)
4944 4945
                  <action>hwrap = "Widget"</action>
rules/convert/widget_references.rules 2020-03-20 17:12:39 +0000
316 316
               <action>menu_wo_in = false</action>
317 317
            </rule>
318 318
         
319
            <rule>this.getAnnotation("in_wid_sub_menu") != null
319
            <rule>menu_wo_in and this.getAnnotation("in_wid_sub_menu") != null
320 320
               <action>menu = #(java.lang.String)this.getAnnotation("in_wid_sub_menu")</action> 
321 321
               <action>
322 322
                  lastid = tw.graft("double_method_call", null, closestPeerId,