From f25e4fea18948ad5eabb3247c2beb24ec1ba7b95 Mon Sep 17 00:00:00 2001 From: Lau Ching Jun Date: Thu, 15 Jul 2021 16:56:04 -0700 Subject: [PATCH] Remove unnecessary variables. (#86444) --- .../flutter_tools/lib/src/commands/attach.dart | 2 -- .../flutter_tools/lib/src/commands/run.dart | 2 -- packages/flutter_tools/lib/src/compile.dart | 6 ++++-- .../flutter_tools/lib/src/resident_runner.dart | 18 +++++------------- .../commands.shard/hermetic/attach_test.dart | 4 ++-- 5 files changed, 11 insertions(+), 21 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/attach.dart b/packages/flutter_tools/lib/src/commands/attach.dart index ef72ce344c0..7debc8e1d89 100644 --- a/packages/flutter_tools/lib/src/commands/attach.dart +++ b/packages/flutter_tools/lib/src/commands/attach.dart @@ -411,8 +411,6 @@ known, it can be explicitly provided to attach via the command-line, e.g. final FlutterDevice flutterDevice = await FlutterDevice.create( device, - fileSystemRoots: stringsArg(FlutterOptions.kFileSystemRoot), - fileSystemScheme: stringArg(FlutterOptions.kFileSystemScheme), target: targetFile, targetModel: TargetModel(stringArg('target-model')), buildInfo: buildInfo, diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart index d6503940f47..452f227a8ce 100644 --- a/packages/flutter_tools/lib/src/commands/run.dart +++ b/packages/flutter_tools/lib/src/commands/run.dart @@ -616,8 +616,6 @@ class RunCommand extends RunCommandBase { for (final Device device in devices) await FlutterDevice.create( device, - fileSystemRoots: fileSystemRoots, - fileSystemScheme: fileSystemScheme, experimentalFlags: expFlags, target: targetFile, buildInfo: buildInfo, diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart index e8a69fbafc5..b41bc4ff2b3 100644 --- a/packages/flutter_tools/lib/src/compile.dart +++ b/packages/flutter_tools/lib/src/compile.dart @@ -542,7 +542,7 @@ class DefaultResidentCompiler implements ResidentCompiler { this.testCompilation = false, this.trackWidgetCreation = true, this.packagesPath, - this.fileSystemRoots = const [], + List fileSystemRoots = const [], this.fileSystemScheme, this.initializeFromDill, this.targetModel = TargetModel.flutter, @@ -560,7 +560,9 @@ class DefaultResidentCompiler implements ResidentCompiler { _platform = platform, dartDefines = dartDefines ?? const [], // This is a URI, not a file path, so the forward slash is correct even on Windows. - sdkRoot = sdkRoot.endsWith('/') ? sdkRoot : '$sdkRoot/'; + sdkRoot = sdkRoot.endsWith('/') ? sdkRoot : '$sdkRoot/', + // Make a copy, we might need to modify it later. + fileSystemRoots = List.from(fileSystemRoots); final Logger _logger; final ProcessManager _processManager; diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index e1b0fd17bb8..29f7d4da114 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -47,8 +47,6 @@ class FlutterDevice { FlutterDevice( this.device, { @required this.buildInfo, - this.fileSystemRoots, - this.fileSystemScheme, TargetModel targetModel = TargetModel.flutter, this.targetPlatform, ResidentCompiler generator, @@ -62,8 +60,8 @@ class FlutterDevice { ), buildMode: buildInfo.mode, trackWidgetCreation: buildInfo.trackWidgetCreation, - fileSystemRoots: fileSystemRoots ?? [], - fileSystemScheme: fileSystemScheme, + fileSystemRoots: buildInfo.fileSystemRoots ?? [], + fileSystemScheme: buildInfo.fileSystemScheme, targetModel: targetModel, dartDefines: buildInfo.dartDefines, packagesPath: buildInfo.packagesPath, @@ -81,8 +79,6 @@ class FlutterDevice { @required String target, @required BuildInfo buildInfo, @required Platform platform, - List fileSystemRoots, - String fileSystemScheme, TargetModel targetModel = TargetModel.flutter, List experimentalFlags, ResidentCompiler generator, @@ -121,7 +117,7 @@ class FlutterDevice { globals.artifacts.getHostArtifact(HostArtifact.flutterWebSdk).path, buildMode: buildInfo.mode, trackWidgetCreation: buildInfo.trackWidgetCreation, - fileSystemRoots: fileSystemRoots ?? [], + fileSystemRoots: buildInfo.fileSystemRoots ?? [], // Override the filesystem scheme so that the frontend_server can find // the generated entrypoint code. fileSystemScheme: 'org-dartlang-app', @@ -162,8 +158,8 @@ class FlutterDevice { ), buildMode: buildInfo.mode, trackWidgetCreation: buildInfo.trackWidgetCreation, - fileSystemRoots: fileSystemRoots, - fileSystemScheme: fileSystemScheme, + fileSystemRoots: buildInfo.fileSystemRoots, + fileSystemScheme: buildInfo.fileSystemScheme, targetModel: targetModel, dartDefines: buildInfo.dartDefines, extraFrontEndOptions: extraFrontEndOptions, @@ -183,8 +179,6 @@ class FlutterDevice { return FlutterDevice( device, - fileSystemRoots: fileSystemRoots, - fileSystemScheme:fileSystemScheme, targetModel: targetModel, targetPlatform: targetPlatform, generator: generator, @@ -204,8 +198,6 @@ class FlutterDevice { FlutterVmService vmService; DevFS devFS; ApplicationPackage package; - List fileSystemRoots; - String fileSystemScheme; StreamSubscription _loggingSubscription; bool _isListeningForObservatoryUri; diff --git a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart index 60385852346..6f988d1cd69 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart @@ -197,8 +197,8 @@ void main() { // output dill, filesystem scheme, and filesystem root. final FlutterDevice flutterDevice = hotRunnerFactory.devices.first; - expect(flutterDevice.fileSystemScheme, filesystemScheme); - expect(flutterDevice.fileSystemRoots, const [filesystemRoot]); + expect(flutterDevice.buildInfo.fileSystemScheme, filesystemScheme); + expect(flutterDevice.buildInfo.fileSystemRoots, const [filesystemRoot]); }, overrides: { FileSystem: () => testFileSystem, ProcessManager: () => FakeProcessManager.any(),