From 16e7adedd4d4b0df962706a027b15b4f4e97ff75 Mon Sep 17 00:00:00 2001 From: Sigurd Meldgaard Date: Fri, 21 Jun 2024 10:29:27 +0200 Subject: [PATCH] Stop looking for .packages when analyzing (#150349) Not sure exactly what this was supposed to do, but pub no longer writes ".packages" and has not done since: https://github.com/dart-lang/pub/pull/3413. So this check would never find a '.packages'. Not sure if this code was doing anything useful - but it does not seem to have been missed for a couple of years. This is a warm-up for: https://github.com/flutter/flutter/issues/150196 It was added in https://github.com/flutter/flutter/pull/6093 seemingly without tests of this functionality. --- .../lib/src/commands/analyze_base.dart | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/analyze_base.dart b/packages/flutter_tools/lib/src/commands/analyze_base.dart index 19377ff6b66..23872f31605 100644 --- a/packages/flutter_tools/lib/src/commands/analyze_base.dart +++ b/packages/flutter_tools/lib/src/commands/analyze_base.dart @@ -169,9 +169,6 @@ class PackageDependency { } class PackageDependencyTracker { - /// Packages whose source is defined in the vended SDK. - static const List _vendedSdkPackages = ['analyzer', 'front_end', 'kernel']; - // This is a map from package names to objects that track the paths // involved (sources and targets). Map packages = {}; @@ -180,32 +177,6 @@ class PackageDependencyTracker { return packages.putIfAbsent(packageName, () => PackageDependency()); } - /// Read the .packages file in [directory] and add referenced packages to [dependencies]. - void addDependenciesFromPackagesFileIn(Directory directory) { - final String dotPackagesPath = globals.fs.path.join(directory.path, '.packages'); - final File dotPackages = globals.fs.file(dotPackagesPath); - if (dotPackages.existsSync()) { - // this directory has opinions about what we should be using - final Iterable lines = dotPackages - .readAsStringSync() - .split('\n') - .where((String line) => !line.startsWith(RegExp(r'^ *#'))); - for (final String line in lines) { - final int colon = line.indexOf(':'); - if (colon > 0) { - final String packageName = line.substring(0, colon); - final String packagePath = globals.fs.path.fromUri(line.substring(colon+1)); - // Ensure that we only add `analyzer` and dependent packages defined in the vended SDK (and referred to with a local - // globals.fs.path. directive). Analyzer package versions reached via transitive dependencies (e.g., via `test`) are ignored - // since they would produce spurious conflicts. - if (!_vendedSdkPackages.contains(packageName) || packagePath.startsWith('..')) { - add(packageName, globals.fs.path.normalize(globals.fs.path.absolute(directory.path, packagePath)), dotPackagesPath); - } - } - } - } - } - void addCanonicalCase(String packageName, String packagePath, String pubSpecYamlPath) { getPackageDependency(packageName).addCanonicalCase(packagePath, pubSpecYamlPath); } @@ -235,7 +206,6 @@ class PackageDependencyTracker { throwToolExit('pubspec.yaml is malformed.'); } } - dependencies.addDependenciesFromPackagesFileIn(directory); } // prepare a union of all the .packages files