@cparra/apex-reflection 0.1.0-alpha.0 → 0.1.1-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/__tests__/end-to-end.test.ts +256 -0
  2. package/coverage/clover.xml +12857 -0
  3. package/coverage/coverage-final.json +3 -0
  4. package/coverage/lcov-report/base.css +224 -0
  5. package/coverage/lcov-report/block-navigation.js +79 -0
  6. package/coverage/lcov-report/favicon.png +0 -0
  7. package/coverage/lcov-report/index.html +126 -0
  8. package/coverage/lcov-report/index.js.html +104 -0
  9. package/coverage/lcov-report/out.js.html +41126 -0
  10. package/coverage/lcov-report/prettify.css +1 -0
  11. package/coverage/lcov-report/prettify.js +2 -0
  12. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  13. package/coverage/lcov-report/sorter.js +170 -0
  14. package/coverage/lcov.info +24801 -0
  15. package/index.d.ts +118 -0
  16. package/index.js +8 -0
  17. package/index.ts +141 -0
  18. package/jest.config.js +11 -0
  19. package/out.js +13708 -0
  20. package/package.json +22 -17
  21. package/tsconfig.json +5 -3
  22. package/.idea/apexdocs-dart.iml +0 -18
  23. package/.idea/jsLibraryMappings.xml +0 -6
  24. package/.idea/libraries/Dart_Packages.xml +0 -556
  25. package/.idea/libraries/Dart_SDK.xml +0 -28
  26. package/.idea/misc.xml +0 -6
  27. package/.idea/modules.xml +0 -8
  28. package/.idea/runConfigurations/_template__of_Dart_Test.xml +0 -6
  29. package/.idea/vcs.xml +0 -6
  30. package/CHANGELOG.md +0 -3
  31. package/README.md +0 -26
  32. package/TODO.md +0 -5
  33. package/analysis_options.yaml +0 -30
  34. package/antlr4-4.9.2/CHANGELOG.md +0 -4
  35. package/antlr4-4.9.2/LICENSE +0 -52
  36. package/antlr4-4.9.2/README.md +0 -11
  37. package/antlr4-4.9.2/analysis_options.yaml +0 -1
  38. package/antlr4-4.9.2/lib/antlr4.dart +0 -21
  39. package/antlr4-4.9.2/lib/src/atn/atn.dart +0 -18
  40. package/antlr4-4.9.2/lib/src/atn/src/atn.dart +0 -170
  41. package/antlr4-4.9.2/lib/src/atn/src/atn_config.dart +0 -242
  42. package/antlr4-4.9.2/lib/src/atn/src/atn_config_set.dart +0 -283
  43. package/antlr4-4.9.2/lib/src/atn/src/atn_deserializer.dart +0 -809
  44. package/antlr4-4.9.2/lib/src/atn/src/atn_simulator.dart +0 -95
  45. package/antlr4-4.9.2/lib/src/atn/src/atn_state.dart +0 -296
  46. package/antlr4-4.9.2/lib/src/atn/src/atn_type.dart +0 -14
  47. package/antlr4-4.9.2/lib/src/atn/src/info.dart +0 -553
  48. package/antlr4-4.9.2/lib/src/atn/src/lexer_action.dart +0 -601
  49. package/antlr4-4.9.2/lib/src/atn/src/lexer_action_executor.dart +0 -167
  50. package/antlr4-4.9.2/lib/src/atn/src/lexer_atn_simulator.dart +0 -731
  51. package/antlr4-4.9.2/lib/src/atn/src/parser_atn_simulator.dart +0 -2630
  52. package/antlr4-4.9.2/lib/src/atn/src/profiling_atn_simulator.dart +0 -229
  53. package/antlr4-4.9.2/lib/src/atn/src/semantic_context.dart +0 -404
  54. package/antlr4-4.9.2/lib/src/atn/src/transition.dart +0 -305
  55. package/antlr4-4.9.2/lib/src/dfa/dfa.dart +0 -8
  56. package/antlr4-4.9.2/lib/src/dfa/src/dfa.dart +0 -138
  57. package/antlr4-4.9.2/lib/src/dfa/src/dfa_serializer.dart +0 -76
  58. package/antlr4-4.9.2/lib/src/dfa/src/dfa_state.dart +0 -151
  59. package/antlr4-4.9.2/lib/src/error/error.dart +0 -10
  60. package/antlr4-4.9.2/lib/src/error/src/diagnostic_error_listener.dart +0 -116
  61. package/antlr4-4.9.2/lib/src/error/src/error_listener.dart +0 -241
  62. package/antlr4-4.9.2/lib/src/error/src/error_strategy.dart +0 -902
  63. package/antlr4-4.9.2/lib/src/error/src/errors.dart +0 -204
  64. package/antlr4-4.9.2/lib/src/input_stream.dart +0 -335
  65. package/antlr4-4.9.2/lib/src/interval_set.dart +0 -735
  66. package/antlr4-4.9.2/lib/src/lexer.dart +0 -343
  67. package/antlr4-4.9.2/lib/src/ll1_analyzer.dart +0 -204
  68. package/antlr4-4.9.2/lib/src/misc/multi_map.dart +0 -32
  69. package/antlr4-4.9.2/lib/src/misc/pair.dart +0 -34
  70. package/antlr4-4.9.2/lib/src/parser.dart +0 -777
  71. package/antlr4-4.9.2/lib/src/parser_interpreter.dart +0 -393
  72. package/antlr4-4.9.2/lib/src/parser_rule_context.dart +0 -275
  73. package/antlr4-4.9.2/lib/src/prediction_context.dart +0 -877
  74. package/antlr4-4.9.2/lib/src/recognizer.dart +0 -182
  75. package/antlr4-4.9.2/lib/src/rule_context.dart +0 -192
  76. package/antlr4-4.9.2/lib/src/runtime_meta_data.dart +0 -188
  77. package/antlr4-4.9.2/lib/src/token.dart +0 -431
  78. package/antlr4-4.9.2/lib/src/token_factory.dart +0 -88
  79. package/antlr4-4.9.2/lib/src/token_source.dart +0 -241
  80. package/antlr4-4.9.2/lib/src/token_stream.dart +0 -627
  81. package/antlr4-4.9.2/lib/src/tree/src/pattern/chunk.dart +0 -90
  82. package/antlr4-4.9.2/lib/src/tree/src/pattern/parse_tree_match.dart +0 -635
  83. package/antlr4-4.9.2/lib/src/tree/src/tree.dart +0 -370
  84. package/antlr4-4.9.2/lib/src/tree/src/trees.dart +0 -226
  85. package/antlr4-4.9.2/lib/src/tree/tree.dart +0 -10
  86. package/antlr4-4.9.2/lib/src/util/bit_set.dart +0 -308
  87. package/antlr4-4.9.2/lib/src/util/murmur_hash.dart +0 -77
  88. package/antlr4-4.9.2/lib/src/util/utils.dart +0 -31
  89. package/antlr4-4.9.2/lib/src/vocabulary.dart +0 -254
  90. package/antlr4-4.9.2/pubspec.yaml +0 -13
  91. package/example/node_example/index.js +0 -8
  92. package/example/node_example/package.json +0 -12
  93. package/example/node_example_ts/package-lock.json +0 -70
  94. package/example/node_example_ts/package.json +0 -19
  95. package/example/node_example_ts/src/index.js +0 -5
  96. package/example/node_example_ts/src/index.ts +0 -9
  97. package/example/node_example_ts/tsconfig.json +0 -79
  98. package/js/dart2jsout.js +0 -25898
  99. package/js/dart2jsout.js.map +0 -16
  100. package/js/index.d.ts +0 -1
  101. package/js/index.js +0 -4
  102. package/js/out.js +0 -26023
  103. package/js/out.js.map +0 -16
  104. package/js/package-lock.json +0 -57
  105. package/js/preamble.js +0 -125
  106. package/lib/apexdocs_dart.dart +0 -28
  107. package/lib/src/antlr/grammars/Apexdoc/ApexdocLexer.g4 +0 -120
  108. package/lib/src/antlr/grammars/Apexdoc/ApexdocParser.g4 +0 -158
  109. package/lib/src/antlr/grammars/Apexdoc/gen/ApexdocLexer.interp +0 -95
  110. package/lib/src/antlr/grammars/Apexdoc/gen/ApexdocLexer.java +0 -238
  111. package/lib/src/antlr/grammars/Apexdoc/gen/ApexdocLexer.tokens +0 -23
  112. package/lib/src/antlr/grammars/apex/ApexLexer.g4 +0 -255
  113. package/lib/src/antlr/grammars/apex/ApexParser.g4 +0 -567
  114. package/lib/src/antlr/grammars/apex/examples/ApexClass.cls +0 -6
  115. package/lib/src/antlr/lib/apex/ApexLexer.dart +0 -1223
  116. package/lib/src/antlr/lib/apex/ApexLexer.interp +0 -393
  117. package/lib/src/antlr/lib/apex/ApexLexer.tokens +0 -212
  118. package/lib/src/antlr/lib/apex/ApexParser.dart +0 -9349
  119. package/lib/src/antlr/lib/apex/ApexParser.interp +0 -326
  120. package/lib/src/antlr/lib/apex/ApexParser.tokens +0 -212
  121. package/lib/src/antlr/lib/apex/ApexParserBaseListener.dart +0 -1036
  122. package/lib/src/antlr/lib/apex/ApexParserListener.dart +0 -975
  123. package/lib/src/antlr/lib/apexdoc/ApexdocLexer.dart +0 -373
  124. package/lib/src/antlr/lib/apexdoc/ApexdocLexer.interp +0 -95
  125. package/lib/src/antlr/lib/apexdoc/ApexdocLexer.tokens +0 -23
  126. package/lib/src/antlr/lib/apexdoc/ApexdocParser.dart +0 -2471
  127. package/lib/src/antlr/lib/apexdoc/ApexdocParser.interp +0 -69
  128. package/lib/src/antlr/lib/apexdoc/ApexdocParser.tokens +0 -23
  129. package/lib/src/antlr/lib/apexdoc/ApexdocParserBaseListener.dart +0 -252
  130. package/lib/src/antlr/lib/apexdoc/ApexdocParserListener.dart +0 -215
  131. package/lib/src/builders/builders.dart +0 -32
  132. package/lib/src/model/apex_file_manifest.dart +0 -37
  133. package/lib/src/model/apex_file_manifest.g.dart +0 -18
  134. package/lib/src/model/declaration.dart +0 -50
  135. package/lib/src/model/doc_comment.dart +0 -117
  136. package/lib/src/model/doc_comment.g.dart +0 -118
  137. package/lib/src/model/members.dart +0 -143
  138. package/lib/src/model/members.g.dart +0 -105
  139. package/lib/src/model/types.dart +0 -159
  140. package/lib/src/model/types.g.dart +0 -111
  141. package/lib/src/service/apex_listener.dart +0 -226
  142. package/lib/src/service/apexdoc_listener.dart +0 -82
  143. package/lib/src/service/parsers.dart +0 -33
  144. package/lib/src/service/utils/parsing/access_modifiers_parser.dart +0 -33
  145. package/lib/src/service/utils/parsing/parameters_parser.dart +0 -18
  146. package/lib/src/service/utils/parsing/parsing_utils.dart +0 -2
  147. package/lib/src/service/walker.dart +0 -82
  148. package/pubspec.yaml +0 -19
  149. package/test/apex_file_manifest_test.dart +0 -16
  150. package/test/apex_listener_test.dart +0 -703
  151. package/test/apexdoc_parser_test.dart +0 -179
  152. package/test/doc_comment_test.dart +0 -89
  153. package/test/members_serialization_test.dart +0 -158
  154. package/test/members_test.dart +0 -178
  155. package/test/types_serialization_test.dart +0 -191
  156. package/test/types_test.dart +0 -311
  157. package/test/walker_test.dart +0 -58
  158. package/tool/grind.dart +0 -20
@@ -0,0 +1,256 @@
1
+ import {ClassMirror, InterfaceMirror, reflect} from '../index';
2
+
3
+ describe('Enum Reflection', () => {
4
+ test('Simple, single line declaration', () => {
5
+ const enumBody = 'enum MyEnumName {}';
6
+ const result = reflect(enumBody).typeMirror;
7
+ expect(result.type_name).toBe('enum');
8
+ expect(result.name).toBe('MyEnumName');
9
+ });
10
+
11
+ test('Multi-line declaration with values', () => {
12
+ const enumBody = `
13
+ enum MyEnumName {
14
+ VALUE_1,
15
+ VALUE2
16
+ }
17
+ `;
18
+ const result = reflect(enumBody).typeMirror;
19
+ expect(result.type_name).toBe('enum');
20
+ expect(result.name).toBe('MyEnumName');
21
+ });
22
+
23
+ test('With doc comments', () => {
24
+ const enumBody = `
25
+ /**
26
+ * My enum description
27
+ */
28
+ enum MyEnumName {
29
+ VALUE_1,
30
+ VALUE2
31
+ }
32
+ `;
33
+ const result = reflect(enumBody).typeMirror;
34
+ expect(result.docComment.description).toBe('My enum description');
35
+ });
36
+ });
37
+
38
+ describe('Interface Reflection', () => {
39
+ test('Single line interface definition', () => {
40
+ const interfaceBody = 'interface MyInterface{}';
41
+ const result = reflect(interfaceBody).typeMirror;
42
+ expect(result.type_name).toBe('interface');
43
+ expect(result.name).toBe('MyInterface');
44
+ });
45
+
46
+ test('When no access modifier is defined it is private', () => {
47
+ const interfaceBody = 'interface MyInterface{}';
48
+ const result = reflect(interfaceBody).typeMirror;
49
+ expect(result.access_modifier).toBe('private');
50
+ });
51
+
52
+ test('Can have access modifier', () => {
53
+ const interfaceBody = 'public interface MyInterface{}';
54
+ const result = reflect(interfaceBody).typeMirror;
55
+ expect(result.access_modifier).toBe('public');
56
+ });
57
+
58
+ test('Can have a sharing modifier', () => {
59
+ const interfaceBody = 'public with sharing interface MyInterface{}';
60
+ const result = reflect(interfaceBody) as InterfaceMirror;
61
+ expect(result.sharingModifier).toBe('withSharing');
62
+ });
63
+
64
+ test('Can have methods', () => {
65
+ const interfaceBody = `
66
+ public with sharing interface MyInterface{
67
+ void method1();
68
+ }
69
+ `;
70
+ const result = reflect(interfaceBody) as InterfaceMirror;
71
+ expect(result.methods.length).toBe(1);
72
+ expect(result.methods[0].name).toBe('method1');
73
+ });
74
+
75
+ test('Can have extend other interfaces', () => {
76
+ const interfaceBody = `
77
+ public with sharing interface MyInterface extends Interface2 {
78
+ void method1();
79
+ }
80
+ `;
81
+ const result = reflect(interfaceBody) as InterfaceMirror;
82
+ expect(result.extended_interfaces.length).toBe(1);
83
+ expect(result.extended_interfaces[0]).toBe('Interface2');
84
+ });
85
+
86
+ test('Can have annotations', () => {
87
+ const interfaceBody = `
88
+ @NamespaceAccessible
89
+ public with sharing interface MyInterface{
90
+ void method1();
91
+ }
92
+ `;
93
+ const result = reflect(interfaceBody) as InterfaceMirror;
94
+ expect(result.annotations.length).toBe(1);
95
+ expect(result.annotations[0].name).toBe('namespaceaccessible');
96
+ });
97
+ });
98
+
99
+ describe('Class reflection', () => {
100
+ test('Single line class definition', () => {
101
+ const classBody = 'class MyClass{}';
102
+ const result = reflect(classBody).typeMirror;
103
+ expect(result.type_name).toBe('class');
104
+ expect(result.name).toBe('MyClass');
105
+ });
106
+
107
+ test('When no access modifier is defined it is private', () => {
108
+ const classBody = 'class MyClass{}';
109
+ const result = reflect(classBody).typeMirror;
110
+ expect(result.access_modifier).toBe('private');
111
+ });
112
+
113
+ test('Can have access modifier', () => {
114
+ const interfaceBody = 'public class MyClass{}';
115
+ const result = reflect(interfaceBody).typeMirror;
116
+ expect(result.access_modifier).toBe('public');
117
+ });
118
+
119
+ test('Can have a sharing modifier', () => {
120
+ const classBody = 'public with sharing class MyClass{}';
121
+ const result = reflect(classBody) as ClassMirror;
122
+ expect(result.sharingModifier).toBe('withSharing');
123
+ });
124
+
125
+ test('Can have a class modifier', () => {
126
+ const classBody = 'public with sharing abstract class MyClass{}';
127
+ const result = reflect(classBody) as ClassMirror;
128
+ expect(result.classModifier).toBe('abstract');
129
+ });
130
+
131
+ test('Can extend a class', () => {
132
+ const classBody = 'public with sharing class MyClass extends Class2 {}';
133
+ const result = reflect(classBody) as ClassMirror;
134
+ expect(result.extended_class).toBe('Class2');
135
+ });
136
+
137
+ test('Can implement interfaces', () => {
138
+ const classBody = 'public with sharing class MyClass implements Interface1, Interface2 {}';
139
+ const result = reflect(classBody) as ClassMirror;
140
+ expect(result.implemented_interfaces.length).toBe(2);
141
+ expect(result.implemented_interfaces[0]).toBe('Interface1');
142
+ expect(result.implemented_interfaces[1]).toBe('Interface2');
143
+ });
144
+
145
+ test('Can have properties', () => {
146
+ const classBody = `
147
+ public with sharing class MyClass {
148
+ public String Prop1 { get; set; }
149
+ public Integer Prop2 { get; set; }
150
+ }
151
+ `;
152
+ const result = reflect(classBody) as ClassMirror;
153
+ expect(result.properties.length).toBe(2);
154
+ expect(result.properties[0].type).toBe('String');
155
+ expect(result.properties[0].name).toBe('Prop1');
156
+ expect(result.properties[1].type).toBe('Integer');
157
+ expect(result.properties[1].name).toBe('Prop2');
158
+ });
159
+
160
+ test('Can have fields', () => {
161
+ const classBody = `
162
+ public with sharing class MyClass {
163
+ private String var1, var2;
164
+ }
165
+ `;
166
+ const result = reflect(classBody) as ClassMirror;
167
+ expect(result.fields.length).toBe(2);
168
+ expect(result.fields[0].type).toBe('String');
169
+ expect(result.fields[1].type).toBe('String');
170
+ expect(result.fields[0].name).toBe('var1');
171
+ expect(result.fields[1].name).toBe('var2');
172
+ });
173
+
174
+ test('Can have constructors', () => {
175
+ const classBody = `
176
+ public with sharing class MyClass {
177
+ public MyClass() {}
178
+ public MyClass(String var1) {}
179
+ }
180
+ `;
181
+ const result = reflect(classBody) as ClassMirror;
182
+ expect(result.constructors.length).toBe(2);
183
+ expect(result.constructors[0].parameters.length).toBe(0);
184
+ expect(result.constructors[0].access_modifier).toBe('public');
185
+ expect(result.constructors[1].parameters.length).toBe(1);
186
+ expect(result.constructors[1].parameters[0].name).toBe('var1');
187
+ expect(result.constructors[1].parameters[0].type).toBe('String');
188
+ expect(result.constructors[1].access_modifier).toBe('public');
189
+ });
190
+
191
+ test('Can have methods', () => {
192
+ const classBody = `
193
+ public with sharing class MyClass {
194
+ public static String method1() {
195
+ return '';
196
+ }
197
+
198
+ private void method2(){}
199
+ }
200
+ `;
201
+ const result = reflect(classBody) as ClassMirror;
202
+ expect(result.methods.length).toBe(2);
203
+ expect(result.methods[0].memberModifiers.length).toBe(1);
204
+ expect(result.methods[0].memberModifiers[0]).toBe('static');
205
+ expect(result.methods[0].access_modifier).toBe('public');
206
+ expect(result.methods[0].type).toBe('String');
207
+ expect(result.methods[0].name).toBe('method1');
208
+
209
+ expect(result.methods[1].memberModifiers.length).toBe(0);
210
+ expect(result.methods[1].access_modifier).toBe('private');
211
+ expect(result.methods[1].type).toBe('void');
212
+ expect(result.methods[1].name).toBe('method2');
213
+ });
214
+
215
+ test('Can have inner enums', () => {
216
+ const classBody = `
217
+ public with sharing class MyClass {
218
+ public enum MyEnum {}
219
+ }
220
+ `;
221
+ const result = reflect(classBody) as ClassMirror;
222
+ expect(result.enums.length).toBe(1);
223
+ expect(result.enums[0].access_modifier).toBe('public');
224
+ expect(result.enums[0].name).toBe('MyEnum');
225
+ });
226
+
227
+ test('Can have inner interfaces', () => {
228
+ const classBody = `
229
+ public with sharing class MyClass {
230
+ public interface MyInterface {
231
+ void method1();
232
+ void method2();
233
+ }
234
+ }
235
+ `;
236
+ const result = reflect(classBody) as ClassMirror;
237
+ expect(result.interfaces.length).toBe(1);
238
+ expect(result.interfaces[0].name).toBe('MyInterface');
239
+ expect(result.interfaces[0].methods.length).toBe(2);
240
+ });
241
+
242
+ test('Can have inner classes', () => {
243
+ const classBody = `
244
+ public with sharing class MyClass {
245
+ public class MyClass {
246
+ public void method1();
247
+ public void method2();
248
+ }
249
+ }
250
+ `;
251
+ const result = reflect(classBody) as ClassMirror;
252
+ expect(result.classes.length).toBe(1);
253
+ expect(result.classes[0].name).toBe('MyClass');
254
+ expect(result.classes[0].methods.length).toBe(2);
255
+ });
256
+ });