MCPcopy
hub / github.com/vuejs/core / isReferencedIdentifier

Function isReferencedIdentifier

packages/compiler-core/src/babelUtils.ts:126–161  ·  view source on GitHub ↗
(
  id: Identifier,
  parent: Node | null,
  parentStack: Node[],
)

Source from the content-addressed store, hash-verified

124}
125
126export function isReferencedIdentifier(
127 id: Identifier,
128 parent: Node | null,
129 parentStack: Node[],
130): boolean {
131 if (__BROWSER__) {
132 return false
133 }
134
135 if (!parent) {
136 return true
137 }
138
139 // is a special keyword but parsed as identifier
140 if (id.name === 'arguments') {
141 return false
142 }
143
144 if (isReferenced(id, parent, parentStack[parentStack.length - 2])) {
145 return true
146 }
147
148 // babel's isReferenced check returns false for ids being assigned to, so we
149 // need to cover those cases here
150 switch (parent.type) {
151 case 'AssignmentExpression':
152 case 'AssignmentPattern':
153 return true
154 case 'ObjectProperty':
155 return parent.key !== id && isInDestructureAssignment(parent, parentStack)
156 case 'ArrayPattern':
157 return isInDestructureAssignment(parent, parentStack)
158 }
159
160 return false
161}
162
163export function isInDestructureAssignment(
164 parent: Node,

Callers 3

utils.spec.tsFile · 0.90
enterFunction · 0.85
enterFunction · 0.85

Calls 2

isReferencedFunction · 0.85

Tested by

no test coverage detected