MCPcopy
hub / github.com/rollup/rollup / ThisExpression

Class ThisExpression

src/ast/nodes/ThisExpression.ts:19–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17import { NodeBase } from './shared/Node';
18
19export default class ThisExpression extends NodeBase {
20 declare type: NodeType.tThisExpression;
21 declare variable: Variable;
22 declare private alias: string | null;
23
24 bind(): void {
25 this.variable = this.scope.findVariable('this');
26 }
27
28 deoptimizeArgumentsOnInteractionAtPath(
29 interaction: NodeInteraction,
30 path: ObjectPath,
31 recursionTracker: EntityPathTracker
32 ): void {
33 this.variable.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
34 }
35
36 deoptimizePath(path: ObjectPath): void {
37 this.variable.deoptimizePath(path);
38 }
39
40 hasEffectsOnInteractionAtPath(
41 path: ObjectPath,
42 interaction: NodeInteraction,
43 context: HasEffectsContext
44 ): boolean {
45 if (path.length === 0) {
46 return interaction.type !== INTERACTION_ACCESSED;
47 }
48 return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
49 }
50
51 include(context: InclusionContext): void {
52 if (!this.included) this.includeNode(context);
53 }
54
55 includeNode(context: InclusionContext) {
56 this.included = true;
57 if (!this.deoptimized) this.applyDeoptimizations();
58 this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
59 }
60
61 includePath(path: ObjectPath, context: InclusionContext): void {
62 if (!this.included) {
63 this.included = true;
64 this.scope.context.includeVariableInModule(this.variable, path, context);
65 } else if (path.length > 0) {
66 this.variable.includePath(path, context);
67 }
68 const functionScope = findFunctionScope(this.scope, this.variable);
69 if (
70 functionScope &&
71 functionScope.functionNode.parent instanceof Property &&
72 functionScope.functionNode.parent.parent instanceof ObjectExpression
73 ) {
74 functionScope.functionNode.parent.parent.includePath(path, context);
75 }
76 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…