mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
[editor] use EditorUtil for retrieving data context from editor
Thus we can avoid casting to EditorEx/EditorImpl and substitute editor with an ImaginaryEditor without loosing functionality that requires DataContext GitOrigin-RevId: 9ec629dc8493b9ed4e8573944286193a07e5032a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
833797d238
commit
bb1dc43965
@@ -15,6 +15,7 @@ import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
@@ -128,7 +129,7 @@ public class MoveClassToModuleFix implements IntentionAction {
|
||||
|
||||
private void moveClass(Project project, Editor editor, PsiFile file, PsiClass aClass) {
|
||||
RefactoringActionHandler moveHandler = RefactoringActionHandlerFactory.getInstance().createMoveHandler();
|
||||
DataContext dataContext = ((EditorEx)editor).getDataContext();
|
||||
DataContext dataContext = EditorUtil.getEditorDataContext(editor);
|
||||
final String fqName = aClass.getQualifiedName();
|
||||
LOG.assertTrue(fqName != null);
|
||||
PsiDirectory directory = PackageUtil
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ex.ActionUtil;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
@@ -41,7 +42,7 @@ public class GutterIntentionAction extends AbstractIntentionAction implements Co
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
final RelativePoint relativePoint = JBPopupFactory.getInstance().guessBestPopupLocation(editor);
|
||||
AnActionEvent event = AnActionEvent.createFromInputEvent(
|
||||
relativePoint.toMouseEvent(), ActionPlaces.INTENTION_MENU, null, ((EditorEx)editor).getDataContext());
|
||||
relativePoint.toMouseEvent(), ActionPlaces.INTENTION_MENU, null, EditorUtil.getEditorDataContext(editor));
|
||||
if (!ActionUtil.lastUpdateAndCheckDumb(myAction, event, false)) return;
|
||||
if (myAction instanceof ActionGroup && !((ActionGroup)myAction).canBePerformed(event.getDataContext())) {
|
||||
ActionGroup group = (ActionGroup)myAction;
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.impl.Utils;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
@@ -161,7 +162,7 @@ public final class CachedIntentions {
|
||||
Predicate<IntentionAction> filter = action -> ContainerUtil.and(
|
||||
IntentionActionFilter.EXTENSION_POINT_NAME.getExtensionList(), f -> f.accept(action, myFile));
|
||||
|
||||
DataContext dataContext = Utils.wrapDataContext(((EditorEx)myEditor).getDataContext());
|
||||
DataContext dataContext = Utils.wrapDataContext(EditorUtil.getEditorDataContext(myEditor));
|
||||
PresentationFactory presentationFactory = new PresentationFactory();
|
||||
List<AnAction> actions = Utils.expandActionGroup(
|
||||
false, new DefaultActionGroup(myGuttersRaw), presentationFactory,
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
|
||||
import com.intellij.openapi.editor.actionSystem.TypedAction;
|
||||
import com.intellij.openapi.editor.impl.EditorImpl;
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -160,7 +160,7 @@ public class InvokeCompletion extends ActionOnFile {
|
||||
((LookupImpl)lookup).finishLookup(completionChar, item);
|
||||
} else {
|
||||
EditorActionManager.getInstance();
|
||||
TypedAction.getInstance().actionPerformed(editor, completionChar, ((EditorImpl)lookup.getTopLevelEditor()).getDataContext());
|
||||
TypedAction.getInstance().actionPerformed(editor, completionChar, EditorUtil.getEditorDataContext(lookup.getTopLevelEditor()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.HtmlBuilder;
|
||||
import com.intellij.openapi.util.text.HtmlChunk;
|
||||
@@ -115,7 +116,7 @@ public class PluginXmlDynamicPluginInspection extends DevKitPluginXmlInspectionB
|
||||
@Override
|
||||
public void applyFix(@NotNull Project project, PsiFile file, @Nullable Editor editor) {
|
||||
assert editor != null;
|
||||
action.actionPerformed(AnActionEvent.createFromDataContext(ActionPlaces.UNKNOWN, null, ((EditorEx)editor).getDataContext()));
|
||||
action.actionPerformed(AnActionEvent.createFromDataContext(ActionPlaces.UNKNOWN, null, EditorUtil.getEditorDataContext(editor)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.sh.ShLanguage;
|
||||
@@ -36,6 +37,6 @@ abstract class ShBaseGenerateAction extends CodeInsightAction implements CodeIns
|
||||
caret.moveToOffset(lineEndOffset);
|
||||
|
||||
EditorActionHandler actionHandler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_ENTER);
|
||||
actionHandler.execute(editor, caret, ((EditorEx)editor).getDataContext());
|
||||
actionHandler.execute(editor, caret, EditorUtil.getEditorDataContext(editor));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.impl.text.TextEditorPsiDataProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -78,7 +79,7 @@ public class RenameTo extends LazySuggestions implements SpellCheckerQuickFix {
|
||||
final Boolean selectAll = editor.getUserData(RenameHandlerRegistry.SELECT_ALL);
|
||||
try {
|
||||
editor.putUserData(RenameHandlerRegistry.SELECT_ALL, true);
|
||||
DataContext dataContext = builder.setParent(((EditorEx)editor).getDataContext()).build();
|
||||
DataContext dataContext = builder.setParent(EditorUtil.getEditorDataContext(editor)).build();
|
||||
AnAction action = new RenameElementAction();
|
||||
AnActionEvent event = AnActionEvent.createFromAnAction(action, null, "", dataContext);
|
||||
action.actionPerformed(event);
|
||||
|
||||
Reference in New Issue
Block a user