atConstructorDeclaration method

void atConstructorDeclaration(
  1. ConstructorDeclaration node,
  2. ErrorCode errorCode, {
  3. List<Object>? arguments,
  4. List<DiagnosticMessage>? contextMessages,
  5. Object? data,
})

Report a diagnostic with the given errorCode and arguments. The location of the diagnostic will be the name of the node.

Implementation

void atConstructorDeclaration(
  ConstructorDeclaration node,
  ErrorCode errorCode, {
  List<Object>? arguments,
  List<DiagnosticMessage>? contextMessages,
  Object? data,
}) {
  // TODO(brianwilkerson): Consider extending this method to take any
  //  declaration and compute the correct range for the name of that
  //  declaration. This might make it easier to be consistent.
  if (node.name case var nameToken?) {
    var offset = node.returnType.offset;
    atOffset(
      offset: offset,
      length: nameToken.end - offset,
      errorCode: errorCode,
      arguments: arguments,
    );
  } else {
    atNode(
      node.returnType,
      errorCode,
      arguments: arguments,
    );
  }
}