AnalysisError.tmp constructor

AnalysisError.tmp({
  1. required Source source,
  2. required int offset,
  3. required int length,
  4. required ErrorCode errorCode,
  5. List<Object?> arguments = const [],
  6. List<DiagnosticMessage> contextMessages = const [],
  7. Object? data,
})

Initialize a newly created analysis error. The error is associated with the given source and is located at the given offset with the given length. The error will have the given errorCode and the list of arguments will be used to complete the message and correction. If any contextMessages are provided, they will be recorded with the error.

Implementation

AnalysisError.tmp({
  required this.source,
  required int offset,
  required int length,
  required this.errorCode,
  List<Object?> arguments = const [],
  List<DiagnosticMessage> contextMessages = const [],
  this.data,
}) : _contextMessages = contextMessages {
  assert(
    arguments.length == errorCode.numParameters,
    'Message $errorCode requires ${errorCode.numParameters} '
    'argument${errorCode.numParameters == 1 ? '' : 's'}, but '
    '${arguments.length} '
    'argument${arguments.length == 1 ? ' was' : 's were'} '
    'provided',
  );
  String problemMessage = formatList(errorCode.problemMessage, arguments);
  String? correctionTemplate = errorCode.correctionMessage;
  if (correctionTemplate != null) {
    _correctionMessage = formatList(correctionTemplate, arguments);
  }
  _problemMessage = DiagnosticMessageImpl(
    filePath: source.fullName,
    length: length,
    message: problemMessage,
    offset: offset,
    url: null,
  );
}