source: imaps-frontend/node_modules/@babel/generator/lib/generators/flow.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 6 months ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 16.3 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.AnyTypeAnnotation = AnyTypeAnnotation;
7exports.ArrayTypeAnnotation = ArrayTypeAnnotation;
8exports.BooleanLiteralTypeAnnotation = BooleanLiteralTypeAnnotation;
9exports.BooleanTypeAnnotation = BooleanTypeAnnotation;
10exports.DeclareClass = DeclareClass;
11exports.DeclareExportAllDeclaration = DeclareExportAllDeclaration;
12exports.DeclareExportDeclaration = DeclareExportDeclaration;
13exports.DeclareFunction = DeclareFunction;
14exports.DeclareInterface = DeclareInterface;
15exports.DeclareModule = DeclareModule;
16exports.DeclareModuleExports = DeclareModuleExports;
17exports.DeclareOpaqueType = DeclareOpaqueType;
18exports.DeclareTypeAlias = DeclareTypeAlias;
19exports.DeclareVariable = DeclareVariable;
20exports.DeclaredPredicate = DeclaredPredicate;
21exports.EmptyTypeAnnotation = EmptyTypeAnnotation;
22exports.EnumBooleanBody = EnumBooleanBody;
23exports.EnumBooleanMember = EnumBooleanMember;
24exports.EnumDeclaration = EnumDeclaration;
25exports.EnumDefaultedMember = EnumDefaultedMember;
26exports.EnumNumberBody = EnumNumberBody;
27exports.EnumNumberMember = EnumNumberMember;
28exports.EnumStringBody = EnumStringBody;
29exports.EnumStringMember = EnumStringMember;
30exports.EnumSymbolBody = EnumSymbolBody;
31exports.ExistsTypeAnnotation = ExistsTypeAnnotation;
32exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
33exports.FunctionTypeParam = FunctionTypeParam;
34exports.IndexedAccessType = IndexedAccessType;
35exports.InferredPredicate = InferredPredicate;
36exports.InterfaceDeclaration = InterfaceDeclaration;
37exports.GenericTypeAnnotation = exports.ClassImplements = exports.InterfaceExtends = InterfaceExtends;
38exports.InterfaceTypeAnnotation = InterfaceTypeAnnotation;
39exports.IntersectionTypeAnnotation = IntersectionTypeAnnotation;
40exports.MixedTypeAnnotation = MixedTypeAnnotation;
41exports.NullLiteralTypeAnnotation = NullLiteralTypeAnnotation;
42exports.NullableTypeAnnotation = NullableTypeAnnotation;
43Object.defineProperty(exports, "NumberLiteralTypeAnnotation", {
44 enumerable: true,
45 get: function () {
46 return _types2.NumericLiteral;
47 }
48});
49exports.NumberTypeAnnotation = NumberTypeAnnotation;
50exports.ObjectTypeAnnotation = ObjectTypeAnnotation;
51exports.ObjectTypeCallProperty = ObjectTypeCallProperty;
52exports.ObjectTypeIndexer = ObjectTypeIndexer;
53exports.ObjectTypeInternalSlot = ObjectTypeInternalSlot;
54exports.ObjectTypeProperty = ObjectTypeProperty;
55exports.ObjectTypeSpreadProperty = ObjectTypeSpreadProperty;
56exports.OpaqueType = OpaqueType;
57exports.OptionalIndexedAccessType = OptionalIndexedAccessType;
58exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier;
59Object.defineProperty(exports, "StringLiteralTypeAnnotation", {
60 enumerable: true,
61 get: function () {
62 return _types2.StringLiteral;
63 }
64});
65exports.StringTypeAnnotation = StringTypeAnnotation;
66exports.SymbolTypeAnnotation = SymbolTypeAnnotation;
67exports.ThisTypeAnnotation = ThisTypeAnnotation;
68exports.TupleTypeAnnotation = TupleTypeAnnotation;
69exports.TypeAlias = TypeAlias;
70exports.TypeAnnotation = TypeAnnotation;
71exports.TypeCastExpression = TypeCastExpression;
72exports.TypeParameter = TypeParameter;
73exports.TypeParameterDeclaration = exports.TypeParameterInstantiation = TypeParameterInstantiation;
74exports.TypeofTypeAnnotation = TypeofTypeAnnotation;
75exports.UnionTypeAnnotation = UnionTypeAnnotation;
76exports.Variance = Variance;
77exports.VoidTypeAnnotation = VoidTypeAnnotation;
78exports._interfaceish = _interfaceish;
79exports._variance = _variance;
80var _t = require("@babel/types");
81var _modules = require("./modules.js");
82var _index = require("../node/index.js");
83var _types2 = require("./types.js");
84const {
85 isDeclareExportDeclaration,
86 isStatement
87} = _t;
88function AnyTypeAnnotation() {
89 this.word("any");
90}
91function ArrayTypeAnnotation(node) {
92 this.print(node.elementType, true);
93 this.tokenChar(91);
94 this.tokenChar(93);
95}
96function BooleanTypeAnnotation() {
97 this.word("boolean");
98}
99function BooleanLiteralTypeAnnotation(node) {
100 this.word(node.value ? "true" : "false");
101}
102function NullLiteralTypeAnnotation() {
103 this.word("null");
104}
105function DeclareClass(node, parent) {
106 if (!isDeclareExportDeclaration(parent)) {
107 this.word("declare");
108 this.space();
109 }
110 this.word("class");
111 this.space();
112 this._interfaceish(node);
113}
114function DeclareFunction(node, parent) {
115 if (!isDeclareExportDeclaration(parent)) {
116 this.word("declare");
117 this.space();
118 }
119 this.word("function");
120 this.space();
121 this.print(node.id);
122 this.print(node.id.typeAnnotation.typeAnnotation);
123 if (node.predicate) {
124 this.space();
125 this.print(node.predicate);
126 }
127 this.semicolon();
128}
129function InferredPredicate() {
130 this.tokenChar(37);
131 this.word("checks");
132}
133function DeclaredPredicate(node) {
134 this.tokenChar(37);
135 this.word("checks");
136 this.tokenChar(40);
137 this.print(node.value);
138 this.tokenChar(41);
139}
140function DeclareInterface(node) {
141 this.word("declare");
142 this.space();
143 this.InterfaceDeclaration(node);
144}
145function DeclareModule(node) {
146 this.word("declare");
147 this.space();
148 this.word("module");
149 this.space();
150 this.print(node.id);
151 this.space();
152 this.print(node.body);
153}
154function DeclareModuleExports(node) {
155 this.word("declare");
156 this.space();
157 this.word("module");
158 this.tokenChar(46);
159 this.word("exports");
160 this.print(node.typeAnnotation);
161}
162function DeclareTypeAlias(node) {
163 this.word("declare");
164 this.space();
165 this.TypeAlias(node);
166}
167function DeclareOpaqueType(node, parent) {
168 if (!isDeclareExportDeclaration(parent)) {
169 this.word("declare");
170 this.space();
171 }
172 this.OpaqueType(node);
173}
174function DeclareVariable(node, parent) {
175 if (!isDeclareExportDeclaration(parent)) {
176 this.word("declare");
177 this.space();
178 }
179 this.word("var");
180 this.space();
181 this.print(node.id);
182 this.print(node.id.typeAnnotation);
183 this.semicolon();
184}
185function DeclareExportDeclaration(node) {
186 this.word("declare");
187 this.space();
188 this.word("export");
189 this.space();
190 if (node.default) {
191 this.word("default");
192 this.space();
193 }
194 FlowExportDeclaration.call(this, node);
195}
196function DeclareExportAllDeclaration(node) {
197 this.word("declare");
198 this.space();
199 _modules.ExportAllDeclaration.call(this, node);
200}
201function EnumDeclaration(node) {
202 const {
203 id,
204 body
205 } = node;
206 this.word("enum");
207 this.space();
208 this.print(id);
209 this.print(body);
210}
211function enumExplicitType(context, name, hasExplicitType) {
212 if (hasExplicitType) {
213 context.space();
214 context.word("of");
215 context.space();
216 context.word(name);
217 }
218 context.space();
219}
220function enumBody(context, node) {
221 const {
222 members
223 } = node;
224 context.token("{");
225 context.indent();
226 context.newline();
227 for (const member of members) {
228 context.print(member);
229 context.newline();
230 }
231 if (node.hasUnknownMembers) {
232 context.token("...");
233 context.newline();
234 }
235 context.dedent();
236 context.token("}");
237}
238function EnumBooleanBody(node) {
239 const {
240 explicitType
241 } = node;
242 enumExplicitType(this, "boolean", explicitType);
243 enumBody(this, node);
244}
245function EnumNumberBody(node) {
246 const {
247 explicitType
248 } = node;
249 enumExplicitType(this, "number", explicitType);
250 enumBody(this, node);
251}
252function EnumStringBody(node) {
253 const {
254 explicitType
255 } = node;
256 enumExplicitType(this, "string", explicitType);
257 enumBody(this, node);
258}
259function EnumSymbolBody(node) {
260 enumExplicitType(this, "symbol", true);
261 enumBody(this, node);
262}
263function EnumDefaultedMember(node) {
264 const {
265 id
266 } = node;
267 this.print(id);
268 this.tokenChar(44);
269}
270function enumInitializedMember(context, node) {
271 context.print(node.id);
272 context.space();
273 context.token("=");
274 context.space();
275 context.print(node.init);
276 context.token(",");
277}
278function EnumBooleanMember(node) {
279 enumInitializedMember(this, node);
280}
281function EnumNumberMember(node) {
282 enumInitializedMember(this, node);
283}
284function EnumStringMember(node) {
285 enumInitializedMember(this, node);
286}
287function FlowExportDeclaration(node) {
288 if (node.declaration) {
289 const declar = node.declaration;
290 this.print(declar);
291 if (!isStatement(declar)) this.semicolon();
292 } else {
293 this.tokenChar(123);
294 if (node.specifiers.length) {
295 this.space();
296 this.printList(node.specifiers);
297 this.space();
298 }
299 this.tokenChar(125);
300 if (node.source) {
301 this.space();
302 this.word("from");
303 this.space();
304 this.print(node.source);
305 }
306 this.semicolon();
307 }
308}
309function ExistsTypeAnnotation() {
310 this.tokenChar(42);
311}
312function FunctionTypeAnnotation(node, parent) {
313 this.print(node.typeParameters);
314 this.tokenChar(40);
315 if (node.this) {
316 this.word("this");
317 this.tokenChar(58);
318 this.space();
319 this.print(node.this.typeAnnotation);
320 if (node.params.length || node.rest) {
321 this.tokenChar(44);
322 this.space();
323 }
324 }
325 this.printList(node.params);
326 if (node.rest) {
327 if (node.params.length) {
328 this.tokenChar(44);
329 this.space();
330 }
331 this.token("...");
332 this.print(node.rest);
333 }
334 this.tokenChar(41);
335 const type = parent == null ? void 0 : parent.type;
336 if (type != null && (type === "ObjectTypeCallProperty" || type === "ObjectTypeInternalSlot" || type === "DeclareFunction" || type === "ObjectTypeProperty" && parent.method)) {
337 this.tokenChar(58);
338 } else {
339 this.space();
340 this.token("=>");
341 }
342 this.space();
343 this.print(node.returnType);
344}
345function FunctionTypeParam(node) {
346 this.print(node.name);
347 if (node.optional) this.tokenChar(63);
348 if (node.name) {
349 this.tokenChar(58);
350 this.space();
351 }
352 this.print(node.typeAnnotation);
353}
354function InterfaceExtends(node) {
355 this.print(node.id);
356 this.print(node.typeParameters, true);
357}
358function _interfaceish(node) {
359 var _node$extends;
360 this.print(node.id);
361 this.print(node.typeParameters);
362 if ((_node$extends = node.extends) != null && _node$extends.length) {
363 this.space();
364 this.word("extends");
365 this.space();
366 this.printList(node.extends);
367 }
368 if (node.type === "DeclareClass") {
369 var _node$mixins, _node$implements;
370 if ((_node$mixins = node.mixins) != null && _node$mixins.length) {
371 this.space();
372 this.word("mixins");
373 this.space();
374 this.printList(node.mixins);
375 }
376 if ((_node$implements = node.implements) != null && _node$implements.length) {
377 this.space();
378 this.word("implements");
379 this.space();
380 this.printList(node.implements);
381 }
382 }
383 this.space();
384 this.print(node.body);
385}
386function _variance(node) {
387 var _node$variance;
388 const kind = (_node$variance = node.variance) == null ? void 0 : _node$variance.kind;
389 if (kind != null) {
390 if (kind === "plus") {
391 this.tokenChar(43);
392 } else if (kind === "minus") {
393 this.tokenChar(45);
394 }
395 }
396}
397function InterfaceDeclaration(node) {
398 this.word("interface");
399 this.space();
400 this._interfaceish(node);
401}
402function andSeparator(occurrenceCount) {
403 this.space();
404 this.token("&", false, occurrenceCount);
405 this.space();
406}
407function InterfaceTypeAnnotation(node) {
408 var _node$extends2;
409 this.word("interface");
410 if ((_node$extends2 = node.extends) != null && _node$extends2.length) {
411 this.space();
412 this.word("extends");
413 this.space();
414 this.printList(node.extends);
415 }
416 this.space();
417 this.print(node.body);
418}
419function IntersectionTypeAnnotation(node) {
420 this.printJoin(node.types, undefined, undefined, andSeparator);
421}
422function MixedTypeAnnotation() {
423 this.word("mixed");
424}
425function EmptyTypeAnnotation() {
426 this.word("empty");
427}
428function NullableTypeAnnotation(node) {
429 this.tokenChar(63);
430 this.print(node.typeAnnotation);
431}
432function NumberTypeAnnotation() {
433 this.word("number");
434}
435function StringTypeAnnotation() {
436 this.word("string");
437}
438function ThisTypeAnnotation() {
439 this.word("this");
440}
441function TupleTypeAnnotation(node) {
442 this.tokenChar(91);
443 this.printList(node.types);
444 this.tokenChar(93);
445}
446function TypeofTypeAnnotation(node) {
447 this.word("typeof");
448 this.space();
449 this.print(node.argument);
450}
451function TypeAlias(node) {
452 this.word("type");
453 this.space();
454 this.print(node.id);
455 this.print(node.typeParameters);
456 this.space();
457 this.tokenChar(61);
458 this.space();
459 this.print(node.right);
460 this.semicolon();
461}
462function TypeAnnotation(node, parent) {
463 this.tokenChar(58);
464 this.space();
465 if (parent.type === "ArrowFunctionExpression") {
466 this.tokenContext |= _index.TokenContext.arrowFlowReturnType;
467 } else if (node.optional) {
468 this.tokenChar(63);
469 }
470 this.print(node.typeAnnotation);
471}
472function TypeParameterInstantiation(node) {
473 this.tokenChar(60);
474 this.printList(node.params);
475 this.tokenChar(62);
476}
477function TypeParameter(node) {
478 this._variance(node);
479 this.word(node.name);
480 if (node.bound) {
481 this.print(node.bound);
482 }
483 if (node.default) {
484 this.space();
485 this.tokenChar(61);
486 this.space();
487 this.print(node.default);
488 }
489}
490function OpaqueType(node) {
491 this.word("opaque");
492 this.space();
493 this.word("type");
494 this.space();
495 this.print(node.id);
496 this.print(node.typeParameters);
497 if (node.supertype) {
498 this.tokenChar(58);
499 this.space();
500 this.print(node.supertype);
501 }
502 if (node.impltype) {
503 this.space();
504 this.tokenChar(61);
505 this.space();
506 this.print(node.impltype);
507 }
508 this.semicolon();
509}
510function ObjectTypeAnnotation(node) {
511 if (node.exact) {
512 this.token("{|");
513 } else {
514 this.tokenChar(123);
515 }
516 const props = [...node.properties, ...(node.callProperties || []), ...(node.indexers || []), ...(node.internalSlots || [])];
517 if (props.length) {
518 this.newline();
519 this.space();
520 this.printJoin(props, true, true, undefined, undefined, function addNewlines(leading) {
521 if (leading && !props[0]) return 1;
522 }, () => {
523 if (props.length !== 1 || node.inexact) {
524 this.tokenChar(44);
525 this.space();
526 }
527 });
528 this.space();
529 }
530 if (node.inexact) {
531 this.indent();
532 this.token("...");
533 if (props.length) {
534 this.newline();
535 }
536 this.dedent();
537 }
538 if (node.exact) {
539 this.token("|}");
540 } else {
541 this.tokenChar(125);
542 }
543}
544function ObjectTypeInternalSlot(node) {
545 if (node.static) {
546 this.word("static");
547 this.space();
548 }
549 this.tokenChar(91);
550 this.tokenChar(91);
551 this.print(node.id);
552 this.tokenChar(93);
553 this.tokenChar(93);
554 if (node.optional) this.tokenChar(63);
555 if (!node.method) {
556 this.tokenChar(58);
557 this.space();
558 }
559 this.print(node.value);
560}
561function ObjectTypeCallProperty(node) {
562 if (node.static) {
563 this.word("static");
564 this.space();
565 }
566 this.print(node.value);
567}
568function ObjectTypeIndexer(node) {
569 if (node.static) {
570 this.word("static");
571 this.space();
572 }
573 this._variance(node);
574 this.tokenChar(91);
575 if (node.id) {
576 this.print(node.id);
577 this.tokenChar(58);
578 this.space();
579 }
580 this.print(node.key);
581 this.tokenChar(93);
582 this.tokenChar(58);
583 this.space();
584 this.print(node.value);
585}
586function ObjectTypeProperty(node) {
587 if (node.proto) {
588 this.word("proto");
589 this.space();
590 }
591 if (node.static) {
592 this.word("static");
593 this.space();
594 }
595 if (node.kind === "get" || node.kind === "set") {
596 this.word(node.kind);
597 this.space();
598 }
599 this._variance(node);
600 this.print(node.key);
601 if (node.optional) this.tokenChar(63);
602 if (!node.method) {
603 this.tokenChar(58);
604 this.space();
605 }
606 this.print(node.value);
607}
608function ObjectTypeSpreadProperty(node) {
609 this.token("...");
610 this.print(node.argument);
611}
612function QualifiedTypeIdentifier(node) {
613 this.print(node.qualification);
614 this.tokenChar(46);
615 this.print(node.id);
616}
617function SymbolTypeAnnotation() {
618 this.word("symbol");
619}
620function orSeparator(occurrenceCount) {
621 this.space();
622 this.token("|", false, occurrenceCount);
623 this.space();
624}
625function UnionTypeAnnotation(node) {
626 this.printJoin(node.types, undefined, undefined, orSeparator);
627}
628function TypeCastExpression(node) {
629 this.tokenChar(40);
630 this.print(node.expression);
631 this.print(node.typeAnnotation);
632 this.tokenChar(41);
633}
634function Variance(node) {
635 if (node.kind === "plus") {
636 this.tokenChar(43);
637 } else {
638 this.tokenChar(45);
639 }
640}
641function VoidTypeAnnotation() {
642 this.word("void");
643}
644function IndexedAccessType(node) {
645 this.print(node.objectType, true);
646 this.tokenChar(91);
647 this.print(node.indexType);
648 this.tokenChar(93);
649}
650function OptionalIndexedAccessType(node) {
651 this.print(node.objectType);
652 if (node.optional) {
653 this.token("?.");
654 }
655 this.tokenChar(91);
656 this.print(node.indexType);
657 this.tokenChar(93);
658}
659
660//# sourceMappingURL=flow.js.map
Note: See TracBrowser for help on using the repository browser.