MCPcopy
hub / github.com/rollup/rollup / VariableDeclaration

Class VariableDeclaration

src/ast/nodes/VariableDeclaration.ts:33–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31import type VariableDeclarator from './VariableDeclarator';
32
33export default class VariableDeclaration extends NodeBase {
34 declare declarations: readonly VariableDeclarator[];
35 declare kind: VariableDeclarationKind;
36 declare type: NodeType.tVariableDeclaration;
37
38 deoptimizePath(): void {
39 for (const declarator of this.declarations) {
40 declarator.deoptimizePath(EMPTY_PATH);
41 }
42 }
43
44 hasEffectsOnInteractionAtPath(): boolean {
45 return false;
46 }
47
48 include(
49 context: InclusionContext,
50 includeChildrenRecursively: IncludeChildren,
51 { asSingleStatement }: InclusionOptions = BLANK
52 ): void {
53 this.included = true;
54 for (const declarator of this.declarations) {
55 if (includeChildrenRecursively || declarator.shouldBeIncluded(context)) {
56 declarator.include(context, includeChildrenRecursively);
57 }
58 const { id, init } = declarator;
59 if (asSingleStatement) {
60 id.include(context, includeChildrenRecursively);
61 }
62 if (
63 init &&
64 id.included &&
65 !init.included &&
66 (id instanceof ObjectPattern || id instanceof ArrayPattern)
67 ) {
68 init.include(context, includeChildrenRecursively);
69 }
70 }
71 }
72
73 initialise(): void {
74 super.initialise();
75 for (const declarator of this.declarations) {
76 declarator.declareDeclarator(this.kind);
77 }
78 }
79
80 removeAnnotations(code: MagicString) {
81 this.declarations[0].removeAnnotations(code);
82 }
83
84 render(
85 code: MagicString,
86 options: RenderOptions,
87 nodeRenderOptions: NodeRenderOptions = BLANK
88 ): void {
89 if (this.areAllDeclarationsIncludedAndNotExported(options.exportNamesByVariable)) {
90 for (const declarator of this.declarations) {

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…