source: frontend/node_modules/@babel/generator/lib/generators/expressions.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago

Fix frontend appearance

  • Property mode set to 100644
File size: 8.3 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.LogicalExpression = exports.AssignmentExpression = AssignmentExpression;
7exports.AssignmentPattern = AssignmentPattern;
8exports.AwaitExpression = AwaitExpression;
9exports.BinaryExpression = BinaryExpression;
10exports.BindExpression = BindExpression;
11exports.CallExpression = CallExpression;
12exports.ConditionalExpression = ConditionalExpression;
13exports.Decorator = Decorator;
14exports.DoExpression = DoExpression;
15exports.EmptyStatement = EmptyStatement;
16exports.ExpressionStatement = ExpressionStatement;
17exports.Import = Import;
18exports.MemberExpression = MemberExpression;
19exports.MetaProperty = MetaProperty;
20exports.ModuleExpression = ModuleExpression;
21exports.NewExpression = NewExpression;
22exports.OptionalCallExpression = OptionalCallExpression;
23exports.OptionalMemberExpression = OptionalMemberExpression;
24exports.ParenthesizedExpression = ParenthesizedExpression;
25exports.PrivateName = PrivateName;
26exports.SequenceExpression = SequenceExpression;
27exports.Super = Super;
28exports.ThisExpression = ThisExpression;
29exports.UnaryExpression = UnaryExpression;
30exports.UpdateExpression = UpdateExpression;
31exports.V8IntrinsicIdentifier = V8IntrinsicIdentifier;
32exports.YieldExpression = YieldExpression;
33exports._shouldPrintDecoratorsBeforeExport = _shouldPrintDecoratorsBeforeExport;
34var _t = require("@babel/types");
35var _index = require("../node/index.js");
36const {
37 isCallExpression,
38 isLiteral,
39 isMemberExpression,
40 isNewExpression,
41 isPattern
42} = _t;
43function UnaryExpression(node) {
44 const {
45 operator
46 } = node;
47 const firstChar = operator.charCodeAt(0);
48 if (firstChar >= 97 && firstChar <= 122) {
49 this.word(operator);
50 this.space();
51 } else {
52 this.tokenChar(firstChar);
53 }
54 this.print(node.argument);
55}
56function DoExpression(node) {
57 if (node.async) {
58 this.word("async", true);
59 this.space();
60 }
61 this.word("do");
62 this.space();
63 this.print(node.body);
64}
65function ParenthesizedExpression(node) {
66 this.tokenChar(40);
67 const oldNoLineTerminatorAfterNode = this.enterDelimited();
68 this.print(node.expression, undefined, true);
69 this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
70 this.rightParens(node);
71}
72function UpdateExpression(node) {
73 if (node.prefix) {
74 this.token(node.operator, false, 0, true);
75 this.print(node.argument);
76 } else {
77 this.print(node.argument, true);
78 this.token(node.operator, false, 0, true);
79 }
80}
81function ConditionalExpression(node) {
82 this.print(node.test);
83 this.space();
84 this.tokenChar(63);
85 this.space();
86 this.print(node.consequent);
87 this.space();
88 this.tokenChar(58);
89 this.space();
90 this.print(node.alternate);
91}
92function NewExpression(node, parent) {
93 this.word("new");
94 this.space();
95 this.print(node.callee);
96 if (this.format.minified && node.arguments.length === 0 && !node.optional && !isCallExpression(parent, {
97 callee: node
98 }) && !isMemberExpression(parent) && !isNewExpression(parent)) {
99 return;
100 }
101 this.print(node.typeArguments);
102 this.print(node.typeParameters);
103 if (node.optional) {
104 this.token("?.");
105 }
106 if (node.arguments.length === 0 && this.tokenMap && !this.tokenMap.endMatches(node, ")")) {
107 return;
108 }
109 this.tokenChar(40);
110 const oldNoLineTerminatorAfterNode = this.enterDelimited();
111 this.printList(node.arguments, this.shouldPrintTrailingComma(")"), undefined, undefined, undefined, true);
112 this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
113 this.rightParens(node);
114}
115function SequenceExpression(node) {
116 this.printList(node.expressions);
117}
118function ThisExpression() {
119 this.word("this");
120}
121function Super() {
122 this.word("super");
123}
124function _shouldPrintDecoratorsBeforeExport(node) {
125 if (typeof this.format.decoratorsBeforeExport === "boolean") {
126 return this.format.decoratorsBeforeExport;
127 }
128 return typeof node.start === "number" && node.start === node.declaration.start;
129}
130function Decorator(node) {
131 this.tokenChar(64);
132 const {
133 expression
134 } = node;
135 this.print(expression);
136 this.newline();
137}
138function OptionalMemberExpression(node) {
139 let {
140 computed
141 } = node;
142 const {
143 optional,
144 property
145 } = node;
146 this.print(node.object);
147 if (!computed && isMemberExpression(property)) {
148 throw new TypeError("Got a MemberExpression for MemberExpression property");
149 }
150 if (isLiteral(property) && typeof property.value === "number") {
151 computed = true;
152 }
153 if (optional) {
154 this.token("?.");
155 }
156 if (computed) {
157 this.tokenChar(91);
158 this.print(property);
159 this.tokenChar(93);
160 } else {
161 if (!optional) {
162 this.tokenChar(46);
163 }
164 this.print(property);
165 }
166}
167function OptionalCallExpression(node) {
168 this.print(node.callee);
169 this.print(node.typeParameters);
170 if (node.optional) {
171 this.token("?.");
172 }
173 this.print(node.typeArguments);
174 this.tokenChar(40);
175 const oldNoLineTerminatorAfterNode = this.enterDelimited();
176 this.printList(node.arguments, undefined, undefined, undefined, undefined, true);
177 this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
178 this.rightParens(node);
179}
180function CallExpression(node) {
181 this.print(node.callee);
182 this.print(node.typeArguments);
183 this.print(node.typeParameters);
184 this.tokenChar(40);
185 const oldNoLineTerminatorAfterNode = this.enterDelimited();
186 this.printList(node.arguments, this.shouldPrintTrailingComma(")"), undefined, undefined, undefined, true);
187 this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
188 this.rightParens(node);
189}
190function Import() {
191 this.word("import");
192}
193function AwaitExpression(node) {
194 this.word("await");
195 this.space();
196 this.print(node.argument);
197}
198function YieldExpression(node) {
199 if (node.delegate) {
200 this.word("yield", true);
201 this.tokenChar(42);
202 if (node.argument) {
203 this.space();
204 this.print(node.argument);
205 }
206 } else if (node.argument) {
207 this.word("yield", true);
208 this.space();
209 this.print(node.argument);
210 } else {
211 this.word("yield");
212 }
213}
214function EmptyStatement() {
215 this.semicolon(true);
216}
217function ExpressionStatement(node) {
218 this.tokenContext |= _index.TokenContext.expressionStatement;
219 this.print(node.expression);
220 this.semicolon();
221}
222function AssignmentPattern(node) {
223 this.print(node.left);
224 if (node.left.type === "Identifier" || isPattern(node.left)) {
225 if (node.left.optional) this.tokenChar(63);
226 this.print(node.left.typeAnnotation);
227 }
228 this.space();
229 this.tokenChar(61);
230 this.space();
231 this.print(node.right);
232}
233function AssignmentExpression(node) {
234 this.print(node.left);
235 this.space();
236 this.token(node.operator, false, 0, true);
237 this.space();
238 this.print(node.right);
239}
240function BinaryExpression(node) {
241 this.print(node.left);
242 this.space();
243 const {
244 operator
245 } = node;
246 if (operator.charCodeAt(0) === 105) {
247 this.word(operator);
248 } else {
249 this.token(operator, false, 0, true);
250 this.setLastChar(operator.charCodeAt(operator.length - 1));
251 }
252 this.space();
253 this.print(node.right);
254}
255function BindExpression(node) {
256 this.print(node.object);
257 this.token("::");
258 this.print(node.callee);
259}
260function MemberExpression(node) {
261 this.print(node.object);
262 if (!node.computed && isMemberExpression(node.property)) {
263 throw new TypeError("Got a MemberExpression for MemberExpression property");
264 }
265 let computed = node.computed;
266 if (isLiteral(node.property) && typeof node.property.value === "number") {
267 computed = true;
268 }
269 if (computed) {
270 const oldNoLineTerminatorAfterNode = this.enterDelimited();
271 this.tokenChar(91);
272 this.print(node.property, undefined, true);
273 this.tokenChar(93);
274 this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
275 } else {
276 this.tokenChar(46);
277 this.print(node.property);
278 }
279}
280function MetaProperty(node) {
281 this.print(node.meta);
282 this.tokenChar(46);
283 this.print(node.property);
284}
285function PrivateName(node) {
286 this.tokenChar(35);
287 this.print(node.id);
288}
289function V8IntrinsicIdentifier(node) {
290 this.tokenChar(37);
291 this.word(node.name);
292}
293function ModuleExpression(node) {
294 this.word("module", true);
295 this.space();
296 this.tokenChar(123);
297 this.indent();
298 const {
299 body
300 } = node;
301 if (body.body.length || body.directives.length) {
302 this.newline();
303 }
304 this.print(body);
305 this.dedent();
306 this.rightBrace(node);
307}
308
309//# sourceMappingURL=expressions.js.map
Note: See TracBrowser for help on using the repository browser.