Skip to content

Commit 081104f

Browse files
authored
refactor: rename to symbol for readability (#20291)
1 parent 0c61ce2 commit 081104f

2 files changed

Lines changed: 28 additions & 28 deletions

File tree

lib/optimize/InnerGraph.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,14 +353,14 @@ module.exports.tagTopLevelSymbol = (parser, name) => {
353353
return existingTag;
354354
}
355355

356-
const fn = new TopLevelSymbol(name);
356+
const symbol = new TopLevelSymbol(name);
357357
parser.tagVariable(
358358
name,
359359
topLevelSymbolTag,
360-
fn,
360+
symbol,
361361
JavascriptParser.VariableInfoFlags.Normal
362362
);
363-
return fn;
363+
return symbol;
364364
};
365365

366366
module.exports.topLevelSymbolTag = topLevelSymbolTag;

lib/optimize/InnerGraphPlugin.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ class InnerGraphPlugin {
120120
statement.type === "FunctionDeclaration"
121121
) {
122122
const name = statement.id ? statement.id.name : "*default*";
123-
const fn =
123+
const symbol =
124124
/** @type {TopLevelSymbol} */
125125
(InnerGraph.tagTopLevelSymbol(parser, name));
126-
statementWithTopLevelSymbol.set(statement, fn);
126+
statementWithTopLevelSymbol.set(statement, symbol);
127127
return true;
128128
}
129129
});
@@ -140,15 +140,15 @@ class InnerGraphPlugin {
140140
)
141141
) {
142142
const name = statement.id ? statement.id.name : "*default*";
143-
const fn = /** @type {TopLevelSymbol} */ (
143+
const symbol = /** @type {TopLevelSymbol} */ (
144144
InnerGraph.tagTopLevelSymbol(parser, name)
145145
);
146-
classWithTopLevelSymbol.set(statement, fn);
146+
classWithTopLevelSymbol.set(statement, symbol);
147147
return true;
148148
}
149149
if (statement.type === "ExportDefaultDeclaration") {
150150
const name = "*default*";
151-
const fn =
151+
const symbol =
152152
/** @type {TopLevelSymbol} */
153153
(InnerGraph.tagTopLevelSymbol(parser, name));
154154
const decl = statement.declaration;
@@ -165,7 +165,7 @@ class InnerGraphPlugin {
165165
classWithTopLevelSymbol.set(
166166
/** @type {ClassExpression | ClassDeclaration} */
167167
(decl),
168-
fn
168+
symbol
169169
);
170170
} else if (
171171
parser.isPure(
@@ -175,7 +175,7 @@ class InnerGraphPlugin {
175175
(statement.range)[0]
176176
)
177177
) {
178-
statementWithTopLevelSymbol.set(statement, fn);
178+
statementWithTopLevelSymbol.set(statement, symbol);
179179
if (
180180
!decl.type.endsWith("FunctionExpression") &&
181181
!decl.type.endsWith("Declaration") &&
@@ -207,20 +207,20 @@ class InnerGraphPlugin {
207207
/** @type {Range} */ (decl.id.range)[1]
208208
)
209209
) {
210-
const fn =
210+
const symbol =
211211
/** @type {TopLevelSymbol} */
212212
(InnerGraph.tagTopLevelSymbol(parser, name));
213-
classWithTopLevelSymbol.set(decl.init, fn);
213+
classWithTopLevelSymbol.set(decl.init, symbol);
214214
} else if (
215215
parser.isPure(
216216
decl.init,
217217
/** @type {Range} */ (decl.id.range)[1]
218218
)
219219
) {
220-
const fn =
220+
const symbol =
221221
/** @type {TopLevelSymbol} */
222222
(InnerGraph.tagTopLevelSymbol(parser, name));
223-
declWithTopLevelSymbol.set(decl, fn);
223+
declWithTopLevelSymbol.set(decl, symbol);
224224
if (
225225
!decl.init.type.endsWith("FunctionExpression") &&
226226
decl.init.type !== "Literal"
@@ -252,9 +252,9 @@ class InnerGraphPlugin {
252252
if (parser.scope.topLevelScope === true) {
253253
InnerGraph.setTopLevelSymbol(parser.state, undefined);
254254

255-
const fn = statementWithTopLevelSymbol.get(statement);
256-
if (fn) {
257-
InnerGraph.setTopLevelSymbol(parser.state, fn);
255+
const symbol = statementWithTopLevelSymbol.get(statement);
256+
if (symbol) {
257+
InnerGraph.setTopLevelSymbol(parser.state, symbol);
258258
const purePart = statementPurePart.get(statement);
259259
if (purePart) {
260260
InnerGraph.onUsage(parser.state, (usedByExports) => {
@@ -285,17 +285,17 @@ class InnerGraphPlugin {
285285
(expr, statement) => {
286286
if (!InnerGraph.isEnabled(parser.state)) return;
287287
if (parser.scope.topLevelScope === true) {
288-
const fn = classWithTopLevelSymbol.get(statement);
288+
const symbol = classWithTopLevelSymbol.get(statement);
289289
if (
290-
fn &&
290+
symbol &&
291291
parser.isPure(
292292
expr,
293293
statement.id
294294
? /** @type {Range} */ (statement.id.range)[1]
295295
: /** @type {Range} */ (statement.range)[0]
296296
)
297297
) {
298-
InnerGraph.setTopLevelSymbol(parser.state, fn);
298+
InnerGraph.setTopLevelSymbol(parser.state, symbol);
299299
onUsageSuper(expr);
300300
}
301301
}
@@ -307,8 +307,8 @@ class InnerGraphPlugin {
307307
(element, classDefinition) => {
308308
if (!InnerGraph.isEnabled(parser.state)) return;
309309
if (parser.scope.topLevelScope === true) {
310-
const fn = classWithTopLevelSymbol.get(classDefinition);
311-
if (fn) {
310+
const symbol = classWithTopLevelSymbol.get(classDefinition);
311+
if (symbol) {
312312
InnerGraph.setTopLevelSymbol(parser.state, undefined);
313313
}
314314
}
@@ -320,8 +320,8 @@ class InnerGraphPlugin {
320320
(expression, element, classDefinition) => {
321321
if (!InnerGraph.isEnabled(parser.state)) return;
322322
if (parser.scope.topLevelScope === true) {
323-
const fn = classWithTopLevelSymbol.get(classDefinition);
324-
if (fn) {
323+
const symbol = classWithTopLevelSymbol.get(classDefinition);
324+
if (symbol) {
325325
if (
326326
!element.static ||
327327
parser.isPure(
@@ -331,7 +331,7 @@ class InnerGraphPlugin {
331331
: /** @type {Range} */ (element.range)[0]
332332
)
333333
) {
334-
InnerGraph.setTopLevelSymbol(parser.state, fn);
334+
InnerGraph.setTopLevelSymbol(parser.state, symbol);
335335
if (element.type !== "MethodDefinition" && element.static) {
336336
InnerGraph.onUsage(parser.state, (usedByExports) => {
337337
switch (usedByExports) {
@@ -362,10 +362,10 @@ class InnerGraphPlugin {
362362

363363
parser.hooks.declarator.tap(PLUGIN_NAME, (decl, _statement) => {
364364
if (!InnerGraph.isEnabled(parser.state)) return;
365-
const fn = declWithTopLevelSymbol.get(decl);
365+
const symbol = declWithTopLevelSymbol.get(decl);
366366

367-
if (fn) {
368-
InnerGraph.setTopLevelSymbol(parser.state, fn);
367+
if (symbol) {
368+
InnerGraph.setTopLevelSymbol(parser.state, symbol);
369369
if (pureDeclarators.has(decl)) {
370370
if (
371371
/** @type {ClassExpression} */

0 commit comments

Comments
 (0)