Test for import intension in kotlin project

GitOrigin-RevId: 5fc4219c54ebadebb2c2caa78db5aa90013b2ba6
This commit is contained in:
Yuriy Maltsev
2022-11-15 19:54:26 +01:00
committed by intellij-monorepo-bot
parent 749b148159
commit 7a3982d651
2 changed files with 9 additions and 5 deletions

View File

@@ -3,12 +3,13 @@
<body>
<p>
Simulate invocation of alt+enter and pressing item in the list defined by parameter.
Optional: it is possible to only open pop up and check if item from pa is presented in list.
</p>
<p>
Syntax: %altEnter [parameters]
Syntax: %altEnter &lt;item in list&gt;(Optional)|&lt;invoke&gt;
</p>
<p>
Example: %altEnter Find cause
Example: %altEnter Find cause|true
</p>
</body>
</html>

View File

@@ -39,7 +39,10 @@ public final class ShowAltEnter extends AbstractCommand implements Disposable {
@Override
protected Promise<Object> _execute(@NotNull PlaybackContext context) {
ActionCallback actionCallback = new ActionCallbackProfilerStopper();
final String actionName = extractCommandArgument(PREFIX);
String extractCommandList = extractCommandArgument(PREFIX);
String[] commandList = extractCommandList.split("\\|");
final String actionName = commandList[0];
final boolean invoke = (commandList.length > 1) ? Boolean.parseBoolean(commandList[1]) : true;
ApplicationManager.getApplication().invokeAndWait(Context.current().wrap(() -> {
@NotNull Project project = context.getProject();
Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
@@ -59,10 +62,10 @@ public final class ShowAltEnter extends AbstractCommand implements Disposable {
Optional<HighlightInfo.IntentionActionDescriptor>
singleIntention = combined.stream().filter(s -> s.getAction().getText().startsWith(actionName)).findFirst();
if (singleIntention.isEmpty()) actionCallback.reject(actionName + " is not found among " + combined);
singleIntention
if (invoke) singleIntention
.ifPresent(c -> ShowIntentionActionsHandler.chooseActionAndInvoke(psiFile, editor, c.getAction(), c.getAction().getText()));
}
else {
if (!invoke || actionName.isEmpty()) {
CachedIntentions cachedIntentions = CachedIntentions.create(project, psiFile, editor, intentions);
IntentionHintComponent.showIntentionHint(project, psiFile, editor, true, cachedIntentions);
}