Skip to content

Commit

Permalink
feat: trace assignation in ObjectExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-michelet committed May 16, 2024
1 parent 347036e commit a1972cf
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions workspaces/estree-ast-utils/src/utils/VariableTracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,24 @@ export class VariableTracer extends EventEmitter {

break;
}

case "ObjectExpression": {
this.#walkObjectExpression(id, childNode);
}
}
}

#walkObjectExpression(id, node) {
for (const prop of node.properties) {
const newId = { ...id, name: id.name + "." + prop.key.name };
if (prop.value.type === "Identifier") {
if (this.#traced.has(prop.value.name)) {
this.#declareNewAssignment(prop.value.name, newId);
}
}
else if (prop.value.type === "ObjectExpression") {
this.#walkObjectExpression(newId, prop.value);
}
}
}

Expand Down Expand Up @@ -458,8 +476,16 @@ export class VariableTracer extends EventEmitter {
}
break;
}
case "AssignmentExpression": {
console.log("TODO");

break;
}

case "ClassDeclaration": {
this.#walkClassDeclaration(node);

break;
}
}
}
Expand Down

0 comments on commit a1972cf

Please sign in to comment.