Project

General

Profile

6709-rpt-20221205.diff

Dănuț Filimon, 12/05/2022 03:50 AM

Download (10.9 KB)

View differences:

new/rules/annotations/early_annotations.xml 2022-11-25 11:57:00 +0000
13 13
** 003 CA  20190514 Fixed resolution of DATASET and DATA-SOURCE members.
14 14
** 004 GES 20190712 Calculate dead named events.
15 15
** 005 CA  20200412 Added incremental conversion support.
16
** 006 DDF 20221125 Added nested_find.rules.
16 17
*/
17 18
 -->
18 19
 
......
208 209
   <rule-set name="annotations/duplicate_oo_names" />
209 210
   <rule-set name="annotations/dead_named_events" />
210 211
   
212
   <!-- annotate nested find in for each -->
213
   <rule-set name="annotations/nested_find" />
214
   
211 215
   <!-- persist -->
212 216
   <rule-set>
213 217
      <post-rules>
new/rules/annotations/nested_find.rules 2022-12-05 08:37:47 +0000
1
<?xml version="1.0"?>
2

  
3
<!-- 
4
/*
5
** Module   : nested_find.rules
6
** Abstract : annotation for nested find in for each
7
**
8
** Copyright (c) 2022, Golden Code Development Corporation.
9
**
10
** _#_ _I_ __Date__ __JPRM__ __________________________________Description___________________________________
11
** 001 DDF 20221123          Created initial version. Creates annotation
12
**                           for nested FIND in FOR EACH.
13
** 002 DDF 20221125          Track nested FIND that reference the same buffer.
14
** 003 DDF 20221202          Improved nested find tracking.
15
**
16
*/
17
 -->
18
 
19
<!--
20
** This program is free software: you can redistribute it and/or modify
21
** it under the terms of the GNU Affero General Public License as
22
** published by the Free Software Foundation, either version 3 of the
23
** License, or (at your option) any later version.
24
**
25
** This program is distributed in the hope that it will be useful,
26
** but WITHOUT ANY WARRANTY; without even the implied warranty of
27
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
** GNU Affero General Public License for more details.
29
**
30
** You may find a copy of the GNU Affero GPL version 3 at the following
31
** location: https://www.gnu.org/licenses/agpl-3.0.en.html
32
** 
33
** Additional terms under GNU Affero GPL version 3 section 7:
34
** 
35
**   Under Section 7 of the GNU Affero GPL version 3, the following additional
36
**   terms apply to the works covered under the License.  These additional terms
37
**   are non-permissive additional terms allowed under Section 7 of the GNU
38
**   Affero GPL version 3 and may not be removed by you.
39
** 
40
**   0. Attribution Requirement.
41
** 
42
**     You must preserve all legal notices or author attributions in the covered
43
**     work or Appropriate Legal Notices displayed by works containing the covered
44
**     work.  You may not remove from the covered work any author or developer
45
**     credit already included within the covered work.
46
** 
47
**   1. No License To Use Trademarks.
48
** 
49
**     This license does not grant any license or rights to use the trademarks
50
**     Golden Code, FWD, any Golden Code or FWD logo, or any other trademarks
51
**     of Golden Code Development Corporation. You are not authorized to use the
52
**     name Golden Code, FWD, or the names of any author or contributor, for
53
**     publicity purposes without written authorization.
54
** 
55
**   2. No Misrepresentation of Affiliation.
56
** 
57
**     You may not represent yourself as Golden Code Development Corporation or FWD.
58
** 
59
**     You may not represent yourself for publicity purposes as associated with
60
**     Golden Code Development Corporation, FWD, or any author or contributor to
61
**     the covered work, without written authorization.
62
** 
63
**   3. No Misrepresentation of Source or Origin.
64
** 
65
**     You may not represent the covered work as solely your work.  All modified
66
**     versions of the covered work must be marked in a reasonable way to make it
67
**     clear that the modified work is not originating from Golden Code Development
68
**     Corporation or FWD.  All modified versions must contain the notices of
69
**     attribution required in this license.
70
-->
71

  
72
<rule-set input="tree">
73

  
74
   <worker class="com.goldencode.p2j.uast.ProgressPatternWorker" namespace="prog" />
