MCPcopy Create free account
hub / github.com/Snapchat/Valdi / injectDeclarations

Method injectDeclarations

compiler/companion/src/JSXProcessor.ts:1123–1149  ·  view source on GitHub ↗
(
    node: ts.SourceFile,
    outputState: JSXOutputState,
    transformContext: ts.TransformationContext,
  )

Source from the content-addressed store, hash-verified

1121 }
1122
1123 private injectDeclarations(
1124 node: ts.SourceFile,
1125 outputState: JSXOutputState,
1126 transformContext: ts.TransformationContext,
1127 ): ts.SourceFile {
1128 const requireCall = transformContext.factory.createCallExpression(
1129 transformContext.factory.createIdentifier('require'),
1130 undefined,
1131 [createStringLiteral(rendererModulePath, transformContext)],
1132 );
1133 const accessToJsx = transformContext.factory.createPropertyAccessExpression(requireCall, 'jsx');
1134
1135 const rendererVariableStatement = this.createConstVariable('__Renderer', accessToJsx, transformContext);
1136 outputState.nodePrototypeDeclarations.splice(0, 0, rendererVariableStatement);
1137
1138 const allStatements: ts.Statement[] = [];
1139
1140 const insertionIndex = this.findDeclarationsInsertionIndex(node.statements);
1141
1142 for (const oldStatement of node.statements) {
1143 allStatements.push(oldStatement);
1144 }
1145
1146 allStatements.splice(insertionIndex, 0, ...outputState.nodePrototypeDeclarations);
1147
1148 return this.doUpdateSourceFileNode(node, allStatements, transformContext);
1149 }
1150
1151 private processJSXElement(
1152 node: ts.JsxElement,

Callers 1

makeTransformersMethod · 0.95

Calls 5

createConstVariableMethod · 0.95
createStringLiteralFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected