visitIndex method

  1. @override
dynamic visitIndex(
  1. IndexExpression node, {
  2. bool computeAsPattern = false,
})

Implementation

@override
visitIndex(IndexExpression node, {bool computeAsPattern = false}) {
  dynamic obj = node.object.visitBy(this);
  dynamic prop;
  if (node.property is LiteralExpression) {
    prop = (node.property as LiteralExpression).value;
  }
  if (node.property is NameExpression) {
    if (obj is String) {
      bindings.add(obj);
      bindings.add(node.property.visitBy(this)
          as String); //we add the name to the bindings as well
    }
  } else if (obj is String) {
    if (prop is num) {
      return obj + '[' + prop.toString() + ']';
    } else if (prop is String) {
      return obj + "['" + prop + "']";
    }
  }
}