// Path: src/org/hunmr/acejump/command/ObtainAndPasteRangeAfterJumpCommand.java
// public class ObtainAndPasteRangeAfterJumpCommand extends CommandAroundJump {
// 
//     private final Class<? extends Selector> _selectorClass;
// 
//     public ObtainAndPasteRangeAfterJumpCommand(Editor editor, Class<? extends Selector> selectorClass) {
//         super(editor);
//         _selectorClass = selectorClass;
//     }
// 
//     @Override
//     public void afterJump() {
//         final Runnable runnable = new Runnable() {
//             @Override
//             public void run() {
//                 EditorUtils.copyRange(_selectorClass, _te);
//                 focusSourceCaret();
// 
//                 EditorUtils.selectRangeOf(_selectorClass, _se);
//                 EditorUtils.deleteRange(_selectorClass, _se);
//                 TextRange[] tr = EditorCopyPasteHelperImpl.getInstance().pasteFromClipboard(_se);
// 
//                 if (_config._needSelectTextAfterJump) {
//                     EditorUtils.selectTextRange(_se, tr);
//                 }
//             }
//         };
// 
//         AppUtil.runWriteAction(runnable, _se);
//     }
// }
// 
// Path: src/org/hunmr/common/selector/Selector.java
// public abstract class Selector {
// 
//     protected Editor _editor;
//     protected final String _docText;
//     protected final Document _document;
// 
//     public Selector(Editor editor) {
//         _editor = editor;
//         _document = _editor.getDocument();
//         _docText = _document.getText();
//     }
// 
//     public abstract TextRange getRange(CommandContext cmdCtx);
// 
//     protected boolean isCaretBetweenSpaces(Editor editor) {
//         int caretOffset = editor.getCaretModel().getOffset();
//         int textLength = _docText.length();
// 
//         return caretOffset - 1 > 0
//                 && caretOffset + 1 < textLength
//                 && Character.isWhitespace(charAt(caretOffset - 1))
//                 && Character.isWhitespace(charAt(caretOffset + 1));
//     }
// 
//     protected int getNearestStringEndOffset(Editor editor) {
//         int offset = editor.getCaretModel().getOffset();
// 
//         if (isCaretBetweenSpaces(editor)) {
//             while (offset > 0 && Character.isWhitespace(charAt(offset - 1))) {
//                 offset--;
//             }
//         }
// 
//         return offset;
//     }
// 
//     protected char charAt(int index) {
//         return _docText.charAt(index);
//     }
// 
//     protected boolean caretIsAtEdge() {
//         int offset = _editor.getCaretModel().getOffset();
//         return offset == 0 || offset == _docText.length();
//     }
// }


import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.Editor;
import org.hunmr.acejump.command.ObtainAndPasteRangeAfterJumpCommand;
import org.hunmr.common.selector.Selector;
package org.hunmr.acejump;


public class AceJumpObtainThenReplaceRangeAction extends AnAction {
    @Override
    public void actionPerformed(AnActionEvent e) {
        Editor editor = e.getData(PlatformDataKeys.EDITOR);

        String actionId = e.getActionManager().getId(this);
        String selectorClassName = "org.hunmr.common.selector."
                                   + actionId.substring("emacsIDEAs.AceJumpObtainThenReplace.".length())
                                   + "Selector";

        try {
            Class<? extends Selector> selectorClass = (Class<? extends Selector>) Class.forName(selectorClassName);
// Path: src/org/hunmr/acejump/command/ObtainAndPasteRangeAfterJumpCommand.java
// public class ObtainAndPasteRangeAfterJumpCommand extends CommandAroundJump {
// 
//     private final Class<? extends Selector> _selectorClass;
// 
//     public ObtainAndPasteRangeAfterJumpCommand(Editor editor, Class<? extends Selector> selectorClass) {
//         super(editor);
//         _selectorClass = selectorClass;
//     }
// 
//     @Override
//     public void afterJump() {
//         final Runnable runnable = new Runnable() {
//             @Override
//             public void run() {
//                 EditorUtils.copyRange(_selectorClass, _te);
//                 focusSourceCaret();
// 
//                 EditorUtils.selectRangeOf(_selectorClass, _se);
//                 EditorUtils.deleteRange(_selectorClass, _se);
//                 TextRange[] tr = EditorCopyPasteHelperImpl.getInstance().pasteFromClipboard(_se);
// 
//                 if (_config._needSelectTextAfterJump) {
//                     EditorUtils.selectTextRange(_se, tr);
//                 }
//             }
//         };
// 
//         AppUtil.runWriteAction(runnable, _se);
//     }
// }
// 
// Path: src/org/hunmr/common/selector/Selector.java
// public abstract class Selector {
// 
//     protected Editor _editor;
//     protected final String _docText;
//     protected final Document _document;
// 
//     public Selector(Editor editor) {
//         _editor = editor;
//         _document = _editor.getDocument();
//         _docText = _document.getText();
//     }
// 
//     public abstract TextRange getRange(CommandContext cmdCtx);
// 
//     protected boolean isCaretBetweenSpaces(Editor editor) {
//         int caretOffset = editor.getCaretModel().getOffset();
//         int textLength = _docText.length();
// 
//         return caretOffset - 1 > 0
//                 && caretOffset + 1 < textLength
//                 && Character.isWhitespace(charAt(caretOffset - 1))
//                 && Character.isWhitespace(charAt(caretOffset + 1));
//     }
// 
//     protected int getNearestStringEndOffset(Editor editor) {
//         int offset = editor.getCaretModel().getOffset();
// 
//         if (isCaretBetweenSpaces(editor)) {
//             while (offset > 0 && Character.isWhitespace(charAt(offset - 1))) {
//                 offset--;
//             }
//         }
// 
//         return offset;
//     }
// 
//     protected char charAt(int index) {
//         return _docText.charAt(index);
//     }
// 
//     protected boolean caretIsAtEdge() {
//         int offset = _editor.getCaretModel().getOffset();
//         return offset == 0 || offset == _docText.length();
//     }
// }


// Path: src/org/hunmr/acejump/AceJumpObtainThenReplaceRangeAction.java
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.Editor;
import org.hunmr.acejump.command.ObtainAndPasteRangeAfterJumpCommand;
import org.hunmr.common.selector.Selector;

package org.hunmr.acejump;


public class AceJumpObtainThenReplaceRangeAction extends AnAction {
    @Override
    public void actionPerformed(AnActionEvent e) {
        Editor editor = e.getData(PlatformDataKeys.EDITOR);

        String actionId = e.getActionManager().getId(this);
        String selectorClassName = "org.hunmr.common.selector."
                                   + actionId.substring("emacsIDEAs.AceJumpObtainThenReplace.".length())
                                   + "Selector";

        try {
            Class<? extends Selector> selectorClass = (Class<? extends Selector>) Class.forName(selectorClassName);
            AceJumpAction.getInstance().switchEditorIfNeed(e);