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

main
Last change on this file was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago

Pred finalna verzija

  • Property mode set to 100644
File size: 16.4 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, {
421 separator: andSeparator
422 });
423}
424function MixedTypeAnnotation() {
425 this.word("mixed");
426}
427function EmptyTypeAnnotation() {
428 this.word("empty");
429}
430function NullableTypeAnnotation(node) {
431 this.tokenChar(63);
432 this.print(node.typeAnnotation);
433}
434function NumberTypeAnnotation() {
435 this.word("number");
436}
437function StringTypeAnnotation() {
438 this.word("string");
439}
440function ThisTypeAnnotation() {
441 this.word("this");
442}
443function TupleTypeAnnotation(node) {
444 this.tokenChar(91);
445 this.printList(node.types);
446 this.tokenChar(93);
447}
448function TypeofTypeAnnotation(node) {
449 this.word("typeof");
450 this.space();
451 this.print(node.argument);
452}
453function TypeAlias(node) {
454 this.word("type");
455 this.space();
456 this.print(node.id);
457 this.print(node.typeParameters);
458 this.space();
459 this.tokenChar(61);
460 this.space();
461 this.print(node.right);
462 this.semicolon();
463}
464function TypeAnnotation(node, parent) {
465 this.tokenChar(58);
466 this.space();
467 if (parent.type === "ArrowFunctionExpression") {
468 this.tokenContext |= _index.TokenContext.arrowFlowReturnType;
469 } else if (node.optional) {
470 this.tokenChar(63);
471 }
472 this.print(node.typeAnnotation);
473}
474function TypeParameterInstantiation(node) {
475 this.tokenChar(60);
476 this.printList(node.params, {});
477 this.tokenChar(62);
478}
479function TypeParameter(node) {
480 this._variance(node);
481 this.word(node.name);
482 if (node.bound) {
483 this.print(node.bound);
484 }
485 if (node.default) {
486 this.space();
487 this.tokenChar(61);
488 this.space();
489 this.print(node.default);
490 }
491}
492function OpaqueType(node) {
493 this.word("opaque");
494 this.space();
495 this.word("type");
496 this.space();
497 this.print(node.id);
498 this.print(node.typeParameters);
499 if (node.supertype) {
500 this.tokenChar(58);
501 this.space();
502 this.print(node.supertype);
503 }
504 if (node.impltype) {
505 this.space();
506 this.tokenChar(61);
507 this.space();
508 this.print(node.impltype);
509 }
510 this.semicolon();
511}
512function ObjectTypeAnnotation(node) {
513 if (node.exact) {
514 this.token("{|");
515 } else {
516 this.tokenChar(123);
517 }
518 const props = [...node.properties, ...(node.callProperties || []), ...(node.indexers || []), ...(node.internalSlots || [])];
519 if (props.length) {
520 this.newline();
521 this.space();
522 this.printJoin(props, {
523 addNewlines(leading) {
524 if (leading && !props[0]) return 1;
525 },
526 indent: true,
527 statement: true,
528 iterator: () => {
529 if (props.length !== 1 || node.inexact) {
530 this.tokenChar(44);
531 this.space();
532 }
533 }
534 });
535 this.space();
536 }
537 if (node.inexact) {
538 this.indent();
539 this.token("...");
540 if (props.length) {
541 this.newline();
542 }
543 this.dedent();
544 }
545 if (node.exact) {
546 this.token("|}");
547 } else {
548 this.tokenChar(125);
549 }
550}
551function ObjectTypeInternalSlot(node) {
552 if (node.static) {
553 this.word("static");
554 this.space();
555 }
556 this.tokenChar(91);
557 this.tokenChar(91);
558 this.print(node.id);
559 this.tokenChar(93);
560 this.tokenChar(93);
561 if (node.optional) this.tokenChar(63);
562 if (!node.method) {
563 this.tokenChar(58);
564 this.space();
565 }
566 this.print(node.value);
567}
568function ObjectTypeCallProperty(node) {
569 if (node.static) {
570 this.word("static");
571 this.space();
572 }
573 this.print(node.value);
574}
575function ObjectTypeIndexer(node) {
576 if (node.static) {
577 this.word("static");
578 this.space();
579 }
580 this._variance(node);
581 this.tokenChar(91);
582 if (node.id) {
583 this.print(node.id);
584 this.tokenChar(58);
585 this.space();
586 }
587 this.print(node.key);
588 this.tokenChar(93);
589 this.tokenChar(58);
590 this.space();
591 this.print(node.value);
592}
593function ObjectTypeProperty(node) {
594 if (node.proto) {
595 this.word("proto");
596 this.space();
597 }
598 if (node.static) {
599 this.word("static");
600 this.space();
601 }
602 if (node.kind === "get" || node.kind === "set") {
603 this.word(node.kind);
604 this.space();
605 }
606 this._variance(node);
607 this.print(node.key);
608 if (node.optional) this.tokenChar(63);
609 if (!node.method) {
610 this.tokenChar(58);
611 this.space();
612 }
613 this.print(node.value);
614}
615function ObjectTypeSpreadProperty(node) {
616 this.token("...");
617 this.print(node.argument);
618}
619function QualifiedTypeIdentifier(node) {
620 this.print(node.qualification);
621 this.tokenChar(46);
622 this.print(node.id);
623}
624function SymbolTypeAnnotation() {
625 this.word("symbol");
626}
627function orSeparator(occurrenceCount) {
628 this.space();
629 this.token("|", false, occurrenceCount);
630 this.space();
631}
632function UnionTypeAnnotation(node) {
633 this.printJoin(node.types, {
634 separator: orSeparator
635 });
636}
637function TypeCastExpression(node) {
638 this.tokenChar(40);
639 this.print(node.expression);
640 this.print(node.typeAnnotation);
641 this.tokenChar(41);
642}
643function Variance(node) {
644 if (node.kind === "plus") {
645 this.tokenChar(43);
646 } else {
647 this.tokenChar(45);
648 }
649}
650function VoidTypeAnnotation() {
651 this.word("void");
652}
653function IndexedAccessType(node) {
654 this.print(node.objectType, true);
655 this.tokenChar(91);
656 this.print(node.indexType);
657 this.tokenChar(93);
658}
659function OptionalIndexedAccessType(node) {
660 this.print(node.objectType);
661 if (node.optional) {
662 this.token("?.");
663 }
664 this.tokenChar(91);
665 this.print(node.indexType);
666 this.tokenChar(93);
667}
668
669//# sourceMappingURL=flow.js.map
Note: See TracBrowser for help on using the repository browser.