(
path,
{
opts,
file: {
opts: {filename},
},
}
)
| 62 | |
| 63 | export const visitor: VisitNodeFunction<PluginPass & State, t.CallExpression> = |
| 64 | function ( |
| 65 | path, |
| 66 | { |
| 67 | opts, |
| 68 | file: { |
| 69 | opts: {filename}, |
| 70 | }, |
| 71 | } |
| 72 | ) { |
| 73 | const { |
| 74 | overrideIdFn, |
| 75 | idInterpolationPattern, |
| 76 | removeDefaultMessage, |
| 77 | ast, |
| 78 | preserveWhitespace, |
| 79 | flatten, |
| 80 | throws, |
| 81 | onMsgError, |
| 82 | } = opts as Options |
| 83 | if (wasExtracted(path)) { |
| 84 | return |
| 85 | } |
| 86 | const {messages, functionNames} = this |
| 87 | const callee = path.get('callee') |
| 88 | const args = path.get('arguments') |
| 89 | |
| 90 | /** |
| 91 | * Process MessageDescriptor |
| 92 | * @param messageDescriptor Message Descriptor |
| 93 | */ |
| 94 | function processMessageObject( |
| 95 | messageDescriptor: NodePath<t.ObjectExpression> |
| 96 | ) { |
| 97 | assertObjectExpression(messageDescriptor, callee) |
| 98 | |
| 99 | const properties = messageDescriptor.get( |
| 100 | 'properties' |
| 101 | ) as NodePath<t.ObjectProperty>[] |
| 102 | |
| 103 | let descriptorPath: MessageDescriptorPath |
| 104 | let descriptor: MessageDescriptor |
| 105 | try { |
| 106 | descriptorPath = createMessageDescriptor( |
| 107 | properties.map( |
| 108 | prop => |
| 109 | [prop.get('key'), prop.get('value')] as [ |
| 110 | NodePath<t.Identifier>, |
| 111 | NodePath<t.StringLiteral>, |
| 112 | ] |
| 113 | ) |
| 114 | ) |
| 115 | |
| 116 | // If the message is already compiled, don't re-compile it |
| 117 | if (descriptorPath.defaultMessage?.isArrayExpression()) { |
| 118 | return |
| 119 | } |
| 120 | |
| 121 | descriptor = evaluateMessageDescriptor( |
nothing calls this directly
no test coverage detected