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