mirror of
https://github.com/flutter/flutter
synced 2024-08-25 02:46:31 +00:00
Remove duplicate global declaration of UserMessages
(#142281)
Fixes https://github.com/flutter/flutter/issues/142286 This is a refactor. No code behavior changes should be observed.
This commit is contained in:
parent
6d436dfaa5
commit
69c98bd960
|
@ -11,7 +11,7 @@ import '../base/context.dart';
|
|||
import '../base/io.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/user_messages.dart' hide userMessages;
|
||||
import '../base/user_messages.dart';
|
||||
import '../base/version.dart';
|
||||
import '../convert.dart';
|
||||
import '../doctor_validator.dart';
|
||||
|
|
|
@ -2,18 +2,14 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'context.dart';
|
||||
import 'platform.dart';
|
||||
|
||||
/// Contains messages produced by Flutter tools.
|
||||
/// Class containing some message strings that can be produced by Flutter tools.
|
||||
//
|
||||
// This allows partial reimplementations of the flutter tool to override
|
||||
// certain messages.
|
||||
// TODO(andrewkolos): It is unclear if this is worth keeping. See
|
||||
// https://github.com/flutter/flutter/issues/125155.
|
||||
UserMessages get userMessages => context.get<UserMessages>()!;
|
||||
|
||||
/// Class containing message strings that can be produced by Flutter tools.
|
||||
class UserMessages {
|
||||
// Messages used in multiple components.
|
||||
String get flutterToolBugInstructions =>
|
||||
|
@ -211,11 +207,6 @@ class UserMessages {
|
|||
'$consequence\n'
|
||||
'To re-install $reinstallInstructions';
|
||||
|
||||
// Messages used in VsCodeValidator
|
||||
String vsCodeVersion(String version) => 'version $version';
|
||||
String vsCodeLocation(String location) => 'VS Code at $location';
|
||||
String vsCodeFlutterExtensionMissing(String url) => 'Flutter extension not installed; install from\n$url';
|
||||
|
||||
// Messages used in VisualStudioValidator
|
||||
String visualStudioVersion(String name, String version) => '$name version $version';
|
||||
String visualStudioLocation(String location) => 'Visual Studio at $location';
|
||||
|
|
|
@ -278,7 +278,7 @@ Future<T> runInContext<T>(
|
|||
processManager: globals.processManager
|
||||
),
|
||||
LocalEngineLocator: () => LocalEngineLocator(
|
||||
userMessages: userMessages,
|
||||
userMessages: globals.userMessages,
|
||||
logger: globals.logger,
|
||||
platform: globals.platform,
|
||||
fileSystem: globals.fs,
|
||||
|
|
|
@ -119,7 +119,7 @@ class _DefaultDoctorValidatorsProvider implements DoctorValidatorsProvider {
|
|||
...IntelliJValidator.installedValidators(
|
||||
fileSystem: globals.fs,
|
||||
platform: platform,
|
||||
userMessages: userMessages,
|
||||
userMessages: globals.userMessages,
|
||||
plistParser: globals.plistParser,
|
||||
processManager: globals.processManager,
|
||||
logger: _logger,
|
||||
|
@ -134,7 +134,7 @@ class _DefaultDoctorValidatorsProvider implements DoctorValidatorsProvider {
|
|||
flutterVersion: () => globals.flutterVersion.fetchTagsAndGetVersion(clock: globals.systemClock),
|
||||
devToolsVersion: () => globals.cache.devToolsVersion,
|
||||
processManager: globals.processManager,
|
||||
userMessages: userMessages,
|
||||
userMessages: globals.userMessages,
|
||||
artifacts: globals.artifacts!,
|
||||
flutterRoot: () => Cache.flutterRoot!,
|
||||
operatingSystemUtils: globals.os,
|
||||
|
@ -150,7 +150,7 @@ class _DefaultDoctorValidatorsProvider implements DoctorValidatorsProvider {
|
|||
GroupedValidator(<DoctorValidator>[
|
||||
XcodeValidator(
|
||||
xcode: globals.xcode!,
|
||||
userMessages: userMessages,
|
||||
userMessages: globals.userMessages,
|
||||
iosSimulatorUtils: globals.iosSimulatorUtils!,
|
||||
),
|
||||
globals.cocoapodsValidator!,
|
||||
|
@ -170,7 +170,7 @@ class _DefaultDoctorValidatorsProvider implements DoctorValidatorsProvider {
|
|||
if (linuxWorkflow.appliesToHostPlatform)
|
||||
LinuxDoctorValidator(
|
||||
processManager: globals.processManager,
|
||||
userMessages: userMessages,
|
||||
userMessages: globals.userMessages,
|
||||
),
|
||||
if (windowsWorkflow!.appliesToHostPlatform)
|
||||
visualStudioValidator!,
|
||||
|
|
|
@ -9,8 +9,8 @@ import 'package:yaml/yaml.dart';
|
|||
import 'base/deferred_component.dart';
|
||||
import 'base/file_system.dart';
|
||||
import 'base/logger.dart';
|
||||
import 'base/user_messages.dart';
|
||||
import 'base/utils.dart';
|
||||
import 'globals.dart' as globals;
|
||||
import 'plugins.dart';
|
||||
|
||||
/// Whether or not Impeller Scene 3D model import is enabled.
|
||||
|
@ -103,7 +103,7 @@ class FlutterManifest {
|
|||
version = Version.parse(verStr);
|
||||
} on Exception {
|
||||
if (!_hasShowInvalidVersionMsg) {
|
||||
_logger.printStatus(userMessages.invalidVersionSettingHintMessage(verStr), emphasis: true);
|
||||
_logger.printStatus(globals.userMessages.invalidVersionSettingHintMessage(verStr), emphasis: true);
|
||||
_hasShowInvalidVersionMsg = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import '../base/file_system.dart';
|
|||
import '../base/io.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/user_messages.dart' hide userMessages;
|
||||
import '../base/user_messages.dart';
|
||||
import '../base/version.dart';
|
||||
import '../convert.dart';
|
||||
import '../doctor_validator.dart';
|
||||
|
|
|
@ -15,7 +15,6 @@ import '../base/context.dart';
|
|||
import '../base/io.dart' as io;
|
||||
import '../base/io.dart';
|
||||
import '../base/os.dart';
|
||||
import '../base/user_messages.dart';
|
||||
import '../base/utils.dart';
|
||||
import '../build_info.dart';
|
||||
import '../build_system/build_system.dart';
|
||||
|
@ -1398,7 +1397,7 @@ abstract class FlutterCommand extends Command<void> {
|
|||
commandResult = await verifyThenRunCommand(commandPath);
|
||||
} finally {
|
||||
final DateTime endTime = globals.systemClock.now();
|
||||
globals.printTrace(userMessages.flutterElapsedTime(name, getElapsedAsMilliseconds(endTime.difference(startTime))));
|
||||
globals.printTrace(globals.userMessages.flutterElapsedTime(name, getElapsedAsMilliseconds(endTime.difference(startTime))));
|
||||
if (commandPath != null) {
|
||||
_sendPostUsage(
|
||||
commandPath,
|
||||
|
@ -1825,7 +1824,7 @@ Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and
|
|||
return null;
|
||||
}
|
||||
if (deviceList.length > 1) {
|
||||
globals.printStatus(userMessages.flutterSpecifyDevice);
|
||||
globals.printStatus(globals.userMessages.flutterSpecifyDevice);
|
||||
deviceList = await globals.deviceManager!.getAllDevices();
|
||||
globals.printStatus('');
|
||||
await Device.printDevices(deviceList, globals.logger);
|
||||
|
@ -1844,7 +1843,7 @@ Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and
|
|||
// until one can be found.
|
||||
final String? path = findProjectRoot(globals.fs, globals.fs.currentDirectory.path);
|
||||
if (path == null) {
|
||||
throwToolExit(userMessages.flutterNoPubspec);
|
||||
throwToolExit(globals.userMessages.flutterNoPubspec);
|
||||
}
|
||||
if (path != globals.fs.currentDirectory.path) {
|
||||
globals.fs.currentDirectory = path;
|
||||
|
@ -1855,7 +1854,7 @@ Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and
|
|||
if (_usesTargetOption) {
|
||||
final String targetPath = targetFile;
|
||||
if (!globals.fs.isFileSync(targetPath)) {
|
||||
throw ToolExit(userMessages.flutterTargetFileMissing(targetPath));
|
||||
throw ToolExit(globals.userMessages.flutterTargetFileMissing(targetPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import '../base/common.dart';
|
|||
import '../base/context.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/terminal.dart';
|
||||
import '../base/user_messages.dart';
|
||||
import '../base/utils.dart';
|
||||
import '../cache.dart';
|
||||
import '../convert.dart';
|
||||
|
@ -251,10 +250,10 @@ class FlutterCommandRunner extends CommandRunner<void> {
|
|||
try {
|
||||
wrapColumn = int.parse(topLevelResults[FlutterGlobalOptions.kWrapColumnOption] as String);
|
||||
if (wrapColumn < 0) {
|
||||
throwToolExit(userMessages.runnerWrapColumnInvalid(topLevelResults[FlutterGlobalOptions.kWrapColumnOption]));
|
||||
throwToolExit(globals.userMessages.runnerWrapColumnInvalid(topLevelResults[FlutterGlobalOptions.kWrapColumnOption]));
|
||||
}
|
||||
} on FormatException {
|
||||
throwToolExit(userMessages.runnerWrapColumnParseError(topLevelResults[FlutterGlobalOptions.kWrapColumnOption]));
|
||||
throwToolExit(globals.userMessages.runnerWrapColumnParseError(topLevelResults[FlutterGlobalOptions.kWrapColumnOption]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import '../base/common.dart';
|
|||
import '../base/file_system.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/user_messages.dart' hide userMessages;
|
||||
import '../base/user_messages.dart';
|
||||
import '../cache.dart';
|
||||
import '../dart/package_map.dart';
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import '../base/common.dart';
|
|||
import '../base/logger.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/terminal.dart';
|
||||
import '../base/user_messages.dart';
|
||||
import '../device.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../ios/devices.dart';
|
||||
|
@ -151,7 +150,7 @@ class TargetDevices {
|
|||
bool includeDevicesUnsupportedByProject = false,
|
||||
}) async {
|
||||
if (!globals.doctor!.canLaunchAnything) {
|
||||
_logger.printError(userMessages.flutterNoDevelopmentDevice);
|
||||
_logger.printError(globals.userMessages.flutterNoDevelopmentDevice);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -215,7 +214,7 @@ class TargetDevices {
|
|||
|
||||
_logger.printStatus(_deviceManager.hasSpecifiedAllDevices
|
||||
? _noDevicesFoundMessage
|
||||
: userMessages.flutterNoSupportedDevices);
|
||||
: globals.userMessages.flutterNoSupportedDevices);
|
||||
await _printUnsupportedDevice(unsupportedDevices);
|
||||
return null;
|
||||
}
|
||||
|
@ -272,7 +271,7 @@ class TargetDevices {
|
|||
supportFilter: DeviceDiscoverySupportFilter.excludeDevicesUnsupportedByFlutter(),
|
||||
);
|
||||
|
||||
_logger.printStatus(userMessages.flutterSpecifyDeviceWithAllOption);
|
||||
_logger.printStatus(globals.userMessages.flutterSpecifyDeviceWithAllOption);
|
||||
_logger.printStatus('');
|
||||
}
|
||||
|
||||
|
@ -336,7 +335,7 @@ class TargetDevices {
|
|||
'\n',
|
||||
);
|
||||
result.writeln();
|
||||
result.writeln(userMessages.flutterMissPlatformProjects(
|
||||
result.writeln(globals.userMessages.flutterMissPlatformProjects(
|
||||
Device.devicesPlatformTypes(unsupportedDevices),
|
||||
));
|
||||
_logger.printStatus(result.toString(), newline: false);
|
||||
|
@ -461,7 +460,7 @@ class TargetDevicesWithExtendedWirelessDeviceDiscovery extends TargetDevices {
|
|||
bool includeDevicesUnsupportedByProject = false,
|
||||
}) async {
|
||||
if (!globals.doctor!.canLaunchAnything) {
|
||||
_logger.printError(userMessages.flutterNoDevelopmentDevice);
|
||||
_logger.printError(globals.userMessages.flutterNoDevelopmentDevice);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import 'package:process/process.dart';
|
|||
|
||||
import '../base/file_system.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/user_messages.dart';
|
||||
import '../doctor_validator.dart';
|
||||
import 'vscode.dart';
|
||||
|
||||
|
@ -27,8 +26,8 @@ class VsCodeValidator extends DoctorValidator {
|
|||
List<ValidationMessage>.from(_vsCode.validationMessages);
|
||||
|
||||
final String vsCodeVersionText = _vsCode.version == null
|
||||
? userMessages.vsCodeVersion('unknown')
|
||||
: userMessages.vsCodeVersion(_vsCode.version.toString());
|
||||
? 'version unknown'
|
||||
: 'version ${_vsCode.version}';
|
||||
|
||||
if (_vsCode.version == null) {
|
||||
validationMessages.add(const ValidationMessage.error('Unable to determine VS Code version.'));
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
import '../base/context.dart';
|
||||
import '../base/user_messages.dart' hide userMessages;
|
||||
import '../base/user_messages.dart';
|
||||
import '../doctor_validator.dart';
|
||||
import 'visual_studio.dart';
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import 'package:flutter_tools/src/base/io.dart';
|
|||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
import 'package:flutter_tools/src/base/user_messages.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/daemon.dart';
|
||||
|
@ -419,7 +418,7 @@ void main() {
|
|||
expect(
|
||||
testLogger.statusText,
|
||||
containsIgnoringWhitespace(
|
||||
userMessages.flutterMissPlatformProjects(
|
||||
globals.userMessages.flutterMissPlatformProjects(
|
||||
Device.devicesPlatformTypes(<Device>[mockDevice]),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_tools/src/base/user_messages.dart' hide userMessages;
|
||||
import 'package:flutter_tools/src/base/user_messages.dart';
|
||||
import 'package:flutter_tools/src/doctor_validator.dart';
|
||||
import 'package:flutter_tools/src/windows/visual_studio.dart';
|
||||
import 'package:flutter_tools/src/windows/visual_studio_validator.dart';
|
||||
|
@ -10,11 +10,11 @@ import 'package:test/fake.dart';
|
|||
|
||||
import '../../src/common.dart';
|
||||
|
||||
final UserMessages userMessages = UserMessages();
|
||||
|
||||
void main() {
|
||||
group('Visual Studio validation', () {
|
||||
late FakeVisualStudio fakeVisualStudio;
|
||||
final UserMessages userMessages = UserMessages();
|
||||
|
||||
setUp(() {
|
||||
fakeVisualStudio = FakeVisualStudio();
|
||||
|
|
Loading…
Reference in a new issue