diff --git a/CHANGELOG.md b/CHANGELOG.md index 726a95b..5b3695e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,10 @@ ### Acknowledge undefined action inputs & outputs -- Fix: Keep user settings after action refresh - Feat: [#33 Acknowledge undefined action inputs & outputs](https://github.com/YunaBraska/github-workflow-plugin/issues/33) - Feat: Click on `Needs` navigates directly to the `Job` +- Fix: [Startup error: Slow operations are prohibited on EDT](https://github.com/YunaBraska/github-workflow-plugin/issues/38) +- Fix: Keep user settings after action refresh - Chore: refactored & split logic to specific classes like \[`Action`, `Envs`, `GitHub`, `Inputs`, `Jobs`, `Needs`, `Runner`, `Secrets`, `Steps`] diff --git a/src/main/java/com/github/yunabraska/githubworkflow/services/ProjectStartup.java b/src/main/java/com/github/yunabraska/githubworkflow/services/ProjectStartup.java index 3e74cbe..8087347 100644 --- a/src/main/java/com/github/yunabraska/githubworkflow/services/ProjectStartup.java +++ b/src/main/java/com/github/yunabraska/githubworkflow/services/ProjectStartup.java @@ -89,17 +89,25 @@ public static void asyncInitAllActionsAfterInit(final Project project, final Vir } private static void asyncInitAllActions(final Project project, final VirtualFile virtualFile) { - if (virtualFile != null && (GitHubWorkflowHelper.isWorkflowPath(toPath(virtualFile.getPath())))) { - final List actions = new ArrayList<>(); - // READ CONTEXT - ApplicationManager.getApplication().runReadAction(() -> Optional.of(PsiManager.getInstance(project)) - .map(psiManager -> psiManager.findFile(virtualFile)) - .map(psiFile -> PsiElementHelper.getAllElements(psiFile, FIELD_USES)) - .ifPresent(usesList -> usesList.stream().map(GitHubActionCache::getAction).filter(action -> !action.isSuppressed()).filter(action -> !action.isResolved()).forEach(actions::add)) - ); - - // ASYNC HTTP CONTEXT - GitHubActionCache.resolveActionsAsync(actions); + final Runnable task = () -> { + if (virtualFile != null && (GitHubWorkflowHelper.isWorkflowPath(toPath(virtualFile.getPath())))) { + final List actions = new ArrayList<>(); + // READ CONTEXT + ApplicationManager.getApplication().runReadAction(() -> Optional.of(PsiManager.getInstance(project)) + .map(psiManager -> psiManager.findFile(virtualFile)) + .map(psiFile -> PsiElementHelper.getAllElements(psiFile, FIELD_USES)) + .ifPresent(usesList -> usesList.stream().map(GitHubActionCache::getAction).filter(action -> !action.isSuppressed()).filter(action -> !action.isResolved()).forEach(actions::add)) + ); + + // ASYNC HTTP CONTEXT + GitHubActionCache.resolveActionsAsync(actions); + } + }; + + if (!DumbService.isDumb(project)) { + ApplicationManager.getApplication().executeOnPooledThread(task); + } else { + DumbService.getInstance(project).runWhenSmart(() -> ApplicationManager.getApplication().executeOnPooledThread(task)); } } }