75
   
76
   <variable name="scopedDict"       type="com.goldencode.p2j.util.ScopedSymbolDictionary" />
77
   <variable name="tempTableAst"     type="com.goldencode.ast.Aast" />
78
   <variable name="currentFindAst"   type="com.goldencode.ast.Aast" />
79
   <variable name="inWhere"          type="java.lang.Boolean" />
80
   <variable name="schemaName"       type="java.lang.String" />
81
   <variable name="annotationValue"  type="java.lang.String" />
82
   <variable name="annotationObject" type="java.lang.Object" />
83
   
84
   <init-rules>
85
      <rule>scopedDict = create("com.goldencode.p2j.util.ScopedSymbolDictionary")</rule>
86
      <rule>inWhere = false</rule>
87
   </init-rules>
88
   
89
   <walk-rules>
90
      <!-- crete a scope using the FOR EACH ast -->
91
      <rule>type == prog.KW_FOR and
92
            this.descendant(1, prog.KW_EACH)
93
            <action>scopedDict.addScope(this)</action>
94
      </rule>
95
      
96
      <!-- add for each temp-table/buffer as symbols in the current scope -->
97
      <rule>relativePath("KW_FOR/RECORD_PHRASE")
98
         <action>tempTableAst = null</action>
99
         <rule>this.getImmediateChild(prog.TEMP_TABLE, null) != null
100
            <action>tempTableAst = this.getImmediateChild(prog.TEMP_TABLE, null)</action>
101
         </rule>
102
         <rule>this.getImmediateChild(prog.BUFFER, null) != null
103
            <action>tempTableAst = this.getImmediateChild(prog.BUFFER, null)</action>
104
         </rule>
105
         <rule>tempTableAst != null
106
            <action>annotationValue = #(java.lang.String) tempTableAst.getAnnotation("schemaname")</action>
107
            <action>annotationObject = tempTableAst.getAnnotation("schemaname")</action>
108
            <action>scopedDict.addSymbol(false, annotationValue, annotationObject)</action>
109
         </rule>
110
      </rule>
111
      
112
      <!-- save current AST of a FIND with a WHERE clause -->
113
      <rule>type == prog.KW_FIND and this.downPath("RECORD_PHRASE/KW_WHERE") and scopedDict.size() > 0
114
         <action>currentFindAst = this</action>
115
      </rule>
116
      
117
      <!-- toggle flag when the finding the AST of the WHERE clause -->
118
      <rule>type == prog.KW_WHERE and currentFindAst != null and scopedDict.size() > 0
119
         <action>inWhere = true</action>
120
      </rule>
121
      
122
      <!-- if schemaname annotation is present, search it among the symbols
123
           from all the scopes and annotate the find AST saved
124
           previously -->
125
      <rule>inWhere and scopedDict.size() > 0 and this.isAnnotation("schemaname")
126
         <action>schemaName = #(java.lang.String) this.getAnnotation("schemaname")</action>
127
         <rule>schemaName.contains(".")
128
            <!-- get the buffer name if the schemaname specifies a field -->
129
            <action>schemaName = splitToList(schemaName, "\.").get(0)</action>
130
         </rule>
131
         <rule>scopedDict.lookupSymbol(schemaName) != null
132
            <action>putReferenceNote(currentFindAst.getId(), "nested_find", true)</action>
133
         </rule>
134
      </rule>
135
   </walk-rules>
136
   
137
   <ascent-rules>
138
      <!-- pop the scope when exiting the FOR EACH statement -->
139
      <rule>type == prog.BLOCK and
140
            this.prevSibling != null and
141
            this.prevSibling.type == prog.KW_FOR and
142
            this.prevSibling.descendant(1, prog.KW_EACH)
143
         <action>scopedDict.deleteScope()</action>
144
      </rule>
145
      
146
      <!-- toggle flag when exiting the FIND statement -->
147
      <rule>inWhere and type == prog.KW_FIND
148
         <action>inWhere = false</action>
149
      </rule>
150
   </ascent-rules>
151
   
152
</rule-set>
new/rules/include/report.rules 2022-11-25 12:04:02 +0000
58 58
**         20190710          Added helper to describe an enum reference. 
59 59
** 027 CA  20200428          Describe legacy DEFINE ENUM type.
60 60
** 028 GES 20210702          Fixed broken code in describing lvalues.
61
** 029 DDF 20221125          Added helper functions for checking nested_find annotation and
62
**                           classifying types of nested finds.
61 63
*/
62 64
 -->
63 65
 
......
3296 3298
         </rule>
3297 3299
      </function>
3298 3300
      
3301
      <!-- check if annotation "nested_find" is present -->
3302
      <function name="nested_find">
3303
         <parameter name="target"       type="com.goldencode.ast.Aast" />
3304
         <return    name="isNestedFind" type="java.lang.Boolean" />
3305
         
3306
         <rule>isNestedFind = false</rule>
3307
         <rule>target.isAnnotation("nested_find")
3308
            <action>isNestedFind = true</action>
3309
         </rule>
3310
      </function>
3311
      
3312
      <!-- classify type of nested find -->
3313
      <function name="type_nested_find_classify">
3314
         <parameter name="target"   type="com.goldencode.ast.Aast" />
3315
         <return    name="findType" type="java.lang.String" />
3316
         
3317
         <rule>target.downPath("RECORD_PHRASE/KW_WHERE")
3318
            <action>findType = "WHERE"</action>
3319
         </rule>
3320

  
3321
         <rule>target.getImmediateChild(prog.KW_FIRST, null) != null
3322
            <action>findType = "FIRST"</action>
3323
         </rule>
3324
         
3325
         <rule>target.getImmediateChild(prog.KW_LAST, null) != null
3326
            <action>findType = "LAST"</action>
3327
         </rule>
3328
         
3329
         <rule>target.getImmediateChild(prog.KW_NEXT, null) != null
3330
            <action>findType = "NEXT"</action>
3331
         </rule>
3332
         
3333
         <rule>target.getImmediateChild(prog.KW_PREV, null) != null
3334
            <action>findType = "PREV"</action>
3335
         </rule>
3336
         
3337
         <rule>target.getImmediateChild(prog.KW_CURRENT, null) != null
3338
            <action>findType = "CURRENT"</action>
3339
         </rule>
3340
      </function>
3299 3341
  </func-library>
3300 3342
</rule-set>
new/rules/reports/profile.rpt 2022-11-25 11:55:05 +0000
70 70
**         20190715          Added file variants of the .NET reports.
71 71
**     CA  20191023          Added builtin OO method report; improved builtin OO class reports.
72 72
** 036 CA  20200428          Include the enums in duplicate OO names report.
73
** 037 DDF 20221125          Added nested find report.
73 74
*/
74 75
 -->
75 76
 
......
2415 2416
      dumpType="parser"
2416 2417
      title="Nested CAN-FIND"
2417 2418
      tags="Database"/>
2419
   <report
2420
      condition="evalLib(&quot;nested_find&quot;, this)"
2421
      dumpType="parser"
2422
      multiplexExpr="execLib(&quot;type_nested_find_classify&quot;, this)"
2423
      title="FOR EACH Nested FIND"
2424
      tags="Database"/>
2418 2425
   <report 
2419 2426
      condition="upPath(&quot;KW_FIND/RECORD_PHRASE&quot;) and evalLib(&quot;literals&quot;, type)"
2420 2427
      dumpType="parser"