|
16 | 16 |
|
17 | 17 | package org.intellij.erlang.quickfixes; |
18 | 18 |
|
| 19 | +import com.intellij.codeInsight.intention.preview.IntentionPreviewInfo; |
19 | 20 | import com.intellij.codeInspection.ProblemDescriptor; |
20 | 21 | import com.intellij.openapi.application.ApplicationManager; |
21 | 22 | import com.intellij.openapi.command.CommandProcessor; |
@@ -81,19 +82,29 @@ public void applyFix(@NotNull Project project, |
81 | 82 | if (matchFiles.length == 0) { |
82 | 83 | return; |
83 | 84 | } |
| 85 | + |
| 86 | + ApplicationManager.getApplication().assertIsDispatchThread(); |
| 87 | + |
84 | 88 | //Single file found |
85 | 89 | if (matchFiles.length == 1) { |
86 | | - fixUsingIncludeFile(problem, matchFiles[0]); |
87 | | - renameIncludeString(project, problem, setDirectHrlLink, includeString, includeFileName); |
| 90 | + CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction(() -> { |
| 91 | + fixUsingIncludeFile(problem, matchFiles[0]); |
| 92 | + renameIncludeString(project, problem, setDirectHrlLink, includeString, includeFileName); |
| 93 | + FileContentUtilCore.reparseFiles(Collections.singletonList(problem.getContainingFile().getVirtualFile())); |
| 94 | + }), "Include File", "Include File"); |
88 | 95 | } |
89 | 96 | //Multiple files -- allow user select which file should be imported |
90 | 97 | if (matchFiles.length > 1) { |
91 | | - ApplicationManager.getApplication().invokeLater( |
92 | | - () -> displayPopupListDialog(project, problem, matchFiles, setDirectHrlLink, includeString, includeFileName) |
93 | | - ); |
| 98 | + displayPopupListDialog(project, problem, matchFiles, setDirectHrlLink, includeString, includeFileName); |
94 | 99 | } |
95 | 100 | } |
96 | 101 |
|
| 102 | + @Override |
| 103 | + public @NotNull IntentionPreviewInfo generatePreview(@NotNull Project project, |
| 104 | + @NotNull ProblemDescriptor previewDescriptor) { |
| 105 | + return IntentionPreviewInfo.EMPTY; |
| 106 | + } |
| 107 | + |
97 | 108 | private static void renameIncludeString(Project project, |
98 | 109 | PsiElement problem, |
99 | 110 | boolean setDirectHrlLink, |
@@ -169,7 +180,7 @@ public PopupStep<PsiFile> onChosen(PsiFile o, boolean b) { |
169 | 180 | fixUsingIncludeFile(problem, o); |
170 | 181 | renameIncludeString(project, problem, setDirectHrlLink, includeString, includeFileName); |
171 | 182 | FileContentUtilCore.reparseFiles(Collections.singletonList(problem.getContainingFile().getVirtualFile())); |
172 | | - }), "Add Facet Action (Find Include Quick Fix)", null, problemEditor.getDocument()); |
| 183 | + }), "Add Facet Action (Find Include Quick Fix)", "Include File", problemEditor.getDocument()); |
173 | 184 |
|
174 | 185 | return null; |
175 | 186 | } |
@@ -245,5 +256,3 @@ private static PsiFile[] searchFileInsideProject(Project project, String fileNam |
245 | 256 | } |
246 | 257 |
|
247 | 258 | } |
248 | | - |
249 | | - |
|
0 commit comments