Skip to content

Commit cda923e

Browse files
authored
[cq] remove straggling .packages support (#8724)
Fixes: #8722 and opportunistically removes some dead code. **Note:** nothing urgent here; just tidying up! 🧹 --- - [x] I’ve reviewed the contributor guide and applied the relevant portions to this PR. <details> <summary>Contribution guidelines:</summary><br> - See our [contributor guide]([https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md](https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md) for general expectations for PRs. - Larger or significant changes should be discussed in an issue before creating a PR. - Dart contributions to our repos should follow the [Dart style guide](https://dart.dev/guides/language/effective-dart) and use `dart format`. - Java and Kotlin contributions should strive to follow Java and Kotlin best practices ([discussion](#8098)). </details>
1 parent 40ebdf8 commit cda923e

3 files changed

Lines changed: 8 additions & 57 deletions

File tree

src/io/flutter/pub/PubRoot.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
public class PubRoot {
3434
public static final String DOT_DART_TOOL = ".dart_tool";
3535
public static final String PACKAGE_CONFIG_JSON = "package_config.json";
36-
public static final String DOT_PACKAGES = ".packages";
3736
public static final String PUBSPEC_YAML = "pubspec.yaml";
3837

3938
@NotNull
@@ -271,17 +270,6 @@ public boolean isFlutterPlugin() {
271270
return FlutterUtils.isFlutterPlugin(pubspec);
272271
}
273272

274-
/**
275-
* Returns true if the directory content looks like a Flutter module.
276-
*/
277-
public boolean isFlutterModule() {
278-
return root.findChild(".android") != null;
279-
}
280-
281-
public boolean isNonEditableFlutterModule() {
282-
return isFlutterModule() && root.findChild("android") == null;
283-
}
284-
285273
@Nullable
286274
public VirtualFile getPackageConfigFile() {
287275
VirtualFile rootToExpectToolsDirectory = root;
@@ -305,16 +293,6 @@ public VirtualFile getPackageConfigFile() {
305293
return null;
306294
}
307295

308-
@Nullable
309-
public VirtualFile getPackagesFile() {
310-
// Obsolete by Flutter 2.0
311-
final VirtualFile packages = root.findChild(DOT_PACKAGES);
312-
if (packages != null && !packages.isDirectory()) {
313-
return packages;
314-
}
315-
return null;
316-
}
317-
318296
public @Nullable Map<String, String> getPackagesMap() {
319297
final var packageConfigFile = getPackageConfigFile();
320298
if (packageConfigFile != null) {
@@ -341,12 +319,6 @@ public boolean hasUpToDatePackages() {
341319
long configLastModified = new File(configFile.getPath()).lastModified();
342320
return pubspecLastModified < configLastModified;
343321
}
344-
final VirtualFile packagesFile = getPackagesFile();
345-
if (packagesFile != null) {
346-
long pubspecLastModified = new File(pubspec.getPath()).lastModified();
347-
long packagesLastModified = new File(packagesFile.getPath()).lastModified();
348-
return pubspecLastModified < packagesLastModified;
349-
}
350322
return false;
351323
}
352324

src/io/flutter/run/MainFile.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ private static boolean isAppDir(@NotNull VirtualFile dir, @NotNull Project proje
124124
assert (!WorkspaceCache.getInstance(project).isBazel());
125125
return dir.isDirectory() && (
126126
dir.findChild(PubRoot.PUBSPEC_YAML) != null ||
127-
dir.findChild(PubRoot.DOT_DART_TOOL) != null ||
128-
dir.findChild(PubRoot.DOT_PACKAGES) != null
127+
dir.findChild(PubRoot.DOT_DART_TOOL) != null
129128
);
130129
}
131130

src/io/flutter/sdk/FlutterSdkUtil.java

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@
3636
import org.jetbrains.annotations.NotNull;
3737
import org.jetbrains.annotations.Nullable;
3838

39-
import javax.swing.*;
39+
import javax.swing.DefaultComboBoxModel;
40+
import javax.swing.JComboBox;
4041
import java.io.File;
4142
import java.io.IOException;
4243
import java.net.URI;
4344
import java.net.URISyntaxException;
44-
import java.util.*;
45+
import java.util.HashSet;
46+
import java.util.LinkedHashSet;
47+
import java.util.List;
48+
import java.util.Set;
4549

4650
public class FlutterSdkUtil {
4751
/**
@@ -208,16 +212,7 @@ private static boolean isFlutterSdkHomeWithoutDartSdk(@NotNull final String path
208212
final File dartLibFolder = new File(path + "/bin/cache/dart-sdk/lib");
209213
return flutterPubspecFile.isFile() && flutterToolFile.isFile() && !dartLibFolder.isDirectory();
210214
}
211-
212-
/**
213-
* Checks the workspace for any open Flutter projects.
214-
*
215-
* @return true if an open Flutter project is found
216-
*/
217-
public static boolean hasFlutterModules() {
218-
return Arrays.stream(ProjectManager.getInstance().getOpenProjects()).anyMatch(FlutterModuleUtils::hasFlutterModule);
219-
}
220-
215+
221216
public static boolean hasFlutterModules(@NotNull Project project) {
222217
return FlutterModuleUtils.hasFlutterModule(project);
223218
}
@@ -287,21 +282,6 @@ public static String guessFlutterSdkFromPackagesFile(@NotNull Module module) {
287282
}
288283
}
289284

290-
// Next, try the obsolete .packages
291-
for (PubRoot pubRoot : PubRoots.forModule(module)) {
292-
final VirtualFile packagesFile = pubRoot.getPackagesFile();
293-
if (packagesFile == null) {
294-
continue;
295-
}
296-
// parse it
297-
try {
298-
final String contents = new String(packagesFile.contentsToByteArray(true /* cache contents */));
299-
return parseFlutterSdkPath(contents);
300-
}
301-
catch (IOException ignored) {
302-
}
303-
}
304-
305285
return null;
306286
}
307287

0 commit comments

Comments
 (0)