Skip to content

Commit 1953172

Browse files
authored
[CQ] fix nullability problems for flutter/pub (#8306)
Fix nullability problems in `src/io/flutter/pub/`. See #8291. If we pursue #8292, we could mark `src/io/flutter/pub/` as null-"clean". --- - [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/dart-lang/sdk/blob/main/CONTRIBUTING.md](https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview) 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 e55aba1 commit 1953172

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

flutter-idea/src/io/flutter/pub/PubRoot.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public String getRelativePath(@NotNull VirtualFile file) {
177177
return path.substring(root.length() + 1);
178178
}
179179

180-
private static final String /*@NotNull*/[] TEST_DIRS = new String[]{ // TODO 2022.1
180+
private static final String @NotNull [] TEST_DIRS = new String[]{ // TODO 2022.1
181181
"/test/",
182182
"/integration_test/",
183183
"/test_driver/",
@@ -237,6 +237,7 @@ public VirtualFile getPubspec() {
237237
*/
238238
public boolean declaresFlutter() {
239239
validateUpdateCachedPubspecInfo();
240+
assert cachedPubspecInfo != null;
240241
return cachedPubspecInfo.declaresFlutter();
241242
}
242243

@@ -444,7 +445,10 @@ public Module getModule(@NotNull Project project) {
444445
if (project.isDisposed()) {
445446
return null;
446447
}
447-
return ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(pubspec);
448+
var manager = ProjectRootManager.getInstance(project);
449+
if (manager == null) return null;
450+
451+
return manager.getFileIndex().getModuleForFile(pubspec);
448452
}
449453

450454
@Override

0 commit comments

Comments
 (0)