atOffset method
void
atOffset({})
Report an error with the given errorCode
and arguments
. The location
of the error is specified by the given offset
and length
.
Implementation
void atOffset({
required int offset,
required int length,
required ErrorCode errorCode,
List<Object>? arguments,
List<DiagnosticMessage>? contextMessages,
Object? data,
}) {
if (lockLevel != 0) {
return;
}
if (arguments != null) {
var invalid = arguments
.whereNotType<String>()
.whereNotType<DartType>()
.whereNotType<Element2>()
.whereNotType<int>()
.whereNotType<Uri>();
if (invalid.isNotEmpty) {
throw ArgumentError('Tried to format an error using '
'${invalid.map((e) => e.runtimeType).join(', ')}');
}
}
contextMessages ??= [];
contextMessages.addAll(_convertTypeNames(arguments));
_errorListener.onError(
AnalysisError.tmp(
source: _source,
offset: offset,
length: length,
errorCode: errorCode,
arguments: arguments ?? const [],
contextMessages: contextMessages,
data: data,
),
);
}