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

Function extractRenderElements

npm_modules/cli/src/core/analyze/parser.ts:115–132  ·  view source on GitHub ↗
(sourceFile: ts.SourceFile)

Source from the content-addressed store, hash-verified

113}
114
115function extractRenderElements(sourceFile: ts.SourceFile): string[] {
116 const elements: string[] = [];
117
118 function visit(node: ts.Node): void {
119 if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) {
120 const tagName = node.tagName.getText(sourceFile);
121 elements.push(tagName);
122 }
123 ts.forEachChild(node, visit);
124 }
125
126 const onRender = findMethod(sourceFile, 'onRender');
127 if (onRender) {
128 ts.forEachChild(onRender, visit);
129 }
130
131 return elements;
132}
133
134function findMethod(sourceFile: ts.SourceFile, methodName: string): ts.Node | undefined {
135 for (const statement of sourceFile.statements) {

Callers 1

parseFileFunction · 0.85

Calls 1

findMethodFunction · 0.85

Tested by

no test coverage detected