Unverified Commit 2bf0627d authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Migrate localizations and generate_synthetic_packages to null safety (#83310)

parent 6b6b71ff
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import '../../base/file_system.dart';
import '../../convert.dart';
import '../../localizations/gen_l10n.dart';
......@@ -69,15 +67,19 @@ class GenerateLocalizationsTarget extends Target {
final Map<String, Object> dependencies = json.decode(
environment.buildDir.childFile(_kDependenciesFileName).readAsStringSync()
) as Map<String, Object>;
final List<Object?>? inputs = dependencies['inputs'] as List<Object?>?;
final List<Object?>? outputs = dependencies['outputs'] as List<Object?>?;
final Depfile depfile = Depfile(
<File>[
configFile,
for (dynamic inputFile in dependencies['inputs'] as List<dynamic>)
environment.fileSystem.file(inputFile)
if (inputs != null)
for (Object inputFile in inputs.whereType<Object>())
environment.fileSystem.file(inputFile)
],
<File>[
for (dynamic outputFile in dependencies['outputs'] as List<dynamic>)
environment.fileSystem.file(outputFile)
if (outputs != null)
for (Object outputFile in outputs.whereType<Object>())
environment.fileSystem.file(outputFile)
],
);
depfileService.writeToFile(
......
......@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:meta/meta.dart';
import 'package:yaml/yaml.dart';
import '../base/common.dart';
......@@ -14,8 +11,8 @@ import '../build_system/build_system.dart';
import '../build_system/targets/localizations.dart';
Future<void> generateLocalizationsSyntheticPackage({
@required Environment environment,
@required BuildSystem buildSystem,
required Environment environment,
required BuildSystem buildSystem,
}) async {
assert(environment != null);
assert(buildSystem != null);
......@@ -42,7 +39,7 @@ Future<void> generateLocalizationsSyntheticPackage({
// it.
if (yamlNode.value != null) {
final YamlMap yamlMap = yamlNode as YamlMap;
final Object value = yamlMap['synthetic-package'];
final Object? value = yamlMap['synthetic-package'];
if (value is! bool && value != null) {
throwToolExit(
'Expected "synthetic-package" to have a bool value, '
......@@ -52,8 +49,8 @@ Future<void> generateLocalizationsSyntheticPackage({
// Generate gen_l10n synthetic package only if synthetic-package: true or
// synthetic-package is null.
final bool isSyntheticL10nPackage = value as bool ?? true;
if (!isSyntheticL10nPackage) {
final bool? isSyntheticL10nPackage = value as bool?;
if (isSyntheticL10nPackage == false) {
return;
}
}
......@@ -70,7 +67,7 @@ Future<void> generateLocalizationsSyntheticPackage({
throwToolExit(
'Generating synthetic localizations package failed with ${result.exceptions.length} ${pluralize('error', result.exceptions.length)}:'
'\n\n'
'${result.exceptions.values.map<Object>((ExceptionMeasurement e) => e.exception).join('\n\n')}',
'${result.exceptions.values.map<Object?>((ExceptionMeasurement e) => e.exception).join('\n\n')}',
);
}
}
......@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
......@@ -19,7 +18,7 @@ void main() {
final FileSystem fileSystem = MemoryFileSystem.test();
final Environment environment = Environment.test(
fileSystem.currentDirectory,
artifacts: null,
artifacts: Artifacts.test(),
fileSystem: fileSystem,
logger: BufferLogger.test(),
processManager: FakeProcessManager.any(),
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:async';
......@@ -45,7 +44,7 @@ void main() {
);
final Completer<void> completer = Completer<void>();
final BuildResult exception = BuildResult(success: false, exceptions: <String, ExceptionMeasurement>{
'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), null),
'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), StackTrace.current),
});
final TestBuildSystem buildSystem = TestBuildSystem.all(exception, (Target target, Environment environment) {
expect(target, const GenerateLocalizationsTarget());
......@@ -94,7 +93,7 @@ void main() {
);
final Completer<void> completer = Completer<void>();
final BuildResult exception = BuildResult(success: false, exceptions: <String, ExceptionMeasurement>{
'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), null),
'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), StackTrace.current),
});
final TestBuildSystem buildSystem = TestBuildSystem.all(exception, (Target target, Environment environment) {
expect(target, const GenerateLocalizationsTarget());
......@@ -141,7 +140,7 @@ void main() {
);
final Completer<void> completer = Completer<void>();
final BuildResult exception = BuildResult(success: false, exceptions: <String, ExceptionMeasurement>{
'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), null),
'hello': ExceptionMeasurement('hello', const FormatException('illegal character in input string'), StackTrace.current),
});
final TestBuildSystem buildSystem = TestBuildSystem.all(exception, (Target target, Environment environment) {
expect(target, const GenerateLocalizationsTarget());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment