Skip to content

Commit 647f99b

Browse files
authored
Fix the IntelliJ freeze issue 7968 (#7981)
#7968 The issue was introduced with this change: #7885 The documentation from JetBrains states that this code is to avoid deadlocks: https://github.com/JetBrains/intellij-community/blob/idea/243.21565.193/platform/core-api/src/com/intellij/openapi/application/ReadAction.java#L94
1 parent 38e78f0 commit 647f99b

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

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

+5-12
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.intellij.openapi.actionSystem.CommonDataKeys;
1010
import com.intellij.openapi.actionSystem.LangDataKeys;
1111
import com.intellij.openapi.application.ApplicationManager;
12-
import com.intellij.openapi.application.ReadAction;
1312
import com.intellij.openapi.module.Module;
1413
import com.intellij.openapi.module.ModuleManager;
1514
import com.intellij.openapi.project.Project;
@@ -19,7 +18,6 @@
1918
import com.intellij.openapi.util.Computable;
2019
import com.intellij.openapi.vfs.VirtualFile;
2120
import com.intellij.psi.PsiFile;
22-
import com.intellij.util.concurrency.AppExecutorUtil;
2321
import com.jetbrains.lang.dart.util.DotPackagesFileUtil;
2422
import io.flutter.FlutterUtils;
2523
import org.jetbrains.annotations.NotNull;
@@ -141,18 +139,11 @@ public static PubRoot forDirectory(@Nullable VirtualFile dir) {
141139
if (dir == null || !dir.isDirectory() || dir.getPath().endsWith("/")) {
142140
return null;
143141
}
144-
VirtualFile pubspec = null;
145-
try {
146-
pubspec = ReadAction.nonBlocking(() -> {
147-
return dir.findChild(PUBSPEC_YAML);
148-
}).submit(AppExecutorUtil.getAppExecutorService()).get();
149-
} catch (Exception e) {
150-
// do nothing
151-
}
152-
142+
final VirtualFile pubspec = dir.findChild(PUBSPEC_YAML);
153143
if (pubspec == null || !pubspec.exists() || pubspec.isDirectory()) {
154144
return null;
155-
} else {
145+
}
146+
else {
156147
return new PubRoot(dir, pubspec);
157148
}
158149
}
@@ -194,6 +185,7 @@ public String getRelativePath(@NotNull VirtualFile file) {
194185

195186
/**
196187
* Returns true if the given file is a directory that contains tests.
188+
*
197189
* @noinspection BooleanMethodIsAlwaysInverted
198190
*/
199191
public boolean hasTests(@NotNull VirtualFile dir) {
@@ -314,6 +306,7 @@ public VirtualFile getPackagesFile() {
314306
/**
315307
* Returns true if the packages are up-to-date with regard to the `pubspec.yaml`. The `.packages` file is used if no
316308
* `.tool/package_config.json` is found. The default value returned is to return false.
309+
*
317310
* @noinspection BooleanMethodIsAlwaysInverted
318311
*/
319312
public boolean hasUpToDatePackages() {

0 commit comments

Comments
 (0)