@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
@@ -1,179 +0,0 @@
1
- // Disabling null safety since this test relies on the antrl4 package
2
- // @dart=2.10
3
-
4
- import 'package:apexdocs_dart/src/service/parsers.dart';
5
- import 'package:test/test.dart';
6
-
7
- main() {
8
- test('Can parse a single line simple doc comment', () {
9
- final docBody = '/** This is a description */';
10
- final docComment = ApexdocParser.parseFromBody(docBody);
11
- expect(docComment.description, 'This is a description');
12
- });
13
-
14
- test('Can parse a multi line simple doc comment', () {
15
- final docBody = '''
16
- /**
17
- * This is a description
18
- */
19
- ''';
20
- final docComment = ApexdocParser.parseFromBody(docBody);
21
- expect(docComment.description, 'This is a description');
22
- });
23
-
24
- test('Can parse a multi line simple doc comment with multiple blank lines',
25
- () {
26
- final docBody = '''
27
- /**
28
- *
29
- * This is a description
30
- *
31
- */
32
- ''';
33
- final docComment = ApexdocParser.parseFromBody(docBody);
34
- expect(docComment.description, 'This is a description');
35
- });
36
-
37
- test('Can parse description of multiple lines.', () {
38
- final docBody = '''
39
- /**
40
- * This is a description.
41
- * The description continues here.
42
- */
43
- ''';
44
- final docComment = ApexdocParser.parseFromBody(docBody);
45
- expect(docComment.description,
46
- 'This is a description. The description continues here.');
47
- });
48
-
49
- test('Can parse tagged description', () {
50
- final docBody = '''
51
- /**
52
- * @description This is a description
53
- */
54
- ''';
55
- final docComment = ApexdocParser.parseFromBody(docBody);
56
- expect(docComment.description, 'This is a description');
57
- });
58
-
59
- test('Can parse tagged description with multiple lines', () {
60
- final docBody = '''
61
- /**
62
- * @description This is a description.
63
- * The description continues here
64
- */
65
- ''';
66
- final docComment = ApexdocParser.parseFromBody(docBody);
67
- expect(docComment.descriptionLines.length, equals(2));
68
- expect(docComment.description,
69
- equals('This is a description. The description continues here'));
70
- });
71
-
72
- test('Can parse a tag', () {
73
- final docBody = '''
74
- /**
75
- * @description This is a description.
76
- * @param param1 description
77
- */
78
- ''';
79
- final docComment = ApexdocParser.parseFromBody(docBody);
80
- expect(docComment.paramAnnotations.length, equals(1));
81
- expect(docComment.paramAnnotations.first.paramName, equals('param1'));
82
- expect(docComment.paramAnnotations.first.body, equals('description'));
83
- });
84
-
85
- test('Can parse multiple of the same tag', () {
86
- final docBody = '''
87
- /**
88
- * @description This is a description.
89
- * @param param1 description1
90
- * @param param2 description2
91
- */
92
- ''';
93
- final docComment = ApexdocParser.parseFromBody(docBody);
94
- expect(docComment.paramAnnotations.length, equals(2));
95
- expect(docComment.paramAnnotations.first.paramName, equals('param1'));
96
- expect(docComment.paramAnnotations.first.body, equals('description1'));
97
- expect(docComment.paramAnnotations[1].paramName, equals('param2'));
98
- expect(docComment.paramAnnotations[1].body, equals('description2'));
99
- });
100
-
101
- test('Can parse a param with a multi line body', () {
102
- final docBody = '''
103
- /**
104
- * @description This is a description.
105
- * @param param1 description1
106
- * The description continues here.
107
- */
108
- ''';
109
- final docComment = ApexdocParser.parseFromBody(docBody);
110
- expect(docComment.paramAnnotations.length, equals(1));
111
- expect(docComment.paramAnnotations.first.paramName, equals('param1'));
112
- expect(docComment.paramAnnotations.first.body,
113
- equals('description1 The description continues here.'));
114
- });
115
-
116
- test('Can parse a return tag', () {
117
- final docBody = '''
118
- /**
119
- * @description This is a description.
120
- * @param param1 description1
121
- * @return Returns something
122
- */
123
- ''';
124
- final docComment = ApexdocParser.parseFromBody(docBody);
125
- expect(docComment.returnAnnotation, isNotNull);
126
- expect(docComment.returnAnnotation.body, equals('Returns something'));
127
- });
128
-
129
- test('Can parse a throws tag', () {
130
- final docBody = '''
131
- /**
132
- * @description This is a description.
133
- * @param param1 description1
134
- * @return Returns something
135
- * @throws ExceptionName1 description1
136
- * @throws ExceptionName2 description2
137
- */
138
- ''';
139
- final docComment = ApexdocParser.parseFromBody(docBody);
140
- expect(docComment.throwsAnnotations.length, equals(2));
141
- expect(docComment.throwsAnnotations.first.exceptionName,
142
- equals('ExceptionName1'));
143
- expect(docComment.throwsAnnotations.first.body, equals('description1'));
144
- expect(docComment.throwsAnnotations[1].exceptionName,
145
- equals('ExceptionName2'));
146
- expect(docComment.throwsAnnotations[1].body, equals('description2'));
147
- });
148
-
149
- test('Can parse an example tag', () {
150
- final docBody = '''
151
- /**
152
- * @description This is a description.
153
- * @param param1 description1
154
- * @return Returns something
155
- * @throws ExceptionName1 description1
156
- * @throws ExceptionName2 description2
157
- * @example
158
- * String testString = 'MyString';
159
- */
160
- ''';
161
- final docComment = ApexdocParser.parseFromBody(docBody);
162
- expect(docComment.exampleAnnotation, isNotNull);
163
- expect(docComment.exampleAnnotation.bodyLines.length, equals(1));
164
- expect(docComment.exampleAnnotation.body,
165
- equals("String testString = 'MyString';"));
166
- });
167
-
168
- test('Can parse custom tags', () {
169
- final docBody = '''
170
- /**
171
- * @author Some Author
172
- */
173
- ''';
174
- final docComment = ApexdocParser.parseFromBody(docBody);
175
- expect(docComment.annotationsByName('author').length, equals(1));
176
- expect(docComment.annotationsByName('author').first.body,
177
- equals('Some Author'));
178
- });
179
- }
@@ -1,89 +0,0 @@
1
- import 'package:apexdocs_dart/src/model/doc_comment.dart';
2
- import 'package:test/test.dart';
3
-
4
- main() {
5
- group('Doc Comment', () {
6
- test('Has a description', () {
7
- final comment = DocComment('Any Description');
8
- expect(comment.description, equals('Any Description'));
9
- });
10
-
11
- test(
12
- 'Supports the description being a tag when there is no default description',
13
- () {
14
- final comment = DocComment('');
15
- comment.annotations.add(DocCommentAnnotation('description', 'some body'));
16
- expect(comment.description, equals('some body'));
17
- });
18
-
19
- test('Can have param annotations', () {
20
- final comment = DocComment('Any Description');
21
- comment.paramAnnotations
22
- .add(ParamDocCommentAnnotation('param1', 'Some description'));
23
- expect(comment.paramAnnotations.length, equals(1));
24
- expect(comment.paramAnnotations.first.paramName, equals('param1'));
25
- });
26
-
27
- test('Can have a return annotation', () {
28
- final comment = DocComment('Any Description');
29
- comment.returnAnnotation = ReturnDocCommentAnnotation('description');
30
- expect(comment.returnAnnotation, isNotNull);
31
- });
32
-
33
- test('Can have annotations', () {
34
- final comment = DocComment('Any Description');
35
- comment.annotations.add(DocCommentAnnotation('see', 'body'));
36
- expect(comment.annotations.length, equals(1));
37
- expect(comment.annotations.first.name, equals('see'));
38
- });
39
- });
40
-
41
- group('Doc Comment Annotation', () {
42
- test('Has a name', () {
43
- final annotation = DocCommentAnnotation('description', 'body');
44
- expect(annotation.name, equals('description'));
45
- });
46
-
47
- test('Can have a body', () {
48
- final annotation = DocCommentAnnotation('description', ['body']);
49
- expect(annotation.body, equals('body'));
50
- });
51
- });
52
-
53
- group('Param annotations', () {
54
- test('Has an annotation name of param, the parameter name, and a body', () {
55
- final paramAnnotation =
56
- ParamDocCommentAnnotation('param1', 'Some description');
57
- expect(paramAnnotation.name, equals('param'));
58
- expect(paramAnnotation.paramName, equals('param1'));
59
- expect(paramAnnotation.body, equals('Some description'));
60
- });
61
- });
62
-
63
- group('Return annotations', () {
64
- test('Has a body', () {
65
- final returnAnnotation = ReturnDocCommentAnnotation('Some description');
66
- expect(returnAnnotation.name, equals('return'));
67
- expect(returnAnnotation.body, equals('Some description'));
68
- });
69
- });
70
-
71
- group('Throws annotations', () {
72
- test('Has an annotation name of throws, the exception name, and a body',
73
- () {
74
- final throwsAnnotation =
75
- ThrowsDocCommentAnnotation('ExceptionName', 'Some description');
76
- expect(throwsAnnotation.name, equals('throws'));
77
- expect(throwsAnnotation.exceptionName, equals('ExceptionName'));
78
- expect(throwsAnnotation.body, equals('Some description'));
79
- });
80
- });
81
-
82
- group('Example annotations', () {
83
- test('Has a body', () {
84
- final exampleAnnotation = ExampleDocCommentAnnotation('Some description');
85
- expect(exampleAnnotation.name, equals('example'));
86
- expect(exampleAnnotation.body, equals('Some description'));
87
- });
88
- });
89
- }
@@ -1,158 +0,0 @@
1
- import 'dart:convert';
2
-
3
- import 'package:test/test.dart';
4
- import 'package:apexdocs_dart/src/model/members.dart';
5
-
6
- void main() {
7
- group('Property serialization', () {
8
- test('Properties can be serialized', () {
9
- final property = Property(
10
- name: 'PropName',
11
- type: 'String',
12
- accessModifiers: ['namespaceaccessible', 'public']);
13
-
14
- String encodedProperty = jsonEncode(property);
15
- expect(encodedProperty, isNotNull);
16
- final decodedProperty = Property.fromJson(jsonDecode(encodedProperty));
17
- expect(property.name, equals(decodedProperty.name));
18
- });
19
-
20
- test('Properties can be deserialized', () {
21
- final propertyAsJson = '''
22
- {
23
- "name": "PropName",
24
- "type": "String",
25
- "access_modifiers": ["namespaceaccessible", "public"]
26
- }
27
- ''';
28
-
29
- final property = Property.fromJson(jsonDecode(propertyAsJson));
30
- expect(property.name, equals('PropName'));
31
- expect(property.type, equals('String'));
32
- expect(
33
- property.accessModifiers, equals(['namespaceaccessible', 'public']));
34
- });
35
- });
36
-
37
- group('Field serialization', () {
38
- test('Fields can be serialized', () {
39
- var field = Field(
40
- name: 'FieldNAme',
41
- type: 'String',
42
- accessModifiers: ['namespaceaccessible', 'public']);
43
-
44
- String encodedField = jsonEncode(field);
45
- expect(encodedField, isNotNull);
46
- final decodedField = Field.fromJson(jsonDecode(encodedField));
47
- expect(field.name, equals(decodedField.name));
48
- });
49
-
50
- test('Fields can be deserialized', () {
51
- final fieldAsJson = '''
52
- {
53
- "name": "FieldName",
54
- "type": "String",
55
- "access_modifiers": ["namespaceaccessible", "public"]
56
- }
57
- ''';
58
-
59
- final field = Field.fromJson(jsonDecode(fieldAsJson));
60
- expect(field.name, equals('FieldName'));
61
- expect(field.type, equals('String'));
62
- expect(field.accessModifiers, equals(['namespaceaccessible', 'public']));
63
- });
64
- });
65
-
66
- group('Method serialization', () {
67
- test('Methods can be serialized', () {
68
- var method = Method(
69
- name: 'MethodName',
70
- type: 'String',
71
- accessModifiers: ['namespaceaccessible', 'public']);
72
- method.addParameter(Parameter(name: 'Param1', type: 'String'));
73
-
74
- String encodedMethod = jsonEncode(method);
75
- expect(encodedMethod, isNotNull);
76
- final decodedMethod = Method.fromJson(jsonDecode(encodedMethod));
77
- expect(method.name, equals(decodedMethod.name));
78
- });
79
-
80
- test('Methods can be deserialized', () {
81
- final methodAsJson = '''
82
- {
83
- "name":"MethodName",
84
- "type":"String",
85
- "access_modifiers":["namespaceaccessible","public"],
86
- "parameters":[{"name":"Param1","type":"String","access_modifiers":[]}]
87
- }
88
- ''';
89
-
90
- final method = Method.fromJson(jsonDecode(methodAsJson));
91
- expect(method.name, equals('MethodName'));
92
- expect(method.type, equals('String'));
93
- expect(method.accessModifiers, equals(['namespaceaccessible', 'public']));
94
- expect(method.parameters.length, equals(1));
95
- expect(method.parameters.first.name, equals('Param1'));
96
- });
97
- });
98
-
99
- group('Parameter serialization', () {
100
- test('Parameters can be serialized', () {
101
- var parameter = Parameter(
102
- name: 'ParameterName',
103
- type: 'String',
104
- accessModifiers: ['namespaceaccessible', 'public']);
105
-
106
- String encodedParameter = jsonEncode(parameter);
107
- expect(encodedParameter, isNotNull);
108
- final decodedParameter = Parameter.fromJson(jsonDecode(encodedParameter));
109
- expect(parameter.name, equals(decodedParameter.name));
110
- });
111
-
112
- test('Parameters can be deserialized', () {
113
- final parameterAsJson = '''
114
- {
115
- "name": "ParameterName",
116
- "type": "String",
117
- "access_modifiers": ["namespaceaccessible", "public"]
118
- }
119
- ''';
120
-
121
- final parameter = Parameter.fromJson(jsonDecode(parameterAsJson));
122
- expect(parameter.name, equals('ParameterName'));
123
- expect(parameter.type, equals('String'));
124
- expect(
125
- parameter.accessModifiers, equals(['namespaceaccessible', 'public']));
126
- });
127
- });
128
-
129
- group('Constructor serialization', () {
130
- test('Constructors can be serialized', () {
131
- var constructor =
132
- Constructor(accessModifiers: ['namespaceaccessible', 'public']);
133
- constructor.addParameter(Parameter(name: 'Param1', type: 'String'));
134
-
135
- String encodedConstructor = jsonEncode(constructor);
136
- expect(encodedConstructor, isNotNull);
137
- final decodedConstructor =
138
- Constructor.fromJson(jsonDecode(encodedConstructor));
139
- expect(constructor.accessModifiers,
140
- equals(decodedConstructor.accessModifiers));
141
- });
142
-
143
- test('Constructors can be deserialized', () {
144
- final constructorAsJson = '''
145
- {
146
- "access_modifiers":["namespaceaccessible","public"],
147
- "parameters":[{"name":"Param1","type":"String","access_modifiers":[]}]
148
- }
149
- ''';
150
-
151
- final constructor = Constructor.fromJson(jsonDecode(constructorAsJson));
152
- expect(constructor.accessModifiers,
153
- equals(['namespaceaccessible', 'public']));
154
- expect(constructor.parameters.length, equals(1));
155
- expect(constructor.parameters.first.name, equals('Param1'));
156
- });
157
- });
158
- }
@@ -1,178 +0,0 @@
1
- import 'package:test/test.dart';
2
- import 'package:apexdocs_dart/src/model/members.dart';
3
-
4
- void main() {
5
- group('Properties tests', () {
6
- test('Properties have a name', () {
7
- var property = Property(name: 'MyProperty', type: 'String');
8
- expect(property.name, 'MyProperty');
9
- });
10
-
11
- test('Properties have a type', () {
12
- var property = Property(name: 'MyProperty', type: 'String');
13
- expect(property.type, 'String');
14
- });
15
-
16
- test('Do not have doc comments by default', () {
17
- final property = Property(name: 'AnyName', type: 'String');
18
- expect(property.rawDocComment, isNull);
19
- });
20
-
21
- test('Can receive doc comments', () {
22
- final property = Property(
23
- name: 'AnyName',
24
- type: 'String',
25
- docComment: '@description Some description');
26
- expect(property.rawDocComment, isNotNull);
27
- });
28
-
29
- test('Properties can have access modifiers', () {
30
- var property = Property(
31
- name: 'MyProp',
32
- type: 'String',
33
- accessModifiers: ['namespaceaccessible', 'public']);
34
- expect(property.isNamespaceAccessible, isTrue);
35
- expect(property.isPublic, isTrue);
36
- });
37
- });
38
-
39
- group('Fields tests', () {
40
- test('Fields have a name', () {
41
- var field = Field(name: 'MyField', type: 'String');
42
- expect(field.name, 'MyField');
43
- });
44
-
45
- test('Fields have a type', () {
46
- var field = Field(name: 'MyField', type: 'String');
47
- expect(field.type, 'String');
48
- });
49
-
50
- test('Do not have doc comments by default', () {
51
- final field = Field(name: 'AnyName', type: 'String');
52
- expect(field.rawDocComment, isNull);
53
- });
54
-
55
- test('Can receive doc comments', () {
56
- final field = Field(
57
- name: 'AnyName',
58
- type: 'String',
59
- docComment: '@description Some description');
60
- expect(field.rawDocComment, isNotNull);
61
- });
62
-
63
- test('Fields can have access modifiers', () {
64
- var field = Field(
65
- name: 'MyField',
66
- type: 'String',
67
- accessModifiers: ['namespaceaccessible', 'public']);
68
- expect(field.isNamespaceAccessible, isTrue);
69
- expect(field.isPublic, isTrue);
70
- });
71
- });
72
-
73
- group('Methods tests', () {
74
- test('Methods have a name', () {
75
- var method = Method(name: 'myMethod', type: 'String');
76
- expect(method.name, 'myMethod');
77
- });
78
-
79
- test('Do not have doc comments by default', () {
80
- final method = Method(name: 'AnyName', type: 'String');
81
- expect(method.rawDocComment, isNull);
82
- });
83
-
84
- test('Can receive doc comments', () {
85
- final method = Method(
86
- name: 'AnyName',
87
- type: 'String',
88
- docComment: '@description Some description');
89
- expect(method.rawDocComment, isNotNull);
90
- });
91
-
92
- test('Methods without a type are void', () {
93
- var method = Method(name: 'myMethod');
94
- expect(method.isVoid, isTrue);
95
- });
96
-
97
- test('Methods have a type', () {
98
- var method = Method(name: 'myMethod', type: 'String');
99
- expect(method.type, 'String');
100
- });
101
-
102
- test('Methods can have access modifiers', () {
103
- var method = Method(
104
- name: 'myMethod',
105
- type: 'String',
106
- accessModifiers: ['namespaceaccessible', 'public']);
107
- expect(method.isNamespaceAccessible, isTrue);
108
- expect(method.isPublic, isTrue);
109
- });
110
-
111
- test('Methods have no parameters by default', () {
112
- var method = Method(name: 'myMethod');
113
- expect(method.parameters.isEmpty, isTrue);
114
- });
115
-
116
- test('Can receive parameters', () {
117
- var method = Method(name: 'myMethod');
118
- var parameter = Parameter(name: 'Param', type: 'String');
119
- method.addParameter(parameter);
120
- expect(method.parameters.length, equals(1));
121
- expect(method.parameters.first, equals(parameter));
122
- });
123
- });
124
-
125
- group('Parameter tests', () {
126
- test('Parameters have a name', () {
127
- var parameter = Parameter(name: 'Param', type: 'String');
128
- expect(parameter.name, 'Param');
129
- });
130
-
131
- test('Parameters have a type', () {
132
- var parameter = Parameter(name: 'Param', type: 'String');
133
- expect(parameter.type, 'String');
134
- });
135
-
136
- test('Parameters can have access modifiers', () {
137
- var parameter = Parameter(
138
- name: 'Param',
139
- type: 'String',
140
- accessModifiers: ['namespaceaccessible', 'public']);
141
- expect(parameter.isNamespaceAccessible, isTrue);
142
- expect(parameter.isPublic, isTrue);
143
- });
144
- });
145
-
146
- group('Constructor tests', () {
147
- test('Can have access modifiers', () {
148
- var constructor =
149
- Constructor(accessModifiers: ['namespaceaccessible', 'public']);
150
- expect(constructor.isNamespaceAccessible, isTrue);
151
- expect(constructor.isPublic, isTrue);
152
- });
153
-
154
- test('Do not have doc comments by default', () {
155
- final constructor = Constructor();
156
- expect(constructor.rawDocComment, isNull);
157
- });
158
-
159
- test('Can receive doc comments', () {
160
- final constructor =
161
- Constructor(docComment: '@description Some description');
162
- expect(constructor.rawDocComment, isNotNull);
163
- });
164
-
165
- test('Have no parameters by default', () {
166
- var constructor = Constructor();
167
- expect(constructor.parameters.isEmpty, isTrue);
168
- });
169
-
170
- test('Can receive parameters', () {
171
- var constructor = Constructor();
172
- var parameter = Parameter(name: 'Param', type: 'String');
173
- constructor.addParameter(parameter);
174
- expect(constructor.parameters.length, equals(1));
175
- expect(constructor.parameters.first, equals(parameter));
176
- });
177
- });
178
- }