visitCall method

  1. @override
bool visitCall(
  1. CallExpression node
)

Implementation

@override
bool visitCall(CallExpression node) {
  try {
    visit(node.callee);
    if (node.callee is MemberExpression) {
      final member = node.callee as MemberExpression;
      if (member.object is NameExpression) {
        String objectName = (member.object as NameExpression).name.value;
        validateContextExistence(objectName, node, context, isObject: true);
        dynamic obj = context.getContextById(objectName);
        if (obj != null && member.property is Name) {
          String methodName = (member.property as Name).value;
          validatePropertyOrMethodAccess(methodName, objectName, obj, node);
        }
      }
    } else if (node.callee is NameExpression) {
      String name = (node.callee as NameExpression).name.value;
      validateContextExistence(name, node, context);
    }
    for (var arg in node.arguments) {
      visit(arg);
    }
  } catch (e) {
    if (e is! JSException) {
      print('Validation warning: ${e.toString()}');
    } else {
      rethrow;
    }
  }
  return true;
}