|
9 | 9 | import com.intellij.openapi.actionSystem.CommonDataKeys;
|
10 | 10 | import com.intellij.openapi.actionSystem.LangDataKeys;
|
11 | 11 | import com.intellij.openapi.application.ApplicationManager;
|
| 12 | +import com.intellij.openapi.application.ReadAction; |
12 | 13 | import com.intellij.openapi.module.Module;
|
13 | 14 | import com.intellij.openapi.module.ModuleManager;
|
14 | 15 | import com.intellij.openapi.project.Project;
|
|
18 | 19 | import com.intellij.openapi.util.Computable;
|
19 | 20 | import com.intellij.openapi.vfs.VirtualFile;
|
20 | 21 | import com.intellij.psi.PsiFile;
|
| 22 | +import com.intellij.util.concurrency.AppExecutorUtil; |
21 | 23 | import com.jetbrains.lang.dart.util.DotPackagesFileUtil;
|
22 | 24 | import io.flutter.FlutterUtils;
|
23 | 25 | import org.jetbrains.annotations.NotNull;
|
@@ -139,13 +141,20 @@ public static PubRoot forDirectory(@Nullable VirtualFile dir) {
|
139 | 141 | if (dir == null || !dir.isDirectory() || dir.getPath().endsWith("/")) {
|
140 | 142 | return null;
|
141 | 143 | }
|
| 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 | + } |
142 | 152 |
|
143 |
| - final VirtualFile pubspec = dir.findChild(PUBSPEC_YAML); |
144 | 153 | if (pubspec == null || !pubspec.exists() || pubspec.isDirectory()) {
|
145 | 154 | return null;
|
| 155 | + } else { |
| 156 | + return new PubRoot(dir, pubspec); |
146 | 157 | }
|
147 |
| - |
148 |
| - return new PubRoot(dir, pubspec); |
149 | 158 | }
|
150 | 159 |
|
151 | 160 | /**
|
|
0 commit comments