| 932 | const PRAGMA_REGEX = /^\/\/ @([^\s]*) (.*)$/m |
| 933 | |
| 934 | function getVisitor( |
| 935 | ts: TypeScript, |
| 936 | ctx: typescript.TransformationContext, |
| 937 | sf: typescript.SourceFile, |
| 938 | opts: Opts |
| 939 | ) { |
| 940 | const visitor: typescript.Visitor = ( |
| 941 | node: typescript.Node |
| 942 | ): typescript.Node => { |
| 943 | const newNode = ts.isCallExpression(node) |
| 944 | ? extractMessagesFromCallExpression(ts, ctx.factory, node, opts, sf) |
| 945 | : ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node) |
| 946 | ? extractMessageFromJsxComponent( |
| 947 | ts, |
| 948 | ctx.factory, |
| 949 | node as typescript.JsxOpeningElement, |
| 950 | opts, |
| 951 | sf |
| 952 | ) |
| 953 | : node |
| 954 | return ts.visitEachChild(newNode as typescript.Node, visitor, ctx) |
| 955 | } |
| 956 | return visitor |
| 957 | } |
| 958 | |
| 959 | export function transformWithTs( |
| 960 | ts: TypeScript, |