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>
|
... | ... | |
263 |
302 |
<action>symToken = "wid_sub_menu"</action>
|
264 |
303 |
<action on="false">symToken = ref.getSymbolicTokenType()</action>
|
265 |
304 |
</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>
|
|
305 |
<action>menukey = ref.text.toLowerCase()</action>
|
|
306 |
<action>jname = keys_jnames.get(menukey)</action>
|
|
307 |
<rule>jname == null
|
|
308 |
<action>jname = names.convert(ref.text, names.variable)</action>
|
|
309 |
<action>printfln("Not found javaname for %s of %s", menukey, ref.text)</action>
|
|
310 |
</rule>
|
|
311 |
<rule>jname != null
|
|
312 |
<action>putNote(sprintf("IN_%s", symToken), jname)</action>
|
|
313 |
</rule>
|
|
314 |
<action>putNote(sprintf("IN_%s_ID", symToken), ref.id)</action>
|
272 |
315 |
</rule>
|
273 |
316 |
|
274 |
317 |
<rule>ref == null
|
275 |
|
<action>ref = items.get(names.convert(text, names.variable))</action>
|
|
318 |
<action>ref = items.get(names.convert(text.toLowerCase(), names.variable))</action>
|
|
319 |
<action>printfln("ref = items.get(names.convert(%s, names.variable))", text.toLowerCase())</action>
|
276 |
320 |
</rule>
|
277 |
321 |
|
278 |
322 |
<rule>ref != null
|
... | ... | |
308 |
352 |
#(java.lang.Boolean) execLib("is_submenu", this))) and
|
309 |
353 |
parent.parent.type != prog.define_menu and
|
310 |
354 |
parent.parent.type != prog.define_sub_menu
|
311 |
|
<action>menu = execLib("find_sm_menu", names.convert(text, names.variable))</action>
|
|
355 |
<action>menu = execLib("find_sm_menu", names.convert(text.toLowerCase(), names.variable))</action>
|
|
356 |
<!--<action>printfln("menu = execLib('find_sm_menu', names.convert(%s, names.variable))", text.toLowerCase())</action>-->
|
312 |
357 |
<rule>menu != null
|
313 |
358 |
<action>putNote("first-menu-path", menu)</action>
|
314 |
359 |
<action>putNote("in_wid_menu", menu)</action>
|