@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,431 +0,0 @@
1
- /*
2
- * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
3
- * Use of this file is governed by the BSD 3-clause license that
4
- * can be found in the LICENSE.txt file in the project root.
5
- */
6
-
7
- import 'input_stream.dart';
8
- import 'interval_set.dart';
9
- import 'misc/pair.dart';
10
- import 'recognizer.dart';
11
- import 'token_source.dart';
12
-
13
- /// A token has properties: text, type, line, character position in the line
14
- /// (so we can ignore tabs), token channel, index, and source from which
15
- /// we obtained this token.
16
- abstract class Token {
17
- static const int INVALID_TYPE = 0;
18
-
19
- /// During lookahead operations, this "token" signifies we hit rule end ATN state
20
- /// and did not follow it despite needing to.
21
- static const int EPSILON = -2;
22
-
23
- static const int MIN_USER_TOKEN_TYPE = 1;
24
-
25
- static const int EOF = IntStream.EOF;
26
-
27
- /// All tokens go to the parser (unless skip() is called in that rule)
28
- /// on a particular "channel". The parser tunes to a particular channel
29
- /// so that whitespace etc... can go to the parser on a "hidden" channel.
30
- static const int DEFAULT_CHANNEL = 0;
31
-
32
- /// Anything on different channel than DEFAULT_CHANNEL is not parsed
33
- /// by parser.
34
- static const int HIDDEN_CHANNEL = 1;
35
-
36
- /// This is the minimum constant value which can be assigned to a
37
- /// user-defined token channel.
38
- ///
39
- /// <p>
40
- /// The non-negative numbers less than {@link #MIN_USER_CHANNEL_VALUE} are
41
- /// assigned to the predefined channels {@link #DEFAULT_CHANNEL} and
42
- /// {@link #HIDDEN_CHANNEL}.</p>
43
- ///
44
- /// @see Token#getChannel()
45
- static const int MIN_USER_CHANNEL_VALUE = 2;
46
-
47
- /// Get the text of the token.
48
- String get text;
49
-
50
- /// Get the token type of the token */
51
- int get type;
52
-
53
- /// The line number on which the 1st character of this token was matched,
54
- /// line=1..n
55
- int get line;
56
-
57
- /// The index of the first character of this token relative to the
58
- /// beginning of the line at which it occurs, 0..n-1
59
- int get charPositionInLine;
60
-
61
- /// Return the channel this token. Each token can arrive at the parser
62
- /// on a different channel, but the parser only "tunes" to a single channel.
63
- /// The parser ignores everything not on DEFAULT_CHANNEL.
64
- int get channel;
65
-
66
- /// An index from 0..n-1 of the token object in the input stream.
67
- /// This must be valid in order to print token streams and
68
- /// use TokenRewriteStream.
69
- ///
70
- /// Return -1 to indicate that this token was conjured up since
71
- /// it doesn't have a valid index.
72
- int get tokenIndex;
73
-
74
- /// The starting character index of the token
75
- /// This method is optional; return -1 if not implemented.
76
- int get startIndex;
77
-
78
- /// The last character index of the token.
79
- /// This method is optional; return -1 if not implemented.
80
- int get stopIndex;
81
-
82
- /// Gets the [TokenSource] which created this token.
83
- TokenSource get tokenSource;
84
-
85
- /// Gets the [CharStream] from which this token was derived.
86
- CharStream get inputStream;
87
- }
88
-
89
- abstract class WritableToken extends Token {
90
- set text(String text);
91
-
92
- set type(int ttype);
93
-
94
- set line(int line);
95
-
96
- set charPositionInLine(int pos);
97
-
98
- set channel(int channel);
99
-
100
- set tokenIndex(int index);
101
- }
102
-
103
- class CommonToken extends WritableToken {
104
- /// An empty [Pair] which is used as the default value of
105
- /// {@link #source} for tokens that do not have a source.
106
- static const Pair<TokenSource, CharStream> EMPTY_SOURCE =
107
- Pair<TokenSource, CharStream>(null, null);
108
-
109
- @override
110
- int type;
111
-
112
- @override
113
- int line;
114
-
115
- @override
116
- int charPositionInLine = -1; // set to invalid position
117
-
118
- @override
119
- int channel = Token.DEFAULT_CHANNEL;
120
-
121
- /// These properties share a field to reduce the memory footprint of
122
- /// [CommonToken]. Tokens created by a [CommonTokenFactory] from
123
- /// the same source and input stream share a reference to the same
124
- /// [Pair] containing these values.</p>
125
- Pair<TokenSource, CharStream> source;
126
-
127
- /// This is the backing field for {@link #getText} when the token text is
128
- /// explicitly set in the constructor or via {@link #setText}.
129
- ///
130
- /// @see #getText()
131
- String _text;
132
-
133
- @override
134
- int tokenIndex = -1;
135
-
136
- @override
137
- int startIndex;
138
-
139
- @override
140
- int stopIndex;
141
-
142
- /// Constructs a new [CommonToken] with the specified token type and
143
- /// text.
144
- ///
145
- /// @param type The token type.
146
- /// @param text The text of the token.
147
- CommonToken(this.type,
148
- {this.source = EMPTY_SOURCE,
149
- this.channel = Token.DEFAULT_CHANNEL,
150
- this.startIndex,
151
- this.stopIndex,
152
- text}) {
153
- _text = text;
154
- if (source.a != null) {
155
- line = source.a.line;
156
- charPositionInLine = source.a.charPositionInLine;
157
- }
158
- }
159
-
160
- /// Constructs a new [CommonToken] as a copy of another [Token].
161
- ///
162
- /// <p>
163
- /// If [oldToken] is also a [CommonToken] instance, the newly
164
- /// constructed token will share a reference to the {@link #text} field and
165
- /// the [Pair] stored in {@link #source}. Otherwise, {@link #text} will
166
- /// be assigned the result of calling {@link #getText}, and {@link #source}
167
- /// will be constructed from the result of {@link Token#getTokenSource} and
168
- /// {@link Token#getInputStream}.</p>
169
- ///
170
- /// @param oldToken The token to copy.
171
- CommonToken.copy(Token oldToken) {
172
- type = oldToken.type;
173
- line = oldToken.line;
174
- tokenIndex = oldToken.tokenIndex;
175
- charPositionInLine = oldToken.charPositionInLine;
176
- channel = oldToken.channel;
177
- startIndex = oldToken.startIndex;
178
- stopIndex = oldToken.stopIndex;
179
-
180
- if (oldToken is CommonToken) {
181
- _text = oldToken.text;
182
- source = oldToken.source;
183
- } else {
184
- _text = oldToken.text;
185
- source = Pair<TokenSource, CharStream>(
186
- oldToken.tokenSource, oldToken.inputStream);
187
- }
188
- }
189
-
190
- @override
191
- String get text {
192
- if (_text != null) {
193
- return _text;
194
- }
195
-
196
- final input = inputStream;
197
- if (input == null) return null;
198
- final n = input.size;
199
- if (startIndex < n && stopIndex < n) {
200
- return input.getText(Interval.of(startIndex, stopIndex));
201
- } else {
202
- return '<EOF>';
203
- }
204
- }
205
-
206
- /// Explicitly set the text for this token. If {code text} is not
207
- /// null, then {@link #getText} will return this value rather than
208
- /// extracting the text from the input.
209
- ///
210
- /// @param text The explicit text of the token, or null if the text
211
- /// should be obtained from the input along with the start and stop indexes
212
- /// of the token.
213
- @override
214
- set text(String text) {
215
- _text = text;
216
- }
217
-
218
- @override
219
- TokenSource get tokenSource {
220
- return source.a;
221
- }
222
-
223
- @override
224
- CharStream get inputStream {
225
- return source.b;
226
- }
227
-
228
- @override
229
- String toString([Recognizer r]) {
230
- var txt = text;
231
- if (txt != null) {
232
- txt = txt
233
- .replaceAll('\n', r'\n')
234
- .replaceAll('\r', r'\r')
235
- .replaceAll('\t', r'\t');
236
- } else {
237
- txt = '<no text>';
238
- }
239
- return "[@$tokenIndex,$startIndex:$stopIndex='$txt',<$type>" +
240
- (channel > 0 ? ',channel=$channel' : '') +
241
- ',$line:$charPositionInLine]';
242
- }
243
- }
244
-
245
- /// A [Token] object representing an entire subtree matched by a parser
246
- /// rule; e.g., {@code <expr>}. These tokens are created for [TagChunk]
247
- /// chunks where the tag corresponds to a parser rule.
248
- class RuleTagToken implements Token {
249
- /// Gets the name of the rule associated with this rule tag.
250
- ///
251
- /// @return The name of the parser rule associated with this rule tag.
252
- final String ruleName;
253
-
254
- /// The token type for the current token. This is the token type assigned to
255
- /// the bypass alternative for the rule during ATN deserialization.
256
- final int bypassTokenType;
257
-
258
- /// Gets the label associated with the rule tag.
259
- ///
260
- /// @return The name of the label associated with the rule tag, or
261
- /// null if this is an unlabeled rule tag.
262
- final String label;
263
-
264
- /// Constructs a new instance of [RuleTagToken] with the specified rule
265
- /// name, bypass token type, and label.
266
- ///
267
- /// @param ruleName The name of the parser rule this rule tag matches.
268
- /// @param bypassTokenType The bypass token type assigned to the parser rule.
269
- /// @param label The label associated with the rule tag, or null if
270
- /// the rule tag is unlabeled.
271
- ///
272
- /// @exception ArgumentError.value(value) if [ruleName] is null
273
- /// or empty.
274
- RuleTagToken(this.ruleName, this.bypassTokenType, [this.label]) {
275
- if (ruleName == null || ruleName.isEmpty) {
276
- throw ArgumentError.value(
277
- ruleName, 'ruleName', 'cannot be null or empty.');
278
- }
279
- }
280
-
281
- /// {@inheritDoc}
282
- ///
283
- /// <p>Rule tag tokens are always placed on the {@link #DEFAULT_CHANNEL}.</p>
284
-
285
- @override
286
- int get channel {
287
- return Token.DEFAULT_CHANNEL;
288
- }
289
-
290
- /// {@inheritDoc}
291
- ///
292
- /// <p>This method returns the rule tag formatted with {@code <} and {@code >}
293
- /// delimiters.</p>
294
-
295
- @override
296
- String get text {
297
- if (label != null) {
298
- return '<' + label + ':' + ruleName + '>';
299
- }
300
-
301
- return '<' + ruleName + '>';
302
- }
303
-
304
- /// {@inheritDoc}
305
- ///
306
- /// <p>Rule tag tokens have types assigned according to the rule bypass
307
- /// transitions created during ATN deserialization.</p>
308
-
309
- @override
310
- int get type {
311
- return bypassTokenType;
312
- }
313
-
314
- /// {@inheritDoc}
315
- ///
316
- /// <p>The implementation for [RuleTagToken] always returns 0.</p>
317
-
318
- @override
319
- int get line {
320
- return 0;
321
- }
322
-
323
- /// {@inheritDoc}
324
- ///
325
- /// <p>The implementation for [RuleTagToken] always returns -1.</p>
326
- @override
327
- int get charPositionInLine {
328
- return -1;
329
- }
330
-
331
- /// {@inheritDoc}
332
- ///
333
- /// <p>The implementation for [RuleTagToken] always returns -1.</p>
334
- @override
335
- int get tokenIndex {
336
- return -1;
337
- }
338
-
339
- /// {@inheritDoc}
340
- ///
341
- /// <p>The implementation for [RuleTagToken] always returns -1.</p>
342
- @override
343
- int get startIndex {
344
- return -1;
345
- }
346
-
347
- /// {@inheritDoc}
348
- ///
349
- /// <p>The implementation for [RuleTagToken] always returns -1.</p>
350
-
351
- @override
352
- int get stopIndex {
353
- return -1;
354
- }
355
-
356
- /// {@inheritDoc}
357
- ///
358
- /// <p>The implementation for [RuleTagToken] always returns null.</p>
359
-
360
- @override
361
- TokenSource get tokenSource {
362
- return null;
363
- }
364
-
365
- /// {@inheritDoc}
366
- ///
367
- /// <p>The implementation for [RuleTagToken] always returns null.</p>
368
-
369
- @override
370
- CharStream get inputStream {
371
- return null;
372
- }
373
-
374
- /// {@inheritDoc}
375
- ///
376
- /// <p>The implementation for [RuleTagToken] returns a string of the form
377
- /// {@code ruleName:bypassTokenType}.</p>
378
-
379
- @override
380
- String toString() {
381
- return ruleName + ':$bypassTokenType';
382
- }
383
- }
384
-
385
- /// A [Token] object representing a token of a particular type; e.g.,
386
- /// {@code <ID>}. These tokens are created for [TagChunk] chunks where the
387
- /// tag corresponds to a lexer rule or token type.
388
- class TokenTagToken extends CommonToken {
389
- /// Gets the token name.
390
- /// @return The token name.
391
- final String tokenName;
392
-
393
- /// Gets the label associated with the rule tag.
394
- ///
395
- /// @return The name of the label associated with the rule tag, or
396
- /// null if this is an unlabeled rule tag.
397
- final String label;
398
-
399
- /// Constructs a new instance of [TokenTagToken] with the specified
400
- /// token name, type, and label.
401
- ///
402
- /// @param tokenName The token name.
403
- /// @param type The token type.
404
- /// @param label The label associated with the token tag, or null if
405
- /// the token tag is unlabeled.
406
- TokenTagToken(this.tokenName, type, [this.label]) : super(type);
407
-
408
- /// {@inheritDoc}
409
- ///
410
- /// <p>The implementation for [TokenTagToken] returns the token tag
411
- /// formatted with {@code <} and {@code >} delimiters.</p>
412
-
413
- @override
414
- String get text {
415
- if (label != null) {
416
- return '<' + label + ':' + tokenName + '>';
417
- }
418
-
419
- return '<' + tokenName + '>';
420
- }
421
-
422
- /// {@inheritDoc}
423
- ///
424
- /// <p>The implementation for [TokenTagToken] returns a string of the form
425
- /// {@code tokenName:type}.</p>
426
-
427
- @override
428
- String toString([recognizer]) {
429
- return tokenName + ':$type';
430
- }
431
- }
@@ -1,88 +0,0 @@
1
- /*
2
- * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
3
- * Use of this file is governed by the BSD 3-clause license that
4
- * can be found in the LICENSE.txt file in the project root.
5
- */
6
-
7
- import 'input_stream.dart';
8
- import 'interval_set.dart';
9
- import 'misc/pair.dart';
10
- import 'token.dart';
11
- import 'token_source.dart';
12
-
13
- /// The default mechanism for creating tokens. It's used by default in Lexer and
14
- /// the error handling strategy (to create missing tokens). Notifying the parser
15
- /// of a new factory means that it notifies its token source and error strategy.
16
- abstract class TokenFactory<Symbol extends Token> {
17
- /// This is the method used to create tokens in the lexer and in the
18
- /// error handling strategy. If text!=null, than the start and stop positions
19
- /// are wiped to -1 in the text override is set in the CommonToken.
20
- Symbol create(int type, String text,
21
- [Pair<TokenSource, CharStream> source,
22
- int channel,
23
- int start,
24
- int stop,
25
- int line,
26
- int charPositionInLine]);
27
- }
28
-
29
- /// This default implementation of [TokenFactory] creates
30
- /// [CommonToken] objects.
31
- class CommonTokenFactory implements TokenFactory<CommonToken> {
32
- /// The default [CommonTokenFactory] instance.
33
- ///
34
- /// <p>
35
- /// This token factory does not explicitly copy token text when constructing
36
- /// tokens.</p>
37
- static final TokenFactory<CommonToken> DEFAULT = CommonTokenFactory();
38
-
39
- /// Indicates whether {@link CommonToken#setText} should be called after
40
- /// constructing tokens to explicitly set the text. This is useful for cases
41
- /// where the input stream might not be able to provide arbitrary substrings
42
- /// of text from the input after the lexer creates a token (e.g. the
43
- /// implementation of {@link CharStream#getText} in
44
- /// [UnbufferedCharStream] throws an
45
- /// [UnsupportedOperationException]). Explicitly setting the token text
46
- /// allows {@link Token#getText} to be called at any time regardless of the
47
- /// input stream implementation.
48
- ///
49
- /// <p>
50
- /// The default value is [false] to avoid the performance and memory
51
- /// overhead of copying text for every token unless explicitly requested.</p>
52
- final bool copyText;
53
-
54
- /// Constructs a [CommonTokenFactory] with the specified value for
55
- /// {@link #copyText}.
56
- ///
57
- /// <p>
58
- /// When [copyText] is [false], the {@link #DEFAULT} instance
59
- /// should be used instead of constructing a new instance.</p>
60
- ///
61
- /// @param copyText The value for {@link #copyText}.
62
- CommonTokenFactory([this.copyText = false]);
63
-
64
- @override
65
- CommonToken create(int type, String text,
66
- [Pair<TokenSource, CharStream> source,
67
- int channel,
68
- int start,
69
- int stop,
70
- int line,
71
- int charPositionInLine]) {
72
- if (source == null) {
73
- return CommonToken(type, text: text);
74
- }
75
-
76
- final t = CommonToken(type,
77
- source: source, channel: channel, startIndex: start, stopIndex: stop);
78
- t.line = line;
79
- t.charPositionInLine = charPositionInLine;
80
- if (text != null) {
81
- t.text = text;
82
- } else if (copyText && source.b != null) {
83
- t.text = source.b.getText(Interval.of(start, stop));
84
- }
85
-
86
- return t;
87
- }
88
- }