Unverified Commit 0bde67e7 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Migrate flutter_tool tool helper files to null safety (#78845)

parent b921a244
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
final RegExp _whitespace = RegExp(r'\s+'); final RegExp _whitespace = RegExp(r'\s+');
/// Convert adb device names into more human readable descriptions. /// Convert adb device names into more human readable descriptions.
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
const int minApiLevel = 16; const int minApiLevel = 16;
const String minVersionName = 'Jelly Bean'; const String minVersionName = 'Jelly Bean';
const String minVersionText = '4.1.x'; const String minVersionText = '4.1.x';
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
/// An indirection around our mustache templating system to avoid a /// An indirection around our mustache templating system to avoid a
/// dependency on mustache.. /// dependency on mustache..
abstract class TemplateRenderer { abstract class TemplateRenderer {
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'context.dart'; import 'context.dart';
import 'platform.dart'; import 'platform.dart';
...@@ -16,7 +14,7 @@ class UserMessages { ...@@ -16,7 +14,7 @@ class UserMessages {
'Please report a bug at https://github.com/flutter/flutter/issues.'; 'Please report a bug at https://github.com/flutter/flutter/issues.';
// Messages used in FlutterValidator // Messages used in FlutterValidator
String flutterStatusInfo(String channel, String version, String os, String locale) => String flutterStatusInfo(String? channel, String? version, String os, String locale) =>
'Channel ${channel ?? 'unknown'}, ${version ?? 'Unknown'}, on $os, locale $locale'; 'Channel ${channel ?? 'unknown'}, ${version ?? 'Unknown'}, on $os, locale $locale';
String flutterVersion(String version, String flutterRoot) => String flutterVersion(String version, String flutterRoot) =>
'Flutter version $version at $flutterRoot'; 'Flutter version $version at $flutterRoot';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:typed_data'; import 'dart:typed_data';
/// Data from a non-linear mathematical function that functions as /// Data from a non-linear mathematical function that functions as
...@@ -51,7 +49,7 @@ class Md5Hash { ...@@ -51,7 +49,7 @@ class Md5Hash {
int _remainingLength = 0; int _remainingLength = 0;
int _contentLength = 0; int _contentLength = 0;
void addChunk(Uint8List data, [int stop]) { void addChunk(Uint8List data, [int? stop]) {
assert(_remainingLength == 0); assert(_remainingLength == 0);
stop ??= data.length; stop ??= data.length;
int i = 0; int i = 0;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:mustache_template/mustache_template.dart'; import 'package:mustache_template/mustache_template.dart';
import '../base/template.dart'; import '../base/template.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
const String emptyPubspecTemplate = ''' const String emptyPubspecTemplate = '''
# Generated by the flutter tool # Generated by the flutter tool
name: synthetic_package name: synthetic_package
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
/// Cache of https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry. /// Cache of https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry.
const String languageSubtagRegistry = ''' const String languageSubtagRegistry = '''
File-Date: 2020-03-16 File-Date: 2020-03-16
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'test_device.dart'; import 'test_device.dart';
/// Callbacks for reporting progress while running tests. /// Callbacks for reporting progress while running tests.
......
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:meta/meta.dart';
import 'package:package_config/package_config.dart'; import 'package:package_config/package_config.dart';
/// The JavaScript bootstrap script to support in-browser hot restart. /// The JavaScript bootstrap script to support in-browser hot restart.
...@@ -17,8 +14,8 @@ import 'package:package_config/package_config.dart'; ...@@ -17,8 +14,8 @@ import 'package:package_config/package_config.dart';
/// and is responsible for bootstrapping the RequireJS modules and attaching /// and is responsible for bootstrapping the RequireJS modules and attaching
/// the hot reload hooks. /// the hot reload hooks.
String generateBootstrapScript({ String generateBootstrapScript({
@required String requireUrl, required String requireUrl,
@required String mapperUrl, required String mapperUrl,
}) { }) {
return ''' return '''
"use strict"; "use strict";
...@@ -54,9 +51,9 @@ document.head.appendChild(requireEl); ...@@ -54,9 +51,9 @@ document.head.appendChild(requireEl);
/// `foo__bar__baz`. Rather than attempt to guess, we assume the first property of /// `foo__bar__baz`. Rather than attempt to guess, we assume the first property of
/// this object is the module. /// this object is the module.
String generateMainModule({ String generateMainModule({
@required String entrypoint, required String entrypoint,
@required bool nullAssertions, required bool nullAssertions,
@required bool nativeNullAssertions, required bool nativeNullAssertions,
String bootstrapModule = 'main_module.bootstrap', String bootstrapModule = 'main_module.bootstrap',
}) { }) {
// TODO(jonahwilliams): fix typo in dwds and update. // TODO(jonahwilliams): fix typo in dwds and update.
...@@ -102,10 +99,10 @@ define("$bootstrapModule", ["$entrypoint", "dart_sdk"], function(app, dart_sdk) ...@@ -102,10 +99,10 @@ define("$bootstrapModule", ["$entrypoint", "dart_sdk"], function(app, dart_sdk)
/// ///
/// This hard-codes the device pixel ratio to 3.0 and a 2400 x 1800 window size. /// This hard-codes the device pixel ratio to 3.0 and a 2400 x 1800 window size.
String generateTestEntrypoint({ String generateTestEntrypoint({
@required String relativeTestPath, required String relativeTestPath,
@required String absolutePath, required String absolutePath,
@required String testConfigPath, required String testConfigPath,
@required LanguageVersion languageVersion, required LanguageVersion languageVersion,
}) { }) {
return ''' return '''
// @dart = ${languageVersion.major}.${languageVersion.minor} // @dart = ${languageVersion.major}.${languageVersion.minor}
......
...@@ -2,14 +2,12 @@ ...@@ -2,14 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/common.dart';
Process daemon; late Process daemon;
// To use, start from the console and enter: // To use, start from the console and enter:
// version: print version // version: print version
...@@ -85,7 +83,7 @@ Future<void> main() async { ...@@ -85,7 +83,7 @@ Future<void> main() async {
}); });
// Print in the callback can't fail. // Print in the callback can't fail.
unawaited(daemon.exitCode.then<void>((int code) { unawaited(daemon.exitCode.then<int>((int code) {
print('daemon exiting ($code)'); print('daemon exiting ($code)');
exit(code); exit(code);
})); }));
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:io'; import 'dart:io';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
...@@ -27,7 +25,7 @@ int countGlobalImports(Directory directory) { ...@@ -27,7 +25,7 @@ int countGlobalImports(Directory directory) {
if (!file.path.endsWith('.dart') || file is! File) { if (!file.path.endsWith('.dart') || file is! File) {
continue; continue;
} }
final bool hasImport = (file as File).readAsLinesSync().any((String line) { final bool hasImport = file.readAsLinesSync().any((String line) {
return globalImport.hasMatch(line); return globalImport.hasMatch(line);
}); });
if (hasImport) { if (hasImport) {
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:io'; import 'dart:io';
/// Produces a per-library coverage summary when fed an lcov file, sorted by /// Produces a per-library coverage summary when fed an lcov file, sorted by
...@@ -17,7 +15,7 @@ void main(List<String> args) { ...@@ -17,7 +15,7 @@ void main(List<String> args) {
} }
final List<String> lines = File(args.single).readAsLinesSync(); final List<String> lines = File(args.single).readAsLinesSync();
final List<Coverage> coverages = <Coverage>[]; final List<Coverage> coverages = <Coverage>[];
Coverage currentCoverage; Coverage? currentCoverage;
for (final String line in lines) { for (final String line in lines) {
if (line.startsWith('SF:')) { if (line.startsWith('SF:')) {
...@@ -26,9 +24,9 @@ void main(List<String> args) { ...@@ -26,9 +24,9 @@ void main(List<String> args) {
coverages.add(currentCoverage); coverages.add(currentCoverage);
} }
if (line.startsWith('DA')) { if (line.startsWith('DA')) {
currentCoverage.totalLines += 1; currentCoverage?.totalLines += 1;
if (!line.endsWith(',0')) { if (!line.endsWith(',0')) {
currentCoverage.testedLines += 1; currentCoverage?.testedLines += 1;
} }
} }
if (line == 'end_of_record') { if (line == 'end_of_record') {
...@@ -53,7 +51,7 @@ void main(List<String> args) { ...@@ -53,7 +51,7 @@ void main(List<String> args) {
} }
class Coverage { class Coverage {
String library; String? library;
int totalLines = 0; int totalLines = 0;
int testedLines = 0; int testedLines = 0;
} }
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