@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.
- package/__tests__/end-to-end.test.ts +256 -0
- package/coverage/clover.xml +12857 -0
- package/coverage/coverage-final.json +3 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +79 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +126 -0
- package/coverage/lcov-report/index.js.html +104 -0
- package/coverage/lcov-report/out.js.html +41126 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +170 -0
- package/coverage/lcov.info +24801 -0
- package/index.d.ts +118 -0
- package/index.js +8 -0
- package/index.ts +141 -0
- package/jest.config.js +11 -0
- package/out.js +13708 -0
- package/package.json +22 -17
- package/tsconfig.json +5 -3
- package/.idea/apexdocs-dart.iml +0 -18
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/libraries/Dart_Packages.xml +0 -556
- package/.idea/libraries/Dart_SDK.xml +0 -28
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/runConfigurations/_template__of_Dart_Test.xml +0 -6
- package/.idea/vcs.xml +0 -6
- package/CHANGELOG.md +0 -3
- package/README.md +0 -26
- package/TODO.md +0 -5
- package/analysis_options.yaml +0 -30
- package/antlr4-4.9.2/CHANGELOG.md +0 -4
- package/antlr4-4.9.2/LICENSE +0 -52
- package/antlr4-4.9.2/README.md +0 -11
- package/antlr4-4.9.2/analysis_options.yaml +0 -1
- package/antlr4-4.9.2/lib/antlr4.dart +0 -21
- package/antlr4-4.9.2/lib/src/atn/atn.dart +0 -18
- package/antlr4-4.9.2/lib/src/atn/src/atn.dart +0 -170
- package/antlr4-4.9.2/lib/src/atn/src/atn_config.dart +0 -242
- package/antlr4-4.9.2/lib/src/atn/src/atn_config_set.dart +0 -283
- package/antlr4-4.9.2/lib/src/atn/src/atn_deserializer.dart +0 -809
- package/antlr4-4.9.2/lib/src/atn/src/atn_simulator.dart +0 -95
- package/antlr4-4.9.2/lib/src/atn/src/atn_state.dart +0 -296
- package/antlr4-4.9.2/lib/src/atn/src/atn_type.dart +0 -14
- package/antlr4-4.9.2/lib/src/atn/src/info.dart +0 -553
- package/antlr4-4.9.2/lib/src/atn/src/lexer_action.dart +0 -601
- package/antlr4-4.9.2/lib/src/atn/src/lexer_action_executor.dart +0 -167
- package/antlr4-4.9.2/lib/src/atn/src/lexer_atn_simulator.dart +0 -731
- package/antlr4-4.9.2/lib/src/atn/src/parser_atn_simulator.dart +0 -2630
- package/antlr4-4.9.2/lib/src/atn/src/profiling_atn_simulator.dart +0 -229
- package/antlr4-4.9.2/lib/src/atn/src/semantic_context.dart +0 -404
- package/antlr4-4.9.2/lib/src/atn/src/transition.dart +0 -305
- package/antlr4-4.9.2/lib/src/dfa/dfa.dart +0 -8
- package/antlr4-4.9.2/lib/src/dfa/src/dfa.dart +0 -138
- package/antlr4-4.9.2/lib/src/dfa/src/dfa_serializer.dart +0 -76
- package/antlr4-4.9.2/lib/src/dfa/src/dfa_state.dart +0 -151
- package/antlr4-4.9.2/lib/src/error/error.dart +0 -10
- package/antlr4-4.9.2/lib/src/error/src/diagnostic_error_listener.dart +0 -116
- package/antlr4-4.9.2/lib/src/error/src/error_listener.dart +0 -241
- package/antlr4-4.9.2/lib/src/error/src/error_strategy.dart +0 -902
- package/antlr4-4.9.2/lib/src/error/src/errors.dart +0 -204
- package/antlr4-4.9.2/lib/src/input_stream.dart +0 -335
- package/antlr4-4.9.2/lib/src/interval_set.dart +0 -735
- package/antlr4-4.9.2/lib/src/lexer.dart +0 -343
- package/antlr4-4.9.2/lib/src/ll1_analyzer.dart +0 -204
- package/antlr4-4.9.2/lib/src/misc/multi_map.dart +0 -32
- package/antlr4-4.9.2/lib/src/misc/pair.dart +0 -34
- package/antlr4-4.9.2/lib/src/parser.dart +0 -777
- package/antlr4-4.9.2/lib/src/parser_interpreter.dart +0 -393
- package/antlr4-4.9.2/lib/src/parser_rule_context.dart +0 -275
- package/antlr4-4.9.2/lib/src/prediction_context.dart +0 -877
- package/antlr4-4.9.2/lib/src/recognizer.dart +0 -182
- package/antlr4-4.9.2/lib/src/rule_context.dart +0 -192
- package/antlr4-4.9.2/lib/src/runtime_meta_data.dart +0 -188
- package/antlr4-4.9.2/lib/src/token.dart +0 -431
- package/antlr4-4.9.2/lib/src/token_factory.dart +0 -88
- package/antlr4-4.9.2/lib/src/token_source.dart +0 -241
- package/antlr4-4.9.2/lib/src/token_stream.dart +0 -627
- package/antlr4-4.9.2/lib/src/tree/src/pattern/chunk.dart +0 -90
- package/antlr4-4.9.2/lib/src/tree/src/pattern/parse_tree_match.dart +0 -635
- package/antlr4-4.9.2/lib/src/tree/src/tree.dart +0 -370
- package/antlr4-4.9.2/lib/src/tree/src/trees.dart +0 -226
- package/antlr4-4.9.2/lib/src/tree/tree.dart +0 -10
- package/antlr4-4.9.2/lib/src/util/bit_set.dart +0 -308
- package/antlr4-4.9.2/lib/src/util/murmur_hash.dart +0 -77
- package/antlr4-4.9.2/lib/src/util/utils.dart +0 -31
- package/antlr4-4.9.2/lib/src/vocabulary.dart +0 -254
- package/antlr4-4.9.2/pubspec.yaml +0 -13
- package/example/node_example/index.js +0 -8
- package/example/node_example/package.json +0 -12
- package/example/node_example_ts/package-lock.json +0 -70
- package/example/node_example_ts/package.json +0 -19
- package/example/node_example_ts/src/index.js +0 -5
- package/example/node_example_ts/src/index.ts +0 -9
- package/example/node_example_ts/tsconfig.json +0 -79
- package/js/dart2jsout.js +0 -25898
- package/js/dart2jsout.js.map +0 -16
- package/js/index.d.ts +0 -1
- package/js/index.js +0 -4
- package/js/out.js +0 -26023
- package/js/out.js.map +0 -16
- package/js/package-lock.json +0 -57
- package/js/preamble.js +0 -125
- package/lib/apexdocs_dart.dart +0 -28
- package/lib/src/antlr/grammars/Apexdoc/ApexdocLexer.g4 +0 -120
- package/lib/src/antlr/grammars/Apexdoc/ApexdocParser.g4 +0 -158
- package/lib/src/antlr/grammars/Apexdoc/gen/ApexdocLexer.interp +0 -95
- package/lib/src/antlr/grammars/Apexdoc/gen/ApexdocLexer.java +0 -238
- package/lib/src/antlr/grammars/Apexdoc/gen/ApexdocLexer.tokens +0 -23
- package/lib/src/antlr/grammars/apex/ApexLexer.g4 +0 -255
- package/lib/src/antlr/grammars/apex/ApexParser.g4 +0 -567
- package/lib/src/antlr/grammars/apex/examples/ApexClass.cls +0 -6
- package/lib/src/antlr/lib/apex/ApexLexer.dart +0 -1223
- package/lib/src/antlr/lib/apex/ApexLexer.interp +0 -393
- package/lib/src/antlr/lib/apex/ApexLexer.tokens +0 -212
- package/lib/src/antlr/lib/apex/ApexParser.dart +0 -9349
- package/lib/src/antlr/lib/apex/ApexParser.interp +0 -326
- package/lib/src/antlr/lib/apex/ApexParser.tokens +0 -212
- package/lib/src/antlr/lib/apex/ApexParserBaseListener.dart +0 -1036
- package/lib/src/antlr/lib/apex/ApexParserListener.dart +0 -975
- package/lib/src/antlr/lib/apexdoc/ApexdocLexer.dart +0 -373
- package/lib/src/antlr/lib/apexdoc/ApexdocLexer.interp +0 -95
- package/lib/src/antlr/lib/apexdoc/ApexdocLexer.tokens +0 -23
- package/lib/src/antlr/lib/apexdoc/ApexdocParser.dart +0 -2471
- package/lib/src/antlr/lib/apexdoc/ApexdocParser.interp +0 -69
- package/lib/src/antlr/lib/apexdoc/ApexdocParser.tokens +0 -23
- package/lib/src/antlr/lib/apexdoc/ApexdocParserBaseListener.dart +0 -252
- package/lib/src/antlr/lib/apexdoc/ApexdocParserListener.dart +0 -215
- package/lib/src/builders/builders.dart +0 -32
- package/lib/src/model/apex_file_manifest.dart +0 -37
- package/lib/src/model/apex_file_manifest.g.dart +0 -18
- package/lib/src/model/declaration.dart +0 -50
- package/lib/src/model/doc_comment.dart +0 -117
- package/lib/src/model/doc_comment.g.dart +0 -118
- package/lib/src/model/members.dart +0 -143
- package/lib/src/model/members.g.dart +0 -105
- package/lib/src/model/types.dart +0 -159
- package/lib/src/model/types.g.dart +0 -111
- package/lib/src/service/apex_listener.dart +0 -226
- package/lib/src/service/apexdoc_listener.dart +0 -82
- package/lib/src/service/parsers.dart +0 -33
- package/lib/src/service/utils/parsing/access_modifiers_parser.dart +0 -33
- package/lib/src/service/utils/parsing/parameters_parser.dart +0 -18
- package/lib/src/service/utils/parsing/parsing_utils.dart +0 -2
- package/lib/src/service/walker.dart +0 -82
- package/pubspec.yaml +0 -19
- package/test/apex_file_manifest_test.dart +0 -16
- package/test/apex_listener_test.dart +0 -703
- package/test/apexdoc_parser_test.dart +0 -179
- package/test/doc_comment_test.dart +0 -89
- package/test/members_serialization_test.dart +0 -158
- package/test/members_test.dart +0 -178
- package/test/types_serialization_test.dart +0 -191
- package/test/types_test.dart +0 -311
- package/test/walker_test.dart +0 -58
- package/tool/grind.dart +0 -20
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
2
|
-
|
|
3
|
-
part of 'types.dart';
|
|
4
|
-
|
|
5
|
-
// **************************************************************************
|
|
6
|
-
// JsonSerializableGenerator
|
|
7
|
-
// **************************************************************************
|
|
8
|
-
|
|
9
|
-
ClassModel _$ClassModelFromJson(Map<String, dynamic> json) {
|
|
10
|
-
return ClassModel(
|
|
11
|
-
name: json['name'] as String,
|
|
12
|
-
docComment: json['docComment'] as String?,
|
|
13
|
-
accessModifiers: (json['access_modifiers'] as List<dynamic>)
|
|
14
|
-
.map((e) => e as String)
|
|
15
|
-
.toList(),
|
|
16
|
-
extendedClass: json['extended_class'] as String?,
|
|
17
|
-
implementedInterfaces: (json['implemented_interfaces'] as List<dynamic>)
|
|
18
|
-
.map((e) => e as String)
|
|
19
|
-
.toList(),
|
|
20
|
-
)
|
|
21
|
-
..rawDocComment = json['rawDocComment'] as String?
|
|
22
|
-
..typeName = json['type_name'] as String
|
|
23
|
-
..methods = (json['methods'] as List<dynamic>)
|
|
24
|
-
.map((e) => Method.fromJson(e as Map<String, dynamic>))
|
|
25
|
-
.toList()
|
|
26
|
-
..properties = (json['properties'] as List<dynamic>)
|
|
27
|
-
.map((e) => Property.fromJson(e as Map<String, dynamic>))
|
|
28
|
-
.toList()
|
|
29
|
-
..fields = (json['fields'] as List<dynamic>)
|
|
30
|
-
.map((e) => Field.fromJson(e as Map<String, dynamic>))
|
|
31
|
-
.toList()
|
|
32
|
-
..constructors = (json['constructors'] as List<dynamic>)
|
|
33
|
-
.map((e) => Constructor.fromJson(e as Map<String, dynamic>))
|
|
34
|
-
.toList()
|
|
35
|
-
..enums = (json['enums'] as List<dynamic>)
|
|
36
|
-
.map((e) => EnumModel.fromJson(e as Map<String, dynamic>))
|
|
37
|
-
.toList()
|
|
38
|
-
..interfaces = (json['interfaces'] as List<dynamic>)
|
|
39
|
-
.map((e) => InterfaceModel.fromJson(e as Map<String, dynamic>))
|
|
40
|
-
.toList()
|
|
41
|
-
..classes = (json['classes'] as List<dynamic>)
|
|
42
|
-
.map((e) => ClassModel.fromJson(e as Map<String, dynamic>))
|
|
43
|
-
.toList();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
Map<String, dynamic> _$ClassModelToJson(ClassModel instance) =>
|
|
47
|
-
<String, dynamic>{
|
|
48
|
-
'access_modifiers': instance.accessModifiers,
|
|
49
|
-
'rawDocComment': instance.rawDocComment,
|
|
50
|
-
'docComment': instance.docComment,
|
|
51
|
-
'name': instance.name,
|
|
52
|
-
'type_name': instance.typeName,
|
|
53
|
-
'methods': instance.methods,
|
|
54
|
-
'extended_class': instance.extendedClass,
|
|
55
|
-
'implemented_interfaces': instance.implementedInterfaces,
|
|
56
|
-
'properties': instance.properties,
|
|
57
|
-
'fields': instance.fields,
|
|
58
|
-
'constructors': instance.constructors,
|
|
59
|
-
'enums': instance.enums,
|
|
60
|
-
'interfaces': instance.interfaces,
|
|
61
|
-
'classes': instance.classes,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
InterfaceModel _$InterfaceModelFromJson(Map<String, dynamic> json) {
|
|
65
|
-
return InterfaceModel(
|
|
66
|
-
name: json['name'] as String,
|
|
67
|
-
docComment: json['docComment'] as String?,
|
|
68
|
-
accessModifiers: (json['access_modifiers'] as List<dynamic>)
|
|
69
|
-
.map((e) => e as String)
|
|
70
|
-
.toList(),
|
|
71
|
-
extendedInterfaces: (json['extended_interfaces'] as List<dynamic>)
|
|
72
|
-
.map((e) => e as String)
|
|
73
|
-
.toList(),
|
|
74
|
-
)
|
|
75
|
-
..rawDocComment = json['rawDocComment'] as String?
|
|
76
|
-
..typeName = json['type_name'] as String
|
|
77
|
-
..methods = (json['methods'] as List<dynamic>)
|
|
78
|
-
.map((e) => Method.fromJson(e as Map<String, dynamic>))
|
|
79
|
-
.toList();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
Map<String, dynamic> _$InterfaceModelToJson(InterfaceModel instance) =>
|
|
83
|
-
<String, dynamic>{
|
|
84
|
-
'access_modifiers': instance.accessModifiers,
|
|
85
|
-
'rawDocComment': instance.rawDocComment,
|
|
86
|
-
'docComment': instance.docComment,
|
|
87
|
-
'name': instance.name,
|
|
88
|
-
'type_name': instance.typeName,
|
|
89
|
-
'methods': instance.methods,
|
|
90
|
-
'extended_interfaces': instance.extendedInterfaces,
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
EnumModel _$EnumModelFromJson(Map<String, dynamic> json) {
|
|
94
|
-
return EnumModel(
|
|
95
|
-
name: json['name'] as String,
|
|
96
|
-
docComment: json['docComment'] as String?,
|
|
97
|
-
accessModifiers: (json['access_modifiers'] as List<dynamic>)
|
|
98
|
-
.map((e) => e as String)
|
|
99
|
-
.toList(),
|
|
100
|
-
)
|
|
101
|
-
..rawDocComment = json['rawDocComment'] as String?
|
|
102
|
-
..typeName = json['type_name'] as String;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
Map<String, dynamic> _$EnumModelToJson(EnumModel instance) => <String, dynamic>{
|
|
106
|
-
'access_modifiers': instance.accessModifiers,
|
|
107
|
-
'rawDocComment': instance.rawDocComment,
|
|
108
|
-
'docComment': instance.docComment,
|
|
109
|
-
'name': instance.name,
|
|
110
|
-
'type_name': instance.typeName,
|
|
111
|
-
};
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import 'dart:collection';
|
|
2
|
-
|
|
3
|
-
import 'package:apexdocs_dart/src/antlr/lib/apex/ApexParser.dart';
|
|
4
|
-
import 'package:apexdocs_dart/src/antlr/lib/apex/ApexParserBaseListener.dart';
|
|
5
|
-
import 'package:apexdocs_dart/src/builders/builders.dart';
|
|
6
|
-
import 'package:apexdocs_dart/src/model/members.dart';
|
|
7
|
-
import 'package:apexdocs_dart/src/model/types.dart';
|
|
8
|
-
import 'package:apexdocs_dart/src/service/utils/parsing/parsing_utils.dart';
|
|
9
|
-
|
|
10
|
-
class DeclarationDescriptor {
|
|
11
|
-
List<String> accessModifiers = [];
|
|
12
|
-
String? docComment;
|
|
13
|
-
|
|
14
|
-
DeclarationDescriptor({required this.accessModifiers, this.docComment});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
class ApexClassListener extends ApexParserBaseListener {
|
|
18
|
-
final Stack<DeclarationDescriptor> _declaratorDescriptorStack;
|
|
19
|
-
final Stack<Type> generatedTypes;
|
|
20
|
-
late Type generatedType;
|
|
21
|
-
|
|
22
|
-
ApexClassListener()
|
|
23
|
-
: generatedTypes = Stack<Type>(),
|
|
24
|
-
_declaratorDescriptorStack = Stack<DeclarationDescriptor>();
|
|
25
|
-
|
|
26
|
-
@override
|
|
27
|
-
void enterTypeClassDeclaration(TypeClassDeclarationContext ctx) {
|
|
28
|
-
final accessModifiers = getAccessModifiers(ctx);
|
|
29
|
-
final docComment = ctx.DOC_COMMENT()?.text;
|
|
30
|
-
_declaratorDescriptorStack.push(DeclarationDescriptor(
|
|
31
|
-
accessModifiers: accessModifiers, docComment: docComment));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@override
|
|
35
|
-
void enterTypeEnumDeclaration(TypeEnumDeclarationContext ctx) {
|
|
36
|
-
final accessModifiers = getAccessModifiers(ctx);
|
|
37
|
-
final docComment = ctx.DOC_COMMENT()?.text;
|
|
38
|
-
_declaratorDescriptorStack.push(DeclarationDescriptor(
|
|
39
|
-
accessModifiers: accessModifiers, docComment: docComment));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@override
|
|
43
|
-
void enterTypeInterfaceDeclaration(TypeInterfaceDeclarationContext ctx) {
|
|
44
|
-
final accessModifiers = getAccessModifiers(ctx);
|
|
45
|
-
final docComment = ctx.DOC_COMMENT()?.text;
|
|
46
|
-
_declaratorDescriptorStack.push(DeclarationDescriptor(
|
|
47
|
-
accessModifiers: accessModifiers, docComment: docComment));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@override
|
|
51
|
-
void enterClassDeclaration(ClassDeclarationContext ctx) {
|
|
52
|
-
final declarationDescriptor = _declaratorDescriptorStack.pop();
|
|
53
|
-
generatedTypes.push(buildClass(declarationDescriptor, ctx));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
@override
|
|
57
|
-
void enterInterfaceDeclaration(InterfaceDeclarationContext ctx) {
|
|
58
|
-
final declarationDescriptor = _declaratorDescriptorStack.pop();
|
|
59
|
-
generatedTypes.push(buildInterface(declarationDescriptor, ctx));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
@override
|
|
63
|
-
void enterEnumDeclaration(EnumDeclarationContext ctx) {
|
|
64
|
-
final declarationDescriptor = _declaratorDescriptorStack.pop();
|
|
65
|
-
final enumName = ctx.id().text;
|
|
66
|
-
final enumModel = EnumModel(
|
|
67
|
-
name: enumName,
|
|
68
|
-
docComment: declarationDescriptor.docComment,
|
|
69
|
-
accessModifiers: declarationDescriptor.accessModifiers);
|
|
70
|
-
generatedTypes.push(enumModel);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
@override
|
|
74
|
-
void enterMemberClassBodyDeclaration(MemberClassBodyDeclarationContext ctx) {
|
|
75
|
-
final accessModifiers = getAccessModifiers(ctx);
|
|
76
|
-
final docComment = ctx.DOC_COMMENT()?.text;
|
|
77
|
-
_declaratorDescriptorStack.push(DeclarationDescriptor(
|
|
78
|
-
accessModifiers: accessModifiers, docComment: docComment));
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
@override
|
|
82
|
-
void enterPropertyDeclaration(PropertyDeclarationContext ctx) {
|
|
83
|
-
final declarationDescriptor = _declaratorDescriptorStack.pop();
|
|
84
|
-
final propertyName = ctx.id().text;
|
|
85
|
-
final type = ctx.typeRef().text;
|
|
86
|
-
|
|
87
|
-
final property = Property(
|
|
88
|
-
name: propertyName,
|
|
89
|
-
docComment: declarationDescriptor.docComment,
|
|
90
|
-
type: type,
|
|
91
|
-
accessModifiers: declarationDescriptor.accessModifiers);
|
|
92
|
-
(generatedTypes.peak() as ClassModel).addProperty(property);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
@override
|
|
96
|
-
void enterFieldDeclaration(FieldDeclarationContext ctx) {
|
|
97
|
-
final declarationDescriptor = _declaratorDescriptorStack.pop();
|
|
98
|
-
final typeName = ctx.typeRef().text;
|
|
99
|
-
final fieldNames =
|
|
100
|
-
ctx.variableDeclarators().variableDeclarators().map((e) => e.text);
|
|
101
|
-
(generatedTypes.peak() as ClassModel).fields.addAll(fieldNames.map((e) =>
|
|
102
|
-
Field(
|
|
103
|
-
name: e,
|
|
104
|
-
docComment: declarationDescriptor.docComment,
|
|
105
|
-
type: typeName,
|
|
106
|
-
accessModifiers: declarationDescriptor.accessModifiers)));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
@override
|
|
110
|
-
void enterMethodDeclaration(MethodDeclarationContext ctx) {
|
|
111
|
-
final declarationDescriptor = _declaratorDescriptorStack.pop();
|
|
112
|
-
final methodName = ctx.id().text;
|
|
113
|
-
final typeName = ctx.typeRef() != null ? ctx.typeRef().text : 'void';
|
|
114
|
-
|
|
115
|
-
List<Parameter>? parameters = parseParameters(ctx);
|
|
116
|
-
|
|
117
|
-
final method = Method(
|
|
118
|
-
name: methodName,
|
|
119
|
-
docComment: declarationDescriptor.docComment,
|
|
120
|
-
type: typeName,
|
|
121
|
-
accessModifiers: declarationDescriptor.accessModifiers);
|
|
122
|
-
method.parameters = parameters ?? [];
|
|
123
|
-
|
|
124
|
-
(generatedTypes.peak() as MethodsAwareness).methods.add(method);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
@override
|
|
128
|
-
void enterInterfaceMethodDeclaration(InterfaceMethodDeclarationContext ctx) {
|
|
129
|
-
final docComment = ctx.DOC_COMMENT()?.text;
|
|
130
|
-
// Interface methods inherit the access modifiers of the parent declaration.
|
|
131
|
-
final accessModifiers = generatedTypes.peak().accessModifiers;
|
|
132
|
-
final methodName = ctx.id().text;
|
|
133
|
-
final typeName = ctx.typeRef() != null ? ctx.typeRef()!.text : 'void';
|
|
134
|
-
|
|
135
|
-
List<Parameter>? parameters = parseParameters(ctx);
|
|
136
|
-
|
|
137
|
-
final method = Method(
|
|
138
|
-
name: methodName,
|
|
139
|
-
docComment: docComment,
|
|
140
|
-
type: typeName,
|
|
141
|
-
accessModifiers: accessModifiers);
|
|
142
|
-
method.parameters = parameters ?? [];
|
|
143
|
-
|
|
144
|
-
(generatedTypes.peak() as MethodsAwareness).methods.add(method);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
@override
|
|
148
|
-
void enterConstructorDeclaration(ConstructorDeclarationContext ctx) {
|
|
149
|
-
final declaratorDescriptor = _declaratorDescriptorStack.pop();
|
|
150
|
-
List<Parameter>? parameters = parseParameters(ctx);
|
|
151
|
-
final constructorGenerated = Constructor(
|
|
152
|
-
docComment: declaratorDescriptor.docComment,
|
|
153
|
-
accessModifiers: declaratorDescriptor.accessModifiers);
|
|
154
|
-
constructorGenerated.parameters = parameters ?? [];
|
|
155
|
-
|
|
156
|
-
(generatedTypes.peak() as ClassModel)
|
|
157
|
-
.constructors
|
|
158
|
-
.add(constructorGenerated);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
@override
|
|
162
|
-
void exitClassDeclaration(ClassDeclarationContext ctx) {
|
|
163
|
-
_onExitDeclaration();
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
@override
|
|
167
|
-
void exitEnumDeclaration(EnumDeclarationContext ctx) {
|
|
168
|
-
_onExitDeclaration();
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
@override
|
|
172
|
-
void exitInterfaceDeclaration(InterfaceDeclarationContext ctx) {
|
|
173
|
-
_onExitDeclaration();
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
void _onExitDeclaration() {
|
|
177
|
-
if (_atTheTopOfTheStack()) {
|
|
178
|
-
// If we are at the top level of the class, then parsing has finalized,
|
|
179
|
-
// so we want to pop the last item of the stack and set that as the
|
|
180
|
-
// generated type.
|
|
181
|
-
generatedType = generatedTypes.pop();
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Otherwise then we want to add this as an inner class to whoever is on top.
|
|
186
|
-
final currentGeneratedType = generatedTypes.pop();
|
|
187
|
-
var topLevelClass = generatedTypes.peak() as ClassModel;
|
|
188
|
-
if (currentGeneratedType.isClass()) {
|
|
189
|
-
topLevelClass.addClass(currentGeneratedType as ClassModel);
|
|
190
|
-
} else if (currentGeneratedType.isEnum()) {
|
|
191
|
-
topLevelClass.addEnum(currentGeneratedType as EnumModel);
|
|
192
|
-
} else {
|
|
193
|
-
topLevelClass.addInterface(currentGeneratedType as InterfaceModel);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
bool _atTheTopOfTheStack() {
|
|
198
|
-
return generatedTypes.length == 1;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
class Stack<T> {
|
|
203
|
-
final _stack = Queue<T>();
|
|
204
|
-
|
|
205
|
-
int get length => _stack.length;
|
|
206
|
-
|
|
207
|
-
bool canPop() => _stack.isNotEmpty;
|
|
208
|
-
|
|
209
|
-
void clearStack() {
|
|
210
|
-
while (_stack.isNotEmpty) {
|
|
211
|
-
_stack.removeLast();
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
void push(T element) {
|
|
216
|
-
_stack.addLast(element);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
T pop() {
|
|
220
|
-
T lastElement = _stack.last;
|
|
221
|
-
_stack.removeLast();
|
|
222
|
-
return lastElement;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
T peak() => _stack.last;
|
|
226
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import 'dart:convert';
|
|
2
|
-
|
|
3
|
-
import 'package:apexdocs_dart/src/antlr/lib/apexdoc/ApexdocParser.dart';
|
|
4
|
-
import 'package:apexdocs_dart/src/antlr/lib/apexdoc/ApexdocParserBaseListener.dart';
|
|
5
|
-
import 'package:apexdocs_dart/src/model/doc_comment.dart';
|
|
6
|
-
|
|
7
|
-
class ApexdocListener extends ApexdocParserBaseListener {
|
|
8
|
-
var descriptionLines = <String>[];
|
|
9
|
-
|
|
10
|
-
DocComment generatedDocComment = DocComment('');
|
|
11
|
-
|
|
12
|
-
/* Description */
|
|
13
|
-
|
|
14
|
-
@override
|
|
15
|
-
void enterDescriptionLineStart(DescriptionLineStartContext ctx) {
|
|
16
|
-
var descriptionText = ctx.text;
|
|
17
|
-
descriptionLines.add(_sanitizeLineStart(descriptionText));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@override
|
|
21
|
-
void exitDescriptionLineStart(DescriptionLineStartContext ctx) {
|
|
22
|
-
generatedDocComment.descriptionLines = descriptionLines;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/* Block tag (annotations) */
|
|
26
|
-
|
|
27
|
-
@override
|
|
28
|
-
void enterDefaultBlockTag(DefaultBlockTagContext ctx) {
|
|
29
|
-
final tagName = ctx.blockTagName().text;
|
|
30
|
-
generatedDocComment.annotations.add(DocCommentAnnotation(
|
|
31
|
-
tagName, _getContentLines(ctx.blockTagContents())));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@override
|
|
35
|
-
void enterParamBlockTag(ParamBlockTagContext ctx) {
|
|
36
|
-
final paramName = ctx.paramName().text;
|
|
37
|
-
final contentLines = _getContentLines(ctx.blockTagContents());
|
|
38
|
-
generatedDocComment.paramAnnotations
|
|
39
|
-
.add(ParamDocCommentAnnotation(paramName, contentLines));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@override
|
|
43
|
-
void enterReturnBlockTag(ReturnBlockTagContext ctx) {
|
|
44
|
-
final contentLines = _getContentLines(ctx.blockTagContents());
|
|
45
|
-
generatedDocComment.returnAnnotation =
|
|
46
|
-
ReturnDocCommentAnnotation(contentLines);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@override
|
|
50
|
-
void enterThrowsBlockTag(ThrowsBlockTagContext ctx) {
|
|
51
|
-
final exceptionName = ctx.exceptionName().text;
|
|
52
|
-
final contentLines = _getContentLines(ctx.blockTagContents());
|
|
53
|
-
generatedDocComment.throwsAnnotations
|
|
54
|
-
.add(ThrowsDocCommentAnnotation(exceptionName, contentLines));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
@override
|
|
58
|
-
void enterExampleBlockTag(ExampleBlockTagContext ctx) {
|
|
59
|
-
final contentLines = _getContentLines(ctx.blockTagContents());
|
|
60
|
-
generatedDocComment.exampleAnnotation =
|
|
61
|
-
ExampleDocCommentAnnotation(contentLines);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
List<String> _getContentLines(List<BlockTagContentContext> blockTagContents) {
|
|
65
|
-
final rawContent = blockTagContents.map((e) => e.text).join('');
|
|
66
|
-
return LineSplitter.split(rawContent)
|
|
67
|
-
.map((e) => _sanitizeLineStart(e))
|
|
68
|
-
.where((element) => element.isNotEmpty)
|
|
69
|
-
.toList();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
String _sanitizeLineStart(String line) {
|
|
73
|
-
var sanitizedLine = line.trimLeft();
|
|
74
|
-
if (sanitizedLine.startsWith('*')) {
|
|
75
|
-
sanitizedLine = sanitizedLine.replaceFirst('*', '');
|
|
76
|
-
}
|
|
77
|
-
if (sanitizedLine.startsWith(' ')) {
|
|
78
|
-
sanitizedLine = sanitizedLine.replaceFirst(' ', '');
|
|
79
|
-
}
|
|
80
|
-
return sanitizedLine.trimRight();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import 'dart:convert';
|
|
2
|
-
|
|
3
|
-
import 'package:antlr4/antlr4.dart';
|
|
4
|
-
import 'package:apexdocs_dart/src/model/doc_comment.dart';
|
|
5
|
-
import 'package:apexdocs_dart/src/model/types.dart';
|
|
6
|
-
import 'package:apexdocs_dart/src/service/walker.dart';
|
|
7
|
-
|
|
8
|
-
class ApexParser {
|
|
9
|
-
static Future<Type> parseFromPath(String path) async {
|
|
10
|
-
final input = await InputStream.fromPath(path);
|
|
11
|
-
return _parse(input);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static Type parseFromBody(String body) {
|
|
15
|
-
final input = InputStream.fromString(body);
|
|
16
|
-
return _parse(input);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static Type _parse(InputStream input) {
|
|
20
|
-
final walkerDefinition = ApexWalkerDefinition();
|
|
21
|
-
Walker.walk(input, walkerDefinition);
|
|
22
|
-
return walkerDefinition.getGeneratedApexType()!;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
class ApexdocParser {
|
|
27
|
-
static DocComment parseFromBody(String body) {
|
|
28
|
-
var sanitizedBody = body.trimLeft().trimRight();
|
|
29
|
-
final walkerDefinition = ApexdocWalkerDefinition();
|
|
30
|
-
Walker.walk(InputStream.fromString(sanitizedBody), walkerDefinition);
|
|
31
|
-
return walkerDefinition.getGeneratedDocComment();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
List<String> getAccessModifiers(dynamic ctx) {
|
|
2
|
-
bool _hasNoVisibilityModifiers(dynamic ctx) {
|
|
3
|
-
var modifiers = _allModifiers(ctx);
|
|
4
|
-
return !modifiers.contains('private') &&
|
|
5
|
-
!modifiers.contains('public') &&
|
|
6
|
-
!modifiers.contains('global') &&
|
|
7
|
-
!modifiers.contains('protected');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
var accessModifiers = [
|
|
11
|
-
// In Apex a declaration with no visibility modifier is private by default
|
|
12
|
-
if (_hasNoVisibilityModifiers(ctx)) 'private',
|
|
13
|
-
..._allModifiers(ctx)
|
|
14
|
-
];
|
|
15
|
-
return accessModifiers;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
List<String> _allModifiers(dynamic ctx) {
|
|
19
|
-
String _sanitizeModifier(String modifier) {
|
|
20
|
-
var sanitizedString = modifier.replaceFirst('@', '').toLowerCase();
|
|
21
|
-
if (sanitizedString.contains('(')) {
|
|
22
|
-
sanitizedString = sanitizedString.replaceRange(
|
|
23
|
-
modifier.indexOf('(') - 1, modifier.indexOf(')'), '');
|
|
24
|
-
}
|
|
25
|
-
return sanitizedString;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return ctx
|
|
29
|
-
.modifiers()
|
|
30
|
-
.map((modifierContext) => _sanitizeModifier(modifierContext.text))
|
|
31
|
-
.toList()
|
|
32
|
-
.cast<String>();
|
|
33
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import 'package:apexdocs_dart/src/model/members.dart';
|
|
2
|
-
|
|
3
|
-
List<Parameter>? parseParameters(dynamic ctx) {
|
|
4
|
-
final parameters = ctx
|
|
5
|
-
.formalParameters()
|
|
6
|
-
?.formalParameterList()
|
|
7
|
-
?.formalParameters()
|
|
8
|
-
.map((e) => Parameter(
|
|
9
|
-
name: e.id().text,
|
|
10
|
-
type: e.typeRef().text,
|
|
11
|
-
accessModifiers: e
|
|
12
|
-
.modifiers()
|
|
13
|
-
.map((e) => e.text as String)
|
|
14
|
-
.toList()
|
|
15
|
-
.cast<String>()))
|
|
16
|
-
.toList();
|
|
17
|
-
return parameters == null ? <Parameter>[] : parameters.cast<Parameter>();
|
|
18
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import 'package:antlr4/antlr4.dart';
|
|
2
|
-
|
|
3
|
-
import 'package:apexdocs_dart/src/antlr/lib/apex/ApexLexer.dart';
|
|
4
|
-
import 'package:apexdocs_dart/src/antlr/lib/apex/ApexParser.dart';
|
|
5
|
-
import 'package:apexdocs_dart/src/antlr/lib/apexdoc/ApexdocLexer.dart';
|
|
6
|
-
import 'package:apexdocs_dart/src/antlr/lib/apexdoc/ApexdocParser.dart';
|
|
7
|
-
import 'package:apexdocs_dart/src/model/doc_comment.dart';
|
|
8
|
-
import 'package:apexdocs_dart/src/service/apex_listener.dart';
|
|
9
|
-
import 'package:apexdocs_dart/src/model/types.dart';
|
|
10
|
-
|
|
11
|
-
import 'apexdoc_listener.dart';
|
|
12
|
-
|
|
13
|
-
class Walker {
|
|
14
|
-
static walk(InputStream input, WalkerDefinition definition) {
|
|
15
|
-
final lexer = definition.getLexer(input);
|
|
16
|
-
final tokens = CommonTokenStream(lexer);
|
|
17
|
-
final tree = definition.initializeTree(tokens);
|
|
18
|
-
ParseTreeWalker.DEFAULT.walk(definition.getListener(), tree);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
abstract class WalkerDefinition {
|
|
23
|
-
Lexer getLexer(InputStream input);
|
|
24
|
-
|
|
25
|
-
ParserRuleContext initializeTree(TokenStream stream);
|
|
26
|
-
|
|
27
|
-
ParseTreeListener getListener();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
class ApexWalkerDefinition extends WalkerDefinition {
|
|
31
|
-
final ApexClassListener _listener;
|
|
32
|
-
|
|
33
|
-
ApexWalkerDefinition() : _listener = ApexClassListener();
|
|
34
|
-
|
|
35
|
-
@override
|
|
36
|
-
Lexer getLexer(InputStream input) {
|
|
37
|
-
return ApexLexer(input);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@override
|
|
41
|
-
ParserRuleContext initializeTree(TokenStream stream) {
|
|
42
|
-
final parser = ApexParser(stream);
|
|
43
|
-
parser.buildParseTree = true;
|
|
44
|
-
return parser.compilationUnit();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@override
|
|
48
|
-
ParseTreeListener getListener() {
|
|
49
|
-
return _listener;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
Type? getGeneratedApexType() {
|
|
53
|
-
return _listener.generatedType;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
class ApexdocWalkerDefinition extends WalkerDefinition {
|
|
58
|
-
final ApexdocListener _listener;
|
|
59
|
-
|
|
60
|
-
ApexdocWalkerDefinition() : _listener = ApexdocListener();
|
|
61
|
-
|
|
62
|
-
@override
|
|
63
|
-
Lexer getLexer(InputStream input) {
|
|
64
|
-
return ApexdocLexer(input);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
@override
|
|
68
|
-
ParserRuleContext initializeTree(TokenStream stream) {
|
|
69
|
-
final parser = ApexdocParser(stream);
|
|
70
|
-
parser.buildParseTree = true;
|
|
71
|
-
return parser.documentation();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
@override
|
|
75
|
-
ParseTreeListener getListener() {
|
|
76
|
-
return _listener;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
DocComment getGeneratedDocComment() {
|
|
80
|
-
return _listener.generatedDocComment;
|
|
81
|
-
}
|
|
82
|
-
}
|
package/pubspec.yaml
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
name: apexdocs_dart
|
|
2
|
-
description: A starting point for Dart libraries or applications.
|
|
3
|
-
version: 1.0.0
|
|
4
|
-
publish_to: none
|
|
5
|
-
|
|
6
|
-
environment:
|
|
7
|
-
sdk: '>=2.14.1 <3.0.0'
|
|
8
|
-
|
|
9
|
-
dev_dependencies:
|
|
10
|
-
lints: ^1.0.0
|
|
11
|
-
test: ^1.16.5
|
|
12
|
-
js: ^0.6.3
|
|
13
|
-
build_runner: ^1.11.5
|
|
14
|
-
json_serializable: ^4.0.2
|
|
15
|
-
grinder: ^0.9.0
|
|
16
|
-
dependencies:
|
|
17
|
-
antlr4:
|
|
18
|
-
path: antlr4-4.9.2
|
|
19
|
-
json_annotation: ^4.0.1
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import 'dart:convert';
|
|
2
|
-
|
|
3
|
-
import 'package:apexdocs_dart/src/model/apex_file_manifest.dart';
|
|
4
|
-
import 'package:apexdocs_dart/src/model/types.dart';
|
|
5
|
-
import 'package:apexdocs_dart/src/service/parsers.dart';
|
|
6
|
-
import 'package:test/test.dart';
|
|
7
|
-
|
|
8
|
-
main() {
|
|
9
|
-
test('Can serialize and deserialize from object', () {
|
|
10
|
-
var classModel = ClassModel(name: 'ClassName');
|
|
11
|
-
var manifest = ApexFileManifest([classModel]);
|
|
12
|
-
final manifestAsJson = jsonEncode(manifest);
|
|
13
|
-
var decodedManifest = ApexFileManifest.fromJson(jsonDecode(manifestAsJson));
|
|
14
|
-
expect(decodedManifest.generatedTypes.length, equals(1));
|
|
15
|
-
});
|
|
16
|
-
}
|