@@ -57,7 +57,7 @@ class MessageGeneration {
57
57
/// so it's left undefined.
58
58
String package;
59
59
60
- get releaseMode => codegenMode == 'release' ;
60
+ bool get releaseMode => codegenMode == 'release' ;
61
61
62
62
bool get jsonMode => false ;
63
63
@@ -105,10 +105,8 @@ class MessageGeneration {
105
105
for (var translation in usableTranslations) {
106
106
// Some messages we generate as methods in this class. Simpler ones
107
107
// we inline in the map from names to messages.
108
- var messagesThatNeedMethods = translation.originalMessages
109
- .where ((each) => _hasArguments (each))
110
- .toSet ()
111
- .toList ();
108
+ var messagesThatNeedMethods =
109
+ translation.originalMessages.where (_hasArguments).toSet ().toList ();
112
110
for (var original in messagesThatNeedMethods) {
113
111
output
114
112
..write (" " )
@@ -153,22 +151,21 @@ class MessageGeneration {
153
151
// messages from the main program should be duplicated here with the same
154
152
// function name.
155
153
156
- // ignore_for_file: unnecessary_brace_in_string_interps
154
+ // Ignore issues from commonly used lints in this file.
155
+ // ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
156
+ // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
157
+ // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
158
+ // ignore_for_file:unused_import, file_names
157
159
158
160
import 'package:$intlImportPath /intl.dart';
159
161
import 'package:$intlImportPath /message_lookup_by_library.dart';
160
162
$extraImports
161
- // ignore: unnecessary_new
162
163
final messages = new MessageLookup();
163
164
164
- // ignore: unused_element
165
- final _keepAnalysisHappy = Intl.defaultLocale;
166
-
167
- // ignore: non_constant_identifier_names
168
- typedef MessageIfAbsent(String message_str, List<dynamic> args);
165
+ typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
169
166
170
167
class MessageLookup extends MessageLookupByLibrary {
171
- get localeName => '$locale ';
168
+ String get localeName => '$locale ';
172
169
173
170
""" +
174
171
(releaseMode ? overrideLookup : "" );
@@ -185,7 +182,6 @@ class MessageLookup extends MessageLookupByLibrary {
185
182
// If there's no message_str, then we are an internal lookup, e.g. an
186
183
// embedded plural, and shouldn't fail.
187
184
if (message_str == null) return null;
188
- // ignore: unnecessary_new
189
185
throw new UnsupportedError(
190
186
"No translation found for message '\$ name',\\ n"
191
187
" original text '\$ message_str'");
@@ -215,12 +211,11 @@ class MessageLookup extends MessageLookupByLibrary {
215
211
var locale = Intl .canonicalizedLocale (rawLocale);
216
212
var loadOperation = (useDeferredLoading)
217
213
? " '$locale ': ${libraryName (locale )}.loadLibrary,\n "
218
- : "// ignore: unnecessary_new\n "
219
- " '$locale ': () => new Future.value(null),\n " ;
214
+ : " '$locale ': () => new Future.value(null),\n " ;
220
215
output.write (loadOperation);
221
216
}
222
217
output.write ("};\n " );
223
- output.write ("\n MessageLookupByLibrary _findExact(localeName) {\n "
218
+ output.write ("\n MessageLookupByLibrary _findExact(String localeName) {\n "
224
219
" switch (localeName) {\n " );
225
220
for (var rawLocale in allLocales) {
226
221
var locale = Intl .canonicalizedLocale (rawLocale);
@@ -238,11 +233,17 @@ class MessageLookup extends MessageLookupByLibrary {
238
233
// This is a library that looks up messages for specific locales by
239
234
// delegating to the appropriate library.
240
235
236
+ // Ignore issues from commonly used lints in this file.
237
+ // ignore_for_file:implementation_imports, file_names, unnecessary_new
238
+ // ignore_for_file:unnecessary_brace_in_string_interps, directives_ordering
239
+ // ignore_for_file:argument_type_not_assignable, invalid_assignment
240
+ // ignore_for_file:prefer_single_quotes, prefer_generic_function_type_aliases
241
+ // ignore_for_file:comment_references
242
+
241
243
import 'dart:async';
242
244
243
245
import 'package:$intlImportPath /intl.dart';
244
246
import 'package:$intlImportPath /message_lookup_by_library.dart';
245
- // ignore: implementation_imports
246
247
import 'package:$intlImportPath /src/intl_helpers.dart';
247
248
248
249
""" ;
@@ -260,16 +261,12 @@ Future<bool> initializeMessages(String localeName) async {
260
261
(locale) => _deferredLibraries[locale] != null,
261
262
onFailure: (_) => null);
262
263
if (availableLocale == null) {
263
- // ignore: unnecessary_new
264
264
return new Future.value(false);
265
265
}
266
266
var lib = _deferredLibraries[availableLocale];
267
- // ignore: unnecessary_new
268
267
await (lib == null ? new Future.value(false) : lib());
269
- // ignore: unnecessary_new
270
268
initializeInternalMessageLookup(() => new CompositeMessageLookup());
271
269
messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor);
272
- // ignore: unnecessary_new
273
270
return new Future.value(true);
274
271
}
275
272
@@ -281,7 +278,7 @@ bool _messagesExistFor(String locale) {
281
278
}
282
279
}
283
280
284
- MessageLookupByLibrary _findGeneratedMessagesFor(locale) {
281
+ MessageLookupByLibrary _findGeneratedMessagesFor(String locale) {
285
282
var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor,
286
283
onFailure: (_) => null);
287
284
if (actualLocale == null) return null;
@@ -329,8 +326,8 @@ import '${generatedFilePrefix}messages_all.dart' show evaluateJsonTemplate;
329
326
Iterable <TranslatedMessage > usableTranslations, String locale) {
330
327
output.write (r"""
331
328
var _messages;
332
- // ignore: unnecessary_new
333
- get messages => _messages ??= new JsonDecoder().convert(messageText);
329
+ get messages => _messages ??=
330
+ const JsonDecoder().convert(messageText) as Map<String, dynamic> ;
334
331
""" );
335
332
336
333
output.write (" static final messageText = " );
@@ -358,7 +355,7 @@ import '${generatedFilePrefix}messages_all.dart' show evaluateJsonTemplate;
358
355
/// * \[ 'Intl.gender', String gender, (templates for female, male, other)\]
359
356
/// * \[ 'Intl.select', String choice, { 'case' : template, ...} \]
360
357
/// * \[ 'text alternating with ', 0 , ' indexes in the argument list'\]
361
- String evaluateJsonTemplate(Object input, List<dynamic> args) {
358
+ String evaluateJsonTemplate(dynamic input, List<dynamic> args) {
362
359
if (input == null) return null;
363
360
if (input is String) return input;
364
361
if (input is int) {
@@ -398,7 +395,6 @@ String evaluateJsonTemplate(Object input, List<dynamic> args) {
398
395
399
396
// If we get this far, then we are a basic interpolation, just strings and
400
397
// ints.
401
- // ignore: unnecessary_new
402
398
var output = new StringBuffer();
403
399
for (var entry in template) {
404
400
if (entry is int) {
0 commit comments