MCPcopy
hub / github.com/webpack/webpack / _preWalkArrayPattern

Method _preWalkArrayPattern

lib/javascript/JavascriptParser.js:3283–3307  ·  view source on GitHub ↗

* Pre walk array pattern. * @param {ArrayPattern} arrayPattern array pattern * @returns {Set<DestructuringAssignmentProperty> | undefined} set of names or undefined if not all keys are identifiers

(arrayPattern)

Source from the content-addressed store, hash-verified

3281 * @returns {Set<DestructuringAssignmentProperty> | undefined} set of names or undefined if not all keys are identifiers
3282 */
3283 _preWalkArrayPattern(arrayPattern) {
3284 /** @type {Set<DestructuringAssignmentProperty>} */
3285 const props = new Set();
3286 const elements = arrayPattern.elements;
3287 for (let i = 0; i < elements.length; i++) {
3288 const element = elements[i];
3289 if (!element) continue;
3290 if (element.type === "RestElement") return;
3291 const pattern =
3292 element.type === "ObjectPattern"
3293 ? this._preWalkObjectPattern(element)
3294 : element.type === "ArrayPattern"
3295 ? this._preWalkArrayPattern(element)
3296 : undefined;
3297 props.add({
3298 id: `${i}`,
3299 range: /** @type {Range} */ (element.range),
3300 loc: /** @type {SourceLocation} */ (element.loc),
3301 pattern,
3302 shorthand: false
3303 });
3304 }
3305
3306 return props;
3307 }
3308
3309 /**
3310 * Pre walk variable declarator.

Callers 1

_preWalkObjectPatternMethod · 0.95

Calls 2

_preWalkObjectPatternMethod · 0.95
addMethod · 0.45

Tested by

no test coverage detected