AnalysisError constructor

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

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(this.source, int offset, int length, this.errorCode,
    [List<Object?>? arguments,
    List<DiagnosticMessage> contextMessages = const []])
    : _contextMessages = contextMessages {
  assert(
      (arguments ?? const []).length == errorCode.numParameters,
      'Message $errorCode requires ${errorCode.numParameters} '
      'argument(s), but ${(arguments ?? const []).length} argument(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);
}