@@ -71,10 +71,6 @@ class Diagnostic {
7171 /// being reported. The list will be empty if there are no such messages.
7272 final List <DiagnosticMessage > contextMessages;
7373
74- /// Data associated with this diagnostic, specific for [diagnosticCode] .
75- @Deprecated ('Use an expando instead' )
76- final Object ? data;
77-
7874 /// A description of how to fix the problem, or `null` if there is no such
7975 /// description.
8076 final String ? correctionMessage;
@@ -89,15 +85,11 @@ class Diagnostic {
8985 required this .source,
9086 required int offset,
9187 required int length,
92- DiagnosticCode ? diagnosticCode,
93- @Deprecated ("Pass a value for 'diagnosticCode' instead" )
94- DiagnosticCode ? errorCode,
88+ required this .diagnosticCode,
9589 required String message,
9690 this .correctionMessage,
9791 this .contextMessages = const [],
98- @Deprecated ('Use an expando instead' ) this .data,
99- }) : diagnosticCode = _useNonNullCodeBetween (diagnosticCode, errorCode),
100- problemMessage = new DiagnosticMessageImpl (
92+ }) : problemMessage = new DiagnosticMessageImpl (
10193 filePath: source.fullName,
10294 length: length,
10395 message: message,
@@ -109,31 +101,27 @@ class Diagnostic {
109101 ///
110102 /// The diagnostic is associated with the given [source] and is located at the
111103 /// given [offset] with the given [length] . The diagnostic will have the given
112- /// [errorCode ] and the list of [arguments] will be used to complete the
104+ /// [diagnosticCode ] and the list of [arguments] will be used to complete the
113105 /// message and correction. If any [contextMessages] are provided, they will
114106 /// be recorded with the diagnostic.
115107 factory Diagnostic .tmp ({
116108 required Source source,
117109 required int offset,
118110 required int length,
119- DiagnosticCode ? diagnosticCode,
120- @Deprecated ("Pass a value for 'diagnosticCode' instead" )
121- DiagnosticCode ? errorCode,
111+ required DiagnosticCode diagnosticCode,
122112 List <Object ?> arguments = const [],
123113 List <DiagnosticMessage > contextMessages = const [],
124- @Deprecated ('Use an expando instead' ) Object ? data,
125114 }) {
126- DiagnosticCode code = _useNonNullCodeBetween (diagnosticCode, errorCode);
127115 assert (
128- arguments.length == code .numParameters,
129- 'Message $code requires ${code .numParameters } '
130- 'argument${code .numParameters == 1 ? '' : 's' }, but '
116+ arguments.length == diagnosticCode .numParameters,
117+ 'Message $diagnosticCode requires ${diagnosticCode .numParameters } '
118+ 'argument${diagnosticCode .numParameters == 1 ? '' : 's' }, but '
131119 '${arguments .length } '
132120 'argument${arguments .length == 1 ? ' was' : 's were' } '
133121 'provided' ,
134122 );
135- String message = formatList (code .problemMessage, arguments);
136- String ? correctionTemplate = code .correctionMessage;
123+ String message = formatList (diagnosticCode .problemMessage, arguments);
124+ String ? correctionTemplate = diagnosticCode .correctionMessage;
137125 String ? correctionMessage;
138126 if (correctionTemplate != null ) {
139127 correctionMessage = formatList (correctionTemplate, arguments);
@@ -143,12 +131,10 @@ class Diagnostic {
143131 source: source,
144132 offset: offset,
145133 length: length,
146- diagnosticCode: code ,
134+ diagnosticCode: diagnosticCode ,
147135 message: message,
148136 correctionMessage: correctionMessage,
149137 contextMessages: contextMessages,
150- // ignore: deprecated_member_use_from_same_package
151- data: data,
152138 );
153139 }
154140
@@ -233,19 +219,6 @@ class Diagnostic {
233219 buffer.write (message);
234220 return buffer.toString ();
235221 }
236-
237- /// The non-`null` [DiagnosticCode] value between the two parameters.
238- static DiagnosticCode _useNonNullCodeBetween (
239- DiagnosticCode ? diagnosticCode,
240- DiagnosticCode ? errorCode,
241- ) {
242- if ((diagnosticCode == null ) == (errorCode == null )) {
243- throw new ArgumentError (
244- "Exactly one of 'diagnosticCode' and 'errorCode' may be passed" ,
245- );
246- }
247- return diagnosticCode ?? errorCode! ;
248- }
249222}
250223
251224/// Private subtype of [DiagnosticCode] that supports runtime checking of
0 commit comments