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

This commit is contained in:
Jenn Magder 2021-03-23 10:02:59 -07:00 committed by GitHub
parent b921a2443f
commit 0bde67e734
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 18 additions and 47 deletions

View file

@ -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
final RegExp _whitespace = RegExp(r'\s+');
/// Convert adb device names into more human readable descriptions.

View file

@ -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
const int minApiLevel = 16;
const String minVersionName = 'Jelly Bean';
const String minVersionText = '4.1.x';

View file

@ -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
/// An indirection around our mustache templating system to avoid a
/// dependency on mustache..
abstract class TemplateRenderer {

View file

@ -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 'context.dart';
import 'platform.dart';
@ -16,7 +14,7 @@ class UserMessages {
'Please report a bug at https://github.com/flutter/flutter/issues.';
// 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';
String flutterVersion(String version, String flutterRoot) =>
'Flutter version $version at $flutterRoot';

View file

@ -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 'dart:typed_data';
/// Data from a non-linear mathematical function that functions as
@ -51,7 +49,7 @@ class Md5Hash {
int _remainingLength = 0;
int _contentLength = 0;
void addChunk(Uint8List data, [int stop]) {
void addChunk(Uint8List data, [int? stop]) {
assert(_remainingLength == 0);
stop ??= data.length;
int i = 0;

View file

@ -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 'package:mustache_template/mustache_template.dart';
import '../base/template.dart';

View file

@ -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
const String emptyPubspecTemplate = '''
# Generated by the flutter tool
name: synthetic_package

View file

@ -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
/// Cache of https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry.
const String languageSubtagRegistry = '''
File-Date: 2020-03-16

View file

@ -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 'dart:async';
import 'package:meta/meta.dart';

View file

@ -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 'test_device.dart';
/// Callbacks for reporting progress while running tests.

View file

@ -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:package_config/package_config.dart';
/// The JavaScript bootstrap script to support in-browser hot restart.
@ -17,8 +14,8 @@ import 'package:package_config/package_config.dart';
/// and is responsible for bootstrapping the RequireJS modules and attaching
/// the hot reload hooks.
String generateBootstrapScript({
@required String requireUrl,
@required String mapperUrl,
required String requireUrl,
required String mapperUrl,
}) {
return '''
"use strict";
@ -54,9 +51,9 @@ document.head.appendChild(requireEl);
/// `foo__bar__baz`. Rather than attempt to guess, we assume the first property of
/// this object is the module.
String generateMainModule({
@required String entrypoint,
@required bool nullAssertions,
@required bool nativeNullAssertions,
required String entrypoint,
required bool nullAssertions,
required bool nativeNullAssertions,
String bootstrapModule = 'main_module.bootstrap',
}) {
// TODO(jonahwilliams): fix typo in dwds and update.
@ -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.
String generateTestEntrypoint({
@required String relativeTestPath,
@required String absolutePath,
@required String testConfigPath,
@required LanguageVersion languageVersion,
required String relativeTestPath,
required String absolutePath,
required String testConfigPath,
required LanguageVersion languageVersion,
}) {
return '''
// @dart = ${languageVersion.major}.${languageVersion.minor}

View file

@ -2,14 +2,12 @@
// 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:convert';
import 'dart:io';
import 'package:flutter_tools/src/base/common.dart';
Process daemon;
late Process daemon;
// To use, start from the console and enter:
// version: print version
@ -85,7 +83,7 @@ Future<void> main() async {
});
// 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)');
exit(code);
}));

View file

@ -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 'dart:io';
import 'package:path/path.dart' as path;
@ -27,7 +25,7 @@ int countGlobalImports(Directory directory) {
if (!file.path.endsWith('.dart') || file is! File) {
continue;
}
final bool hasImport = (file as File).readAsLinesSync().any((String line) {
final bool hasImport = file.readAsLinesSync().any((String line) {
return globalImport.hasMatch(line);
});
if (hasImport) {

View file

@ -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 'dart:io';
/// Produces a per-library coverage summary when fed an lcov file, sorted by
@ -17,7 +15,7 @@ void main(List<String> args) {
}
final List<String> lines = File(args.single).readAsLinesSync();
final List<Coverage> coverages = <Coverage>[];
Coverage currentCoverage;
Coverage? currentCoverage;
for (final String line in lines) {
if (line.startsWith('SF:')) {
@ -26,9 +24,9 @@ void main(List<String> args) {
coverages.add(currentCoverage);
}
if (line.startsWith('DA')) {
currentCoverage.totalLines += 1;
currentCoverage?.totalLines += 1;
if (!line.endsWith(',0')) {
currentCoverage.testedLines += 1;
currentCoverage?.testedLines += 1;
}
}
if (line == 'end_of_record') {
@ -53,7 +51,7 @@ void main(List<String> args) {
}
class Coverage {
String library;
String? library;
int totalLines = 0;
int testedLines = 0;
}