MCPcopy Create free account
hub / github.com/angular/angular / getLocalizeCall

Function getLocalizeCall

packages/localize/tools/test/source_file_utils_spec.ts:489–513  ·  view source on GitHub ↗
(code: string)

Source from the content-addressed store, hash-verified

487}
488
489function getLocalizeCall(code: string): NodePath<t.CallExpression> {
490 let callPaths: NodePath<t.CallExpression>[] = [];
491 transformSync(code, {
492 code: false,
493 filename: 'test/file.js',
494 cwd: '/',
495 plugins: [
496 () => ({
497 visitor: {
498 CallExpression(path) {
499 callPaths.push(path);
500 },
501 },
502 }),
503 ],
504 });
505 const localizeCall = callPaths.find((p) => {
506 const callee = p.get('callee');
507 return callee.isIdentifier() && callee.node.name === '$localize';
508 });
509 if (!localizeCall) {
510 throw new Error(`$localize cannot be found in ${code}`);
511 }
512 return localizeCall;
513}

Callers 1

Calls 3

isIdentifierMethod · 0.80
getMethod · 0.65
findMethod · 0.45

Tested by

no test coverage detected