MCPcopy Index your code
hub / github.com/formatjs/formatjs / visitor

Function visitor

packages/babel-plugin-formatjs/visitors/call-expression.ts:64–229  ·  view source on GitHub ↗
(
    path,
    {
      opts,
      file: {
        opts: {filename},
      },
    }
  )

Source from the content-addressed store, hash-verified

62
63export 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(

Callers

nothing calls this directly

Calls 6

wasExtractedFunction · 0.90
assertObjectExpressionFunction · 0.85
processMessageObjectFunction · 0.85
isFormatMessageCallFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected