Unverified Commit 30370c9f authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Migrate some workflows and doctor validators to null safety (#79807)

parent bbd58f4d
...@@ -2,10 +2,6 @@ ...@@ -2,10 +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 '../base/config.dart'; import '../base/config.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/platform.dart'; import '../base/platform.dart';
...@@ -16,7 +12,7 @@ import '../intellij/intellij.dart'; ...@@ -16,7 +12,7 @@ import '../intellij/intellij.dart';
import 'android_studio.dart'; import 'android_studio.dart';
class AndroidStudioValidator extends DoctorValidator { class AndroidStudioValidator extends DoctorValidator {
AndroidStudioValidator(this._studio, { @required FileSystem fileSystem }) AndroidStudioValidator(this._studio, { required FileSystem fileSystem })
: _fileSystem = fileSystem, : _fileSystem = fileSystem,
super('Android Studio'); super('Android Studio');
...@@ -40,27 +36,29 @@ class AndroidStudioValidator extends DoctorValidator { ...@@ -40,27 +36,29 @@ class AndroidStudioValidator extends DoctorValidator {
final List<ValidationMessage> messages = <ValidationMessage>[]; final List<ValidationMessage> messages = <ValidationMessage>[];
ValidationType type = ValidationType.missing; ValidationType type = ValidationType.missing;
final String studioVersionText = _studio.version == Version.unknown final String? studioVersionText = _studio.version == Version.unknown
? null ? null
: userMessages.androidStudioVersion(_studio.version.toString()); : userMessages.androidStudioVersion(_studio.version.toString());
messages.add(ValidationMessage( messages.add(ValidationMessage(
userMessages.androidStudioLocation(_studio.directory), userMessages.androidStudioLocation(_studio.directory),
)); ));
final IntelliJPlugins plugins = IntelliJPlugins(_studio.pluginsPath, fileSystem: _fileSystem); if (_studio.pluginsPath != null) {
plugins.validatePackage( final IntelliJPlugins plugins = IntelliJPlugins(_studio.pluginsPath!, fileSystem: _fileSystem);
messages, plugins.validatePackage(
<String>['flutter-intellij', 'flutter-intellij.jar'], messages,
'Flutter', <String>['flutter-intellij', 'flutter-intellij.jar'],
IntelliJPlugins.kIntellijFlutterPluginUrl, 'Flutter',
minVersion: IntelliJPlugins.kMinFlutterPluginVersion, IntelliJPlugins.kIntellijFlutterPluginUrl,
); minVersion: IntelliJPlugins.kMinFlutterPluginVersion,
plugins.validatePackage( );
messages, plugins.validatePackage(
<String>['Dart'], messages,
'Dart', <String>['Dart'],
IntelliJPlugins.kIntellijDartPluginUrl, 'Dart',
); IntelliJPlugins.kIntellijDartPluginUrl,
);
}
if (_studio.isValid) { if (_studio.isValid) {
type = _hasIssues(messages) type = _hasIssues(messages)
...@@ -90,9 +88,9 @@ class AndroidStudioValidator extends DoctorValidator { ...@@ -90,9 +88,9 @@ class AndroidStudioValidator extends DoctorValidator {
class NoAndroidStudioValidator extends DoctorValidator { class NoAndroidStudioValidator extends DoctorValidator {
NoAndroidStudioValidator({ NoAndroidStudioValidator({
@required Config config, required Config config,
@required Platform platform, required Platform platform,
@required UserMessages userMessages, required UserMessages userMessages,
}) : _config = config, }) : _config = config,
_platform = platform, _platform = platform,
_userMessages = userMessages, _userMessages = userMessages,
......
...@@ -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:meta/meta.dart'; import 'package:meta/meta.dart';
import '../doctor_validator.dart'; import '../doctor_validator.dart';
...@@ -18,7 +16,7 @@ import '../features.dart'; ...@@ -18,7 +16,7 @@ import '../features.dart';
@immutable @immutable
class CustomDeviceWorkflow implements Workflow { class CustomDeviceWorkflow implements Workflow {
const CustomDeviceWorkflow({ const CustomDeviceWorkflow({
@required FeatureFlags featureFlags required FeatureFlags featureFlags
}) : _featureFlags = featureFlags; }) : _featureFlags = featureFlags;
final FeatureFlags _featureFlags; final FeatureFlags _featureFlags;
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
// @dart = 2.8 // @dart = 2.8
import 'android/android_sdk.dart';
import 'android/gradle_utils.dart'; import 'android/gradle_utils.dart';
import 'artifacts.dart'; import 'artifacts.dart';
import 'base/bot_detector.dart'; import 'base/bot_detector.dart';
...@@ -51,7 +50,6 @@ CocoaPodsValidator get cocoapodsValidator => context.get<CocoaPodsValidator>(); ...@@ -51,7 +50,6 @@ CocoaPodsValidator get cocoapodsValidator => context.get<CocoaPodsValidator>();
LocalEngineLocator get localEngineLocator => context.get<LocalEngineLocator>(); LocalEngineLocator get localEngineLocator => context.get<LocalEngineLocator>();
AndroidSdk get androidSdk => context.get<AndroidSdk>();
CocoaPods get cocoaPods => context.get<CocoaPods>(); CocoaPods get cocoaPods => context.get<CocoaPods>();
FlutterVersion get flutterVersion => context.get<FlutterVersion>(); FlutterVersion get flutterVersion => context.get<FlutterVersion>();
FuchsiaArtifacts get fuchsiaArtifacts => context.get<FuchsiaArtifacts>(); FuchsiaArtifacts get fuchsiaArtifacts => context.get<FuchsiaArtifacts>();
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'package:process/process.dart'; import 'package:process/process.dart';
import 'android/android_sdk.dart';
import 'android/android_studio.dart'; import 'android/android_studio.dart';
import 'base/config.dart'; import 'base/config.dart';
import 'base/context.dart'; import 'base/context.dart';
...@@ -28,6 +29,7 @@ Logger get logger => context.get<Logger>()!; ...@@ -28,6 +29,7 @@ Logger get logger => context.get<Logger>()!;
OperatingSystemUtils get os => context.get<OperatingSystemUtils>()!; OperatingSystemUtils get os => context.get<OperatingSystemUtils>()!;
Signals get signals => context.get<Signals>() ?? LocalSignals.instance; Signals get signals => context.get<Signals>() ?? LocalSignals.instance;
AndroidStudio? get androidStudio => context.get<AndroidStudio>(); AndroidStudio? get androidStudio => context.get<AndroidStudio>();
AndroidSdk? get androidSdk => context.get<AndroidSdk>();
/// Currently active implementation of the file system. /// Currently active implementation of the file system.
/// ///
......
...@@ -2,10 +2,7 @@ ...@@ -2,10 +2,7 @@
// 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:archive/archive.dart'; import 'package:archive/archive.dart';
import 'package:meta/meta.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/version.dart'; import '../base/version.dart';
...@@ -41,7 +38,7 @@ import '../doctor_validator.dart'; ...@@ -41,7 +38,7 @@ import '../doctor_validator.dart';
/// plugin versions. /// plugin versions.
class IntelliJPlugins { class IntelliJPlugins {
IntelliJPlugins(this.pluginsPath, { IntelliJPlugins(this.pluginsPath, {
@required FileSystem fileSystem required FileSystem fileSystem
}) : _fileSystem = fileSystem; }) : _fileSystem = fileSystem;
final FileSystem _fileSystem; final FileSystem _fileSystem;
...@@ -56,15 +53,15 @@ class IntelliJPlugins { ...@@ -56,15 +53,15 @@ class IntelliJPlugins {
List<String> packageNames, List<String> packageNames,
String title, String title,
String url, { String url, {
Version minVersion, Version? minVersion,
}) { }) {
for (final String packageName in packageNames) { for (final String packageName in packageNames) {
if (!_hasPackage(packageName)) { if (!_hasPackage(packageName)) {
continue; continue;
} }
final String versionText = _readPackageVersion(packageName); final String? versionText = _readPackageVersion(packageName);
final Version version = Version.parse(versionText); final Version? version = Version.parse(versionText);
if (version != null && minVersion != null && version < minVersion) { if (version != null && minVersion != null && version < minVersion) {
messages.add(ValidationMessage.error( messages.add(ValidationMessage.error(
'$title plugin version $versionText - the recommended minimum version is $minVersion'), '$title plugin version $versionText - the recommended minimum version is $minVersion'),
...@@ -90,7 +87,7 @@ class IntelliJPlugins { ...@@ -90,7 +87,7 @@ class IntelliJPlugins {
return _fileSystem.isDirectorySync(packagePath); return _fileSystem.isDirectorySync(packagePath);
} }
ArchiveFile _findPluginXml(String packageName) { ArchiveFile? _findPluginXml(String packageName) {
final List<File> mainJarFileList = <File>[]; final List<File> mainJarFileList = <File>[];
if (packageName.endsWith('.jar')) { if (packageName.endsWith('.jar')) {
// package exists (checked in _hasPackage) // package exists (checked in _hasPackage)
...@@ -131,7 +128,7 @@ class IntelliJPlugins { ...@@ -131,7 +128,7 @@ class IntelliJPlugins {
for (final File file in mainJarFileList) { for (final File file in mainJarFileList) {
final Archive archive = ZipDecoder().decodeBytes(file.readAsBytesSync()); final Archive archive = ZipDecoder().decodeBytes(file.readAsBytesSync());
final ArchiveFile archiveFile = archive.findFile('META-INF/plugin.xml'); final ArchiveFile? archiveFile = archive.findFile('META-INF/plugin.xml');
if (archiveFile != null) { if (archiveFile != null) {
return archiveFile; return archiveFile;
} }
...@@ -139,9 +136,9 @@ class IntelliJPlugins { ...@@ -139,9 +136,9 @@ class IntelliJPlugins {
return null; return null;
} }
String _readPackageVersion(String packageName) { String? _readPackageVersion(String packageName) {
try { try {
final ArchiveFile archiveFile = _findPluginXml(packageName); final ArchiveFile? archiveFile = _findPluginXml(packageName);
if (archiveFile == null) { if (archiveFile == null) {
return null; return null;
} }
......
...@@ -2,10 +2,6 @@ ...@@ -2,10 +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 '../base/platform.dart'; import '../base/platform.dart';
import '../doctor_validator.dart'; import '../doctor_validator.dart';
import '../features.dart'; import '../features.dart';
...@@ -16,8 +12,8 @@ import '../features.dart'; ...@@ -16,8 +12,8 @@ import '../features.dart';
/// repository to the flutter repo. /// repository to the flutter repo.
class LinuxWorkflow implements Workflow { class LinuxWorkflow implements Workflow {
const LinuxWorkflow({ const LinuxWorkflow({
@required Platform platform, required Platform platform,
@required FeatureFlags featureFlags, required FeatureFlags featureFlags,
}) : _platform = platform, }) : _platform = platform,
_featureFlags = featureFlags; _featureFlags = featureFlags;
......
...@@ -2,20 +2,15 @@ ...@@ -2,20 +2,15 @@
// 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 '../base/platform.dart'; import '../base/platform.dart';
import '../doctor_validator.dart'; import '../doctor_validator.dart';
import '../features.dart'; import '../features.dart';
/// The macOS-specific implementation of a [Workflow]. /// The macOS-specific implementation of a [Workflow].
class MacOSWorkflow implements Workflow { class MacOSWorkflow implements Workflow {
const MacOSWorkflow({ const MacOSWorkflow({
@required Platform platform, required Platform platform,
@required FeatureFlags featureFlags, required FeatureFlags featureFlags,
}) : _platform = platform, }) : _platform = platform,
_featureFlags = featureFlags; _featureFlags = featureFlags;
......
...@@ -2,10 +2,6 @@ ...@@ -2,10 +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 'base/platform.dart'; import 'base/platform.dart';
import 'doctor_validator.dart'; import 'doctor_validator.dart';
...@@ -15,7 +11,7 @@ import 'doctor_validator.dart'; ...@@ -15,7 +11,7 @@ import 'doctor_validator.dart';
/// validated along with `NO_PROXY`. /// validated along with `NO_PROXY`.
class ProxyValidator extends DoctorValidator { class ProxyValidator extends DoctorValidator {
ProxyValidator({ ProxyValidator({
@required Platform platform, required Platform platform,
}) : shouldShow = _getEnv('HTTP_PROXY', platform).isNotEmpty, }) : shouldShow = _getEnv('HTTP_PROXY', platform).isNotEmpty,
_httpProxy = _getEnv('HTTP_PROXY', platform), _httpProxy = _getEnv('HTTP_PROXY', platform),
_noProxy = _getEnv('NO_PROXY', platform), _noProxy = _getEnv('NO_PROXY', platform),
......
...@@ -2,18 +2,14 @@ ...@@ -2,18 +2,14 @@
// 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 '../base/platform.dart'; import '../base/platform.dart';
import '../doctor_validator.dart'; import '../doctor_validator.dart';
import '../features.dart'; import '../features.dart';
class WebWorkflow extends Workflow { class WebWorkflow extends Workflow {
const WebWorkflow({ const WebWorkflow({
@required Platform platform, required Platform platform,
@required FeatureFlags featureFlags, required FeatureFlags featureFlags,
}) : _platform = platform, }) : _platform = platform,
_featureFlags = featureFlags; _featureFlags = featureFlags;
......
...@@ -2,21 +2,17 @@ ...@@ -2,21 +2,17 @@
// 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 '../base/context.dart'; import '../base/context.dart';
import '../base/user_messages.dart' hide userMessages; import '../base/user_messages.dart' hide userMessages;
import '../doctor_validator.dart'; import '../doctor_validator.dart';
import 'visual_studio.dart'; import 'visual_studio.dart';
VisualStudioValidator get visualStudioValidator => context.get<VisualStudioValidator>(); VisualStudioValidator? get visualStudioValidator => context.get<VisualStudioValidator>();
class VisualStudioValidator extends DoctorValidator { class VisualStudioValidator extends DoctorValidator {
const VisualStudioValidator({ const VisualStudioValidator({
@required VisualStudio visualStudio, required VisualStudio visualStudio,
@required UserMessages userMessages, required UserMessages userMessages,
}) : _visualStudio = visualStudio, }) : _visualStudio = visualStudio,
_userMessages = userMessages, _userMessages = userMessages,
super('Visual Studio - develop for Windows'); super('Visual Studio - develop for Windows');
...@@ -28,7 +24,7 @@ class VisualStudioValidator extends DoctorValidator { ...@@ -28,7 +24,7 @@ class VisualStudioValidator extends DoctorValidator {
Future<ValidationResult> validate() async { Future<ValidationResult> validate() async {
final List<ValidationMessage> messages = <ValidationMessage>[]; final List<ValidationMessage> messages = <ValidationMessage>[];
ValidationType status = ValidationType.missing; ValidationType status = ValidationType.missing;
String versionInfo; String? versionInfo;
if (_visualStudio.isInstalled) { if (_visualStudio.isInstalled) {
status = ValidationType.installed; status = ValidationType.installed;
...@@ -46,7 +42,7 @@ class VisualStudioValidator extends DoctorValidator { ...@@ -46,7 +42,7 @@ class VisualStudioValidator extends DoctorValidator {
messages.add(ValidationMessage(_userMessages.visualStudioIsPrerelease)); messages.add(ValidationMessage(_userMessages.visualStudioIsPrerelease));
} }
final String windows10SdkVersion = _visualStudio.getWindows10SDKVersion(); final String? windows10SdkVersion = _visualStudio.getWindows10SDKVersion();
if (windows10SdkVersion != null) { if (windows10SdkVersion != null) {
messages.add(ValidationMessage(_userMessages.windows10SdkVersion(windows10SdkVersion))); messages.add(ValidationMessage(_userMessages.windows10SdkVersion(windows10SdkVersion)));
} }
......
...@@ -2,17 +2,13 @@ ...@@ -2,17 +2,13 @@
// 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 '../base/context.dart'; import '../base/context.dart';
import '../base/platform.dart'; import '../base/platform.dart';
import '../doctor_validator.dart'; import '../doctor_validator.dart';
import '../features.dart'; import '../features.dart';
/// The [WindowsWorkflow] instance. /// The [WindowsWorkflow] instance.
WindowsWorkflow get windowsWorkflow => context.get<WindowsWorkflow>(); WindowsWorkflow? get windowsWorkflow => context.get<WindowsWorkflow>();
/// The Windows-specific implementation of a [Workflow]. /// The Windows-specific implementation of a [Workflow].
/// ///
...@@ -20,8 +16,8 @@ WindowsWorkflow get windowsWorkflow => context.get<WindowsWorkflow>(); ...@@ -20,8 +16,8 @@ WindowsWorkflow get windowsWorkflow => context.get<WindowsWorkflow>();
/// desktop configuration setting to be enabled. /// desktop configuration setting to be enabled.
class WindowsWorkflow implements Workflow { class WindowsWorkflow implements Workflow {
const WindowsWorkflow({ const WindowsWorkflow({
@required Platform platform, required Platform platform,
@required FeatureFlags featureFlags, required FeatureFlags featureFlags,
}) : _platform = platform, }) : _platform = platform,
_featureFlags = featureFlags; _featureFlags = featureFlags;
......
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