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