Skip to content

Commit 6215b55

Browse files
committed
fix #1056
1 parent d50b928 commit 6215b55

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/org/intellij/erlang/quickfixes/ErlangFindIncludeQuickFix.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.intellij.erlang.quickfixes;
1818

19+
import com.intellij.codeInsight.intention.preview.IntentionPreviewInfo;
1920
import com.intellij.codeInspection.ProblemDescriptor;
2021
import com.intellij.openapi.application.ApplicationManager;
2122
import com.intellij.openapi.command.CommandProcessor;
@@ -81,19 +82,29 @@ public void applyFix(@NotNull Project project,
8182
if (matchFiles.length == 0) {
8283
return;
8384
}
85+
86+
ApplicationManager.getApplication().assertIsDispatchThread();
87+
8488
//Single file found
8589
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");
8895
}
8996
//Multiple files -- allow user select which file should be imported
9097
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);
9499
}
95100
}
96101

102+
@Override
103+
public @NotNull IntentionPreviewInfo generatePreview(@NotNull Project project,
104+
@NotNull ProblemDescriptor previewDescriptor) {
105+
return IntentionPreviewInfo.EMPTY;
106+
}
107+
97108
private static void renameIncludeString(Project project,
98109
PsiElement problem,
99110
boolean setDirectHrlLink,
@@ -169,7 +180,7 @@ public PopupStep<PsiFile> onChosen(PsiFile o, boolean b) {
169180
fixUsingIncludeFile(problem, o);
170181
renameIncludeString(project, problem, setDirectHrlLink, includeString, includeFileName);
171182
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());
173184

174185
return null;
175186
}
@@ -245,5 +256,3 @@ private static PsiFile[] searchFileInsideProject(Project project, String fileNam
245256
}
246257

247258
}
248-
249-

0 commit comments

Comments
 (0)