mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Revert "Remove redundant code; avoid choose if injectedFile is absent"
This reverts commit 7aefdf73 GitOrigin-RevId: ad7fc09042d136f874cd37b931c75d989fc68430
This commit is contained in:
committed by
intellij-monorepo-bot
parent
93c584914d
commit
af751408e2
+25
-15
@@ -14,6 +14,7 @@ import com.intellij.codeInsight.hint.HintManagerImpl;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInsight.intention.IntentionActionDelegate;
|
||||
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
|
||||
import com.intellij.codeInsight.intention.impl.preview.IntentionPreviewEditor;
|
||||
import com.intellij.codeInsight.intention.impl.preview.IntentionPreviewUnsupportedOperationException;
|
||||
import com.intellij.codeInsight.lookup.LookupEx;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
@@ -172,24 +173,33 @@ public class ShowIntentionActionsHandler implements CodeInsightActionHandler {
|
||||
@NotNull Editor hostEditor,
|
||||
@Nullable PsiFile injectedFile,
|
||||
@NotNull PairProcessor<? super PsiFile, ? super Editor> predicate) {
|
||||
if (injectedFile == null) {
|
||||
return Pair.create(hostFile, hostEditor);
|
||||
}
|
||||
Editor editorToApply = null;
|
||||
PsiFile fileToApply = null;
|
||||
try {
|
||||
Editor editorToApply = null;
|
||||
PsiFile fileToApply = null;
|
||||
|
||||
Editor injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(hostEditor, injectedFile);
|
||||
if (predicate.process(injectedFile, injectedEditor)) {
|
||||
editorToApply = injectedEditor;
|
||||
fileToApply = injectedFile;
|
||||
}
|
||||
Editor injectedEditor = null;
|
||||
// TODO: support intention preview in injections
|
||||
if (injectedFile != null && !(hostEditor instanceof IntentionPreviewEditor)) {
|
||||
injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(hostEditor, injectedFile);
|
||||
if (predicate.process(injectedFile, injectedEditor)) {
|
||||
editorToApply = injectedEditor;
|
||||
fileToApply = injectedFile;
|
||||
}
|
||||
}
|
||||
|
||||
if (editorToApply == null && hostEditor != injectedEditor && predicate.process(hostFile, hostEditor)) {
|
||||
editorToApply = hostEditor;
|
||||
fileToApply = hostFile;
|
||||
if (editorToApply == null && hostEditor != injectedEditor && predicate.process(hostFile, hostEditor)) {
|
||||
editorToApply = hostEditor;
|
||||
fileToApply = hostFile;
|
||||
}
|
||||
if (editorToApply == null) return null;
|
||||
return Pair.create(fileToApply, editorToApply);
|
||||
}
|
||||
catch (IntentionPreviewUnsupportedOperationException e) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
throw e;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (editorToApply == null) return null;
|
||||
return Pair.create(fileToApply, editorToApply);
|
||||
}
|
||||
|
||||
public static boolean chooseActionAndInvoke(@NotNull PsiFile hostFile,
|
||||
|
||||
Reference in New Issue
Block a user