Skip to content

Commit e965bb8

Browse files
authored
Fix IDEA project open hang (#8903)
Fixes #8845. Follows up on #8846 which I reverted before the last release because it was causing new projects to prompt the user to open twice (at least in my environment). The change I made since then is to not reload after setting up the modules. The risk of not reloading is that there could be things that don't recognize the new module identity e.g., tool windows or DAS may not start properly. I checked that those two things aren't an issue, so I feel like this is reasonable and better than being prompted twice to open a new project.
1 parent cb14614 commit e965bb8

5 files changed

Lines changed: 16 additions & 115 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
### Removed
88

99
### Fixed
10+
- Silent failure when opening Flutter projects without `.idea` directory in IntelliJ IDEA, by removing `FlutterProjectOpenProcessor` and
11+
migrating configuration logic to `FlutterInitializer`. (#8903)
1012

1113
## 91.0.0
1214

resources/META-INF/plugin.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,6 @@
335335
<!-- See https://github.com/flutter/flutter-intellij/issues/8029 -->
336336
<projectService serviceImplementation="io.flutter.view.InspectorView" overrides="false"/>
337337

338-
<projectOpenProcessor id="flutter" implementation="io.flutter.project.FlutterProjectOpenProcessor" order="first"/>
339-
340338
<editorNotificationProvider implementation="io.flutter.editor.FlutterPubspecNotificationProvider"/>
341339
<editorNotificationProvider implementation="io.flutter.inspections.SdkConfigurationNotificationProvider"/>
342340
<editorNotificationProvider implementation="io.flutter.editor.NativeEditorNotificationProvider"/>

src/io/flutter/FlutterInitializer.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@
6767
* Runs actions after the project has started up and the index is up to date.
6868
*
6969
* @see ProjectOpenActivity for actions that run earlier.
70-
* @see io.flutter.project.FlutterProjectOpenProcessor for additional actions that
71-
* may run when a project is being imported.
7270
*/
7371
public class FlutterInitializer extends FlutterProjectActivity {
7472
private boolean toolWindowsInitialized = false;
@@ -115,8 +113,19 @@ public void executeProjectStartup(@NotNull Project project) {
115113
}
116114

117115
log().info("Flutter module has been found for project: " + project.getName());
118-
// Ensure SDKs are configured; needed for clean module import.
119-
FlutterModuleUtils.enableDartSDK(module);
116+
117+
// Ensure Flutter project configuration is applied for projects that may have been
118+
// opened without a .idea directory. Previously this was handled by FlutterProjectOpenProcessor,
119+
// but that processor silently failed when no delegate processor could open the project.
120+
// Instead, we let the platform open the project normally and apply our configuration here.
121+
// See https://github.com/flutter/flutter-intellij/issues/8661 (Android Studio equivalent)
122+
if (!FlutterModuleUtils.isFlutterModule(module)) {
123+
log().info("Fixing Flutter module configuration for " + module.getName());
124+
FlutterModuleUtils.setFlutterModuleWithoutReload(module, project);
125+
} else {
126+
// Ensure SDKs are configured; needed for clean module import.
127+
FlutterModuleUtils.enableDartSDK(module);
128+
}
120129

121130
for (PubRoot root : PubRoots.forModule(module)) {
122131
// Set Android SDK.

src/io/flutter/project/FlutterProjectOpenProcessor.kt

Lines changed: 0 additions & 107 deletions
This file was deleted.

src/io/flutter/utils/FlutterModuleUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,15 +373,14 @@ public static void setFlutterModuleType(@NotNull Module module) {
373373
module.setModuleType(getModuleTypeIDForFlutter());
374374
}
375375

376-
public static void setFlutterModuleAndReload(@NotNull Module module, @NotNull Project project) {
376+
public static void setFlutterModuleWithoutReload(@NotNull Module module, @NotNull Project project) {
377377
if (project.isDisposed()) return;
378378
ApplicationManager.getApplication().invokeLater(() -> {
379379
ApplicationManager.getApplication().runWriteAction(() -> setFlutterModuleType(module));
380380
enableDartSDK(module);
381381
project.save();
382382

383383
EditorNotifications.getInstance(project).updateAllNotifications();
384-
ProjectManager.getInstance().reloadProject(project);
385384
});
386385
}
387386

0 commit comments

Comments
 (0)