vscode_validator.dart 1.16 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
import 'package:process/process.dart';

7 8
import '../base/file_system.dart';
import '../base/platform.dart';
9
import '../base/user_messages.dart';
10
import '../base/version.dart';
11
import '../doctor_validator.dart';
12 13 14
import 'vscode.dart';

class VsCodeValidator extends DoctorValidator {
15 16
  VsCodeValidator(this._vsCode) : super(_vsCode.productName);

17 18
  final VsCode _vsCode;

19
  static Iterable<DoctorValidator> installedValidators(FileSystem fileSystem, Platform platform, ProcessManager processManager) {
20
    return VsCode
21
        .allInstalled(fileSystem, platform, processManager)
22
        .map<DoctorValidator>((VsCode vsCode) => VsCodeValidator(vsCode));
23 24 25 26
  }

  @override
  Future<ValidationResult> validate() async {
27
    final String? vsCodeVersionText = _vsCode.version == Version.unknown
28
        ? null
29
        : userMessages.vsCodeVersion(_vsCode.version.toString());
30 31

    return ValidationResult(
32
      ValidationType.installed,
33
      _vsCode.validationMessages.toList(),
34 35
      statusInfo: vsCodeVersionText,
    );
36 37
  }
}