mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-08-08 00:40:37 +02:00
Reformat ChangeEditorActionHandler
This commit is contained in:
parent
9be8e2b5b9
commit
aeef2f8948
src/com/maddyhome/idea/vim
action
change
change
ChangeCaseLowerMotionAction.javaChangeCaseToggleCharacterAction.javaChangeCaseToggleMotionAction.javaChangeCaseUpperMotionAction.javaChangeCharacterAction.javaChangeCharactersAction.javaChangeEndOfLineAction.javaChangeLastGlobalSearchReplaceAction.javaChangeLastSearchReplaceAction.javaChangeLineAction.javaChangeMotionAction.javaChangeReplaceAction.java
number
delete
DeleteCharacterAction.javaDeleteCharacterLeftAction.javaDeleteCharacterRightAction.javaDeleteEndOfLineAction.javaDeleteJoinLinesAction.javaDeleteJoinLinesSpacesAction.javaDeleteLineAction.javaDeleteMotionAction.java
insert
InsertAfterCursorAction.javaInsertAfterLineEndAction.javaInsertAtPreviousInsertAction.javaInsertBeforeCursorAction.javaInsertBeforeFirstNonBlankAction.javaInsertCharacterAboveCursorAction.javaInsertCharacterBelowCursorAction.javaInsertDeleteInsertedTextAction.javaInsertDeletePreviousWordAction.javaInsertLineStartAction.javaInsertNewLineAboveAction.javaInsertNewLineBelowAction.javaInsertPreviousInsertAction.javaInsertPreviousInsertExitAction.java
shift
copy
handler
@ -35,11 +35,7 @@ public class ChangeCaseLowerMotionAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -34,11 +34,7 @@ public class ChangeCaseToggleCharacterAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -35,11 +35,7 @@ public class ChangeCaseToggleMotionAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -35,11 +35,7 @@ public class ChangeCaseUpperMotionAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
return argument != null &&
|
||||
|
@ -34,11 +34,7 @@ public class ChangeCharacterAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -34,11 +34,7 @@ public class ChangeCharactersAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -34,11 +34,7 @@ public class ChangeEndOfLineAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -35,7 +35,7 @@ public class ChangeLastGlobalSearchReplaceAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
private static class Handler extends ChangeEditorActionHandler.SingleExecution {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
final LineRange range = new LineRange(0, EditorHelper.getLineCount(editor) - 1);
|
||||
return VimPlugin.getSearch().searchAndReplace(editor, editor.getCaretModel().getPrimaryCaret(), range, "s", "//~/&");
|
||||
|
@ -35,7 +35,7 @@ public class ChangeLastSearchReplaceAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
private static class Handler extends ChangeEditorActionHandler.SingleExecution {
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount,
|
||||
@Nullable Argument argument) {
|
||||
boolean result = true;
|
||||
|
@ -31,7 +31,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ChangeLineAction extends EditorAction {
|
||||
public ChangeLineAction() {
|
||||
super(new ChangeEditorActionHandler(true) {
|
||||
super(new ChangeEditorActionHandler.ForEachCaret() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull Caret caret,
|
||||
|
@ -34,11 +34,7 @@ public class ChangeMotionAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -30,7 +30,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ChangeReplaceAction extends EditorAction {
|
||||
public ChangeReplaceAction() {
|
||||
super(new ChangeEditorActionHandler() {
|
||||
super(new ChangeEditorActionHandler.SingleExecution() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
|
@ -34,11 +34,7 @@ public class ChangeNumberDecAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -34,11 +34,7 @@ public class ChangeNumberIncAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -34,11 +34,7 @@ public class DeleteCharacterAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -34,11 +34,7 @@ public class DeleteCharacterLeftAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -34,11 +34,7 @@ public class DeleteCharacterRightAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret{
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -34,11 +34,7 @@ public class DeleteEndOfLineAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -35,11 +35,7 @@ public class DeleteJoinLinesAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super();
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.SingleExecution {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
|
@ -35,11 +35,7 @@ public class DeleteJoinLinesSpacesAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super();
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.SingleExecution {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
|
@ -31,7 +31,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class DeleteLineAction extends EditorAction {
|
||||
public DeleteLineAction() {
|
||||
super(new ChangeEditorActionHandler(true) {
|
||||
super(new ChangeEditorActionHandler.ForEachCaret() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull Caret caret,
|
||||
|
@ -34,11 +34,7 @@ public class DeleteMotionAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -30,7 +30,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class InsertAfterCursorAction extends EditorAction {
|
||||
public InsertAfterCursorAction() {
|
||||
super(new ChangeEditorActionHandler() {
|
||||
super(new ChangeEditorActionHandler.SingleExecution() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
|
@ -30,7 +30,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class InsertAfterLineEndAction extends EditorAction {
|
||||
public InsertAfterLineEndAction() {
|
||||
super(new ChangeEditorActionHandler() {
|
||||
super(new ChangeEditorActionHandler.SingleExecution() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
|
@ -30,7 +30,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class InsertAtPreviousInsertAction extends EditorAction {
|
||||
public InsertAtPreviousInsertAction() {
|
||||
super(new ChangeEditorActionHandler() {
|
||||
super(new ChangeEditorActionHandler.SingleExecution() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
|
@ -42,7 +42,7 @@ final public class InsertBeforeCursorAction extends VimCommandAction {
|
||||
@NotNull
|
||||
@Override
|
||||
final protected VimActionHandler makeActionHandler() {
|
||||
return new ChangeEditorActionHandler() {
|
||||
return new ChangeEditorActionHandler.SingleExecution() {
|
||||
final public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount,
|
||||
@Nullable Argument argument) {
|
||||
VimPlugin.getChange().insertBeforeCursor(editor, context);
|
||||
|
@ -30,7 +30,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class InsertBeforeFirstNonBlankAction extends EditorAction {
|
||||
public InsertBeforeFirstNonBlankAction() {
|
||||
super(new ChangeEditorActionHandler() {
|
||||
super(new ChangeEditorActionHandler.SingleExecution() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
|
@ -34,11 +34,7 @@ public class InsertCharacterAboveCursorAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -34,11 +34,7 @@ public class InsertCharacterBelowCursorAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -34,11 +34,7 @@ public class InsertDeleteInsertedTextAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -34,11 +34,7 @@ public class InsertDeletePreviousWordAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -30,7 +30,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class InsertLineStartAction extends EditorAction {
|
||||
public InsertLineStartAction() {
|
||||
super(new ChangeEditorActionHandler() {
|
||||
super(new ChangeEditorActionHandler.SingleExecution() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
|
@ -33,7 +33,8 @@ public class InsertNewLineAboveAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
private static class Handler extends ChangeEditorActionHandler.SingleExecution {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @Nullable Argument argument) {
|
||||
if (editor.isOneLineMode()) {
|
||||
return false;
|
||||
|
@ -33,7 +33,8 @@ public class InsertNewLineBelowAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
private static class Handler extends ChangeEditorActionHandler.SingleExecution {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount,
|
||||
@Nullable Argument argument) {
|
||||
if (editor.isOneLineMode()) {
|
||||
|
@ -30,7 +30,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class InsertPreviousInsertAction extends EditorAction {
|
||||
public InsertPreviousInsertAction() {
|
||||
super(new ChangeEditorActionHandler() {
|
||||
super(new ChangeEditorActionHandler.SingleExecution() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
|
@ -30,7 +30,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class InsertPreviousInsertExitAction extends EditorAction {
|
||||
public InsertPreviousInsertExitAction() {
|
||||
super(new ChangeEditorActionHandler() {
|
||||
super(new ChangeEditorActionHandler.SingleExecution() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
|
@ -31,7 +31,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class AutoIndentLinesAction extends EditorAction {
|
||||
protected AutoIndentLinesAction() {
|
||||
super(new ChangeEditorActionHandler(true) {
|
||||
super(new ChangeEditorActionHandler.ForEachCaret() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -33,7 +33,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public class AutoIndentMotionAction extends EditorAction {
|
||||
protected AutoIndentMotionAction() {
|
||||
super(new ChangeEditorActionHandler(true) {
|
||||
super(new ChangeEditorActionHandler.ForEachCaret() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -34,11 +34,7 @@ public class ShiftLeftLinesAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -34,11 +34,7 @@ public class ShiftLeftMotionAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -34,11 +34,7 @@ public class ShiftRightLinesAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -34,11 +34,7 @@ public class ShiftRightMotionAction extends EditorAction {
|
||||
super(new Handler());
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler {
|
||||
public Handler() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
private static class Handler extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) {
|
||||
|
@ -31,7 +31,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PutTextAfterCursorAction extends EditorAction {
|
||||
public PutTextAfterCursorAction() {
|
||||
super(new ChangeEditorActionHandler() {
|
||||
super(new ChangeEditorActionHandler.SingleExecution() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
|
@ -32,7 +32,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PutTextAfterCursorActionMoveCursor extends EditorAction {
|
||||
public PutTextAfterCursorActionMoveCursor() {
|
||||
super(new ChangeEditorActionHandler() {
|
||||
super(new ChangeEditorActionHandler.SingleExecution() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
|
@ -32,7 +32,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PutTextAfterCursorNoIndentAction extends EditorAction {
|
||||
public PutTextAfterCursorNoIndentAction() {
|
||||
super(new ChangeEditorActionHandler() {
|
||||
super(new ChangeEditorActionHandler.SingleExecution() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
|
@ -32,7 +32,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PutTextBeforeCursorAction extends EditorAction {
|
||||
public PutTextBeforeCursorAction() {
|
||||
super(new ChangeEditorActionHandler() {
|
||||
super(new ChangeEditorActionHandler.SingleExecution() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
|
@ -32,7 +32,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PutTextBeforeCursorActionMoveCursor extends EditorAction {
|
||||
public PutTextBeforeCursorActionMoveCursor() {
|
||||
super(new ChangeEditorActionHandler() {
|
||||
super(new ChangeEditorActionHandler.SingleExecution() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
|
@ -32,7 +32,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PutTextBeforeCursorNoIndentAction extends EditorAction {
|
||||
public PutTextBeforeCursorNoIndentAction() {
|
||||
super(new ChangeEditorActionHandler() {
|
||||
super(new ChangeEditorActionHandler.SingleExecution() {
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
|
@ -16,88 +16,59 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.maddyhome.idea.vim.handler;
|
||||
package com.maddyhome.idea.vim.handler
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Caret;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.command.Argument;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.helper.EditorData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.helper.EditorData
|
||||
|
||||
sealed class ChangeEditorActionHandler : VimActionHandler(false) {
|
||||
|
||||
public abstract class ChangeEditorActionHandler extends VimActionHandler {
|
||||
private boolean myIsMulticaretChangeAction;
|
||||
|
||||
public ChangeEditorActionHandler(boolean runForEachCaret) {
|
||||
super(false);
|
||||
myIsMulticaretChangeAction = runForEachCaret;
|
||||
abstract class ForEachCaret : ChangeEditorActionHandler() {
|
||||
abstract fun execute(editor: Editor, caret: Caret, context: DataContext, count: Int, rawCount: Int, argument: Argument?): Boolean
|
||||
}
|
||||
|
||||
public ChangeEditorActionHandler() {
|
||||
this(false);
|
||||
abstract class SingleExecution : ChangeEditorActionHandler() {
|
||||
abstract fun execute(editor: Editor, context: DataContext, count: Int, rawCount: Int, argument: Argument?): Boolean
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
final override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
|
||||
// Here we have to save the last changed command. This should be done separately for each
|
||||
// call of the task, not for each caret. Currently there is no way to schedule any action
|
||||
// to be worked after each task. So here we override the deprecated execute function which
|
||||
// is called for each task and call the handlers for each caret, if implemented.
|
||||
|
||||
EditorData.setChangeSwitchMode(editor, null);
|
||||
EditorData.setChangeSwitchMode(editor, null)
|
||||
|
||||
final Ref<Boolean> worked = Ref.create(true);
|
||||
if (myIsMulticaretChangeAction) {
|
||||
editor.getCaretModel().runForEachCaret(caret -> {
|
||||
try {
|
||||
if (!execute(editor, caret, context, cmd.getCount(), cmd.getRawCount(), cmd.getArgument())) {
|
||||
worked.set(false);
|
||||
val worked = Ref.create(true)
|
||||
when (this) {
|
||||
is ForEachCaret -> {
|
||||
editor.caretModel.runForEachCaret({ caret ->
|
||||
if (!execute(editor, caret, context, cmd.count, cmd.rawCount, cmd.argument)) {
|
||||
worked.set(false)
|
||||
}
|
||||
}
|
||||
catch (ExecuteMethodNotOverriddenException e) {
|
||||
worked.set(false);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
worked.set(execute(editor, context, cmd.getCount(), cmd.getRawCount(), cmd.getArgument()));
|
||||
}, true)
|
||||
}
|
||||
catch (ExecuteMethodNotOverriddenException e) {
|
||||
return false;
|
||||
is SingleExecution -> {
|
||||
worked.set(execute(editor, context, cmd.count, cmd.rawCount, cmd.argument))
|
||||
}
|
||||
}
|
||||
|
||||
if (worked.get()) {
|
||||
CommandState.getInstance(editor).saveLastChangeCommand(cmd);
|
||||
CommandState.getInstance(editor).saveLastChangeCommand(cmd)
|
||||
}
|
||||
|
||||
CommandState.Mode toSwitch = EditorData.getChangeSwitchMode(editor);
|
||||
val toSwitch = EditorData.getChangeSwitchMode(editor)
|
||||
if (toSwitch != null) {
|
||||
VimPlugin.getChange().processPostChangeModeSwitch(editor, context, toSwitch);
|
||||
VimPlugin.getChange().processPostChangeModeSwitch(editor, context, toSwitch)
|
||||
}
|
||||
|
||||
return worked.get();
|
||||
}
|
||||
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount,
|
||||
@Nullable Argument argument) throws ExecuteMethodNotOverriddenException {
|
||||
if (!myIsMulticaretChangeAction) {
|
||||
throw new ExecuteMethodNotOverriddenException(this.getClass());
|
||||
}
|
||||
return execute(editor, editor.getCaretModel().getPrimaryCaret(), context, count, rawCount, argument);
|
||||
}
|
||||
|
||||
public boolean execute(@NotNull Editor editor, @NotNull Caret caret, @NotNull DataContext context, int count,
|
||||
int rawCount, @Nullable Argument argument) throws ExecuteMethodNotOverriddenException {
|
||||
if (myIsMulticaretChangeAction) {
|
||||
throw new ExecuteMethodNotOverriddenException(this.getClass());
|
||||
}
|
||||
return execute(editor, context, count, rawCount, argument);
|
||||
return worked.get()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user