|
6 | 6 | import java.util.function.Consumer;
|
7 | 7 |
|
8 | 8 | import com.intellij.openapi.actionSystem.ActionManager;
|
| 9 | +import com.intellij.openapi.actionSystem.ActionUiKind; |
9 | 10 | import com.intellij.openapi.actionSystem.AnAction;
|
10 | 11 | import com.intellij.openapi.actionSystem.AnActionEvent;
|
11 | 12 | import com.intellij.openapi.actionSystem.DataContext;
|
|
16 | 17 |
|
17 | 18 | public interface ShortcutActionConstants
|
18 | 19 | {
|
19 |
| - |
20 |
| - Consumer<CodeInsightTestFixture> SAVE_ACTION_SHORTCUT_MANAGER = (fixture) -> |
| 20 | + Consumer<CodeInsightTestFixture> SAVE_ACTION_SHORTCUT_MANAGER = fixture -> |
21 | 21 | WriteCommandAction.writeCommandAction(fixture.getProject()).run(() -> runFixure(fixture));
|
22 | 22 |
|
23 |
| - static void runFixure(CodeInsightTestFixture fixture) |
| 23 | + static void runFixure(final CodeInsightTestFixture fixture) |
24 | 24 | {
|
25 | 25 | // set modification timestamp ++
|
26 | 26 | fixture.getFile().clearCaches();
|
27 | 27 |
|
28 |
| - ActionManager actionManager = ActionManager.getInstance(); |
29 |
| - AnAction action = actionManager.getAction(ShortcutAction.class.getName()); |
| 28 | + final ActionManager actionManager = ActionManager.getInstance(); |
| 29 | + final AnAction action = actionManager.getAction(ShortcutAction.class.getName()); |
30 | 30 |
|
31 |
| - DataContext dataContext = SimpleDataContext.builder() |
| 31 | + final DataContext dataContext = SimpleDataContext.builder() |
32 | 32 | .add(PROJECT, fixture.getProject())
|
33 | 33 | .add(PSI_FILE, fixture.getFile())
|
34 | 34 | .setParent(null)
|
35 | 35 | .build();
|
36 | 36 |
|
37 | 37 | // call plugin on document
|
38 |
| - AnActionEvent event = AnActionEvent.createFromAnAction(action, null, "save-actions", dataContext); |
| 38 | + final AnActionEvent event = AnActionEvent.createEvent( |
| 39 | + dataContext, |
| 40 | + action.getTemplatePresentation(), |
| 41 | + "save-actions", |
| 42 | + ActionUiKind.NONE, |
| 43 | + null); |
| 44 | + |
39 | 45 | new ShortcutAction().actionPerformed(event);
|
40 | 46 | }
|
41 | 47 | }
|
0 commit comments