visitObject method

  1. @override
bool visitObject(
  1. ObjectExpression node
)

Implementation

@override
bool visitObject(ObjectExpression node) {
  Map<String, dynamic> objProperties = {};
  for (var prop in node.properties) {
    if (prop.key is Name) {
      String key = (prop.key as Name).value;
      // If the value is another object, recursively track its properties
      if (prop.value is ObjectExpression) {
        objProperties[key] =
            _trackNestedObject(prop.value as ObjectExpression);
      } else {
        objProperties[key] = true;
      }
    }
    visit(prop.value);
  }
  // Store the object properties in the context for later validation
  if (node.parent != null && node.parent is VariableDeclarator) {
    String varName = (node.parent as VariableDeclarator).name.value;
    context.addDataContextById(varName, objProperties);
  }
  return true;
}