visitInstanceCreationExpression method

  1. @override
Map? visitInstanceCreationExpression(
  1. InstanceCreationExpression node
)
override

Implementation

@override
Map? visitInstanceCreationExpression(InstanceCreationExpression node) {
  Map? callee;
  if (node.constructorName.type.name is PrefixedIdentifier) {
    var prefixedIdentifier =
        node.constructorName.type.name as PrefixedIdentifier;
    callee = {
      'type': 'MemberExpression',
      'object': _visitNode(prefixedIdentifier.prefix),
      'property': _visitNode(prefixedIdentifier.identifier),
    };
  }
  // 换了用 AnalysisContextCollection 解析之后,
  // 可以直接拿到构造的名字
  else if (node.constructorName.name != null) {
    callee = {
      'type': 'MemberExpression',
      'object': _visitNode(node.constructorName.type.name),
      'property': _visitNode(node.constructorName.name),
    };
  } else {
    //如果不是simpleIdentif 需要特殊处理
    callee = _visitNode(node.constructorName.type.name);
  }
  return _buildMethodInvocation(callee, null, _visitNode(node.argumentList));
}