Skip to content

Commit c66950c

Browse files
authored
[fix] OpenInAppCodeAction forbidden initialization service dependency (#8260)
Schedule initialization in a runnable rather than doing service calls in the class initializer. Fixes: #8180 --- - [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 d7d0b0a commit c66950c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

flutter-idea/src/io/flutter/actions/OpenInAppCodeAction.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,24 @@
2222
import com.intellij.openapi.vfs.VirtualFile;
2323
import io.flutter.FlutterMessages;
2424
import io.flutter.sdk.FlutterSdk;
25+
import io.flutter.utils.OpenApiUtils;
2526
import org.jetbrains.annotations.NotNull;
2627
import org.jetbrains.annotations.Nullable;
2728

2829
import static io.flutter.actions.OpenInXcodeAction.findProjectFile;
2930

3031
public class OpenInAppCodeAction extends AnAction {
32+
OpenInAppCodeAction() {
33+
// Schedule initialization so that we can discover if `AppCode` is installed *before* we
34+
// need to decide whether to make the action menu visible.
35+
OpenApiUtils.safeInvokeLater(() -> {
36+
initialize();
37+
});
38+
}
3139

3240
private static boolean IS_INITIALIZED = false;
3341
private static boolean IS_APPCODE_INSTALLED = false;
3442

35-
static {
36-
initialize();
37-
}
38-
3943
private static void initialize() {
4044
if (SystemInfo.isMac) {
4145
try {
@@ -78,6 +82,7 @@ public void update(@NotNull AnActionEvent event) {
7882
public @NotNull ActionUpdateThread getActionUpdateThread() {
7983
return ActionUpdateThread.BGT;
8084
}
85+
8186
@Override
8287
public void actionPerformed(@NotNull AnActionEvent event) {
8388
final VirtualFile projectFile = findProjectFile(event);

0 commit comments

Comments
 (0)