vscode_validator.dart 1.12 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 '../doctor_validator.dart';
11 12 13
import 'vscode.dart';

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

16 17
  final VsCode _vsCode;

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

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

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