@Override public Result preprocessEnter( @NotNull PsiFile psiFile, @NotNull Editor editor, @NotNull Ref<Integer> caretOffset, @NotNull Ref<Integer> caretOffsetChange, @NotNull DataContext dataContext, @Nullable EditorActionHandler originalHandler) { if (psiFile instanceof SoyFile && isBetweenSiblingTags(psiFile, caretOffset.get())) { if (originalHandler != null) { originalHandler.execute(editor, dataContext); } return Result.Default; } return Result.Continue; }
@Override public void executeWriteAction(@NotNull Editor editor, Caret caret, DataContext dataContext) { final Document document = editor.getDocument(); final int caretOffset = editor.getCaretModel().getOffset(); if (caretOffset < 1) { return; } final SelectionModel selectionModel = editor.getSelectionModel(); final CharSequence text = document.getCharsSequence(); final char c = text.charAt(caretOffset - 1); if (!selectionModel.hasSelection() && StringUtil.isWhiteSpace(c)) { int startOffset = CharArrayUtil.shiftBackward(text, caretOffset - 2, "\t \n") + 1; document.deleteString(startOffset, caretOffset); } else { final EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE); handler.execute(editor, caret, dataContext); } }
@Override public Result preprocessEnter(@NotNull final PsiFile file, @NotNull final Editor editor, @NotNull final Ref<Integer> caretOffsetRef, @NotNull final Ref<Integer> caretAdvance, @NotNull final DataContext dataContext, final EditorActionHandler originalHandler) { int caretOffset = caretOffsetRef.get(); if (!isApplicable(file, caretOffset)) { return Result.Continue; } int maxRBraceCount = getMaxRBraceCount(file, editor, caretOffset); if (maxRBraceCount > 0) { insertRBraces(file, editor, caretOffset, getRBraceOffset(file, editor, caretOffset), adjustRBraceCountForPosition(editor, caretOffset, maxRBraceCount)); return Result.DefaultForceIndent; } return Result.Continue; }
@Override public Result preprocessEnter(@NotNull PsiFile file, @NotNull Editor editor, @NotNull Ref<Integer> caretOffset, @NotNull Ref<Integer> caretAdvance, @NotNull DataContext dataContext, EditorActionHandler originalHandler) { int offset = caretOffset.get(); if (editor instanceof EditorWindow) { file = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(file); editor = InjectedLanguageUtil.getTopLevelEditor(editor); offset = editor.getCaretModel().getOffset(); } if (!(file instanceof PyFile)) { return Result.Continue; } // honor dedent (PY-3009) if (BackspaceHandler.isWhitespaceBeforeCaret(editor)) { return Result.DefaultSkipIndent; } return Result.Continue; }
protected static boolean handleEnter(Editor editor, DataContext dataContext, @NotNull Project project, EditorActionHandler originalHandler) { if (HandlerUtils.isReadOnly(editor)) { return false; } int caretOffset = editor.getCaretModel().getOffset(); if (caretOffset < 1) return false; if (handleBetweenSquareBraces(editor, caretOffset, dataContext, project, originalHandler)) { return true; } if (handleInString(editor, caretOffset, dataContext, originalHandler)) { return true; } return false; }
private static boolean handleBetweenSquareBraces(Editor editor, int caret, DataContext context, Project project, EditorActionHandler originalHandler) { String text = editor.getDocument().getText(); if (text == null || text.isEmpty()) return false; final EditorHighlighter highlighter = ((EditorEx)editor).getHighlighter(); if (caret < 1 || caret > text.length() - 1) { return false; } HighlighterIterator iterator = highlighter.createIterator(caret - 1); if (GroovyTokenTypes.mLBRACK == iterator.getTokenType()) { if (text.length() > caret) { iterator = highlighter.createIterator(caret); if (GroovyTokenTypes.mRBRACK == iterator.getTokenType()) { originalHandler.execute(editor, context); originalHandler.execute(editor, context); editor.getCaretModel().moveCaretRelatively(0, -1, false, false, true); insertSpacesByGroovyContinuationIndent(editor, project); return true; } } } return false; }
private void runPasteAction(final String toPaste) { final Producer<Transferable> producer = new Producer<Transferable>() { @Nullable @Override public Transferable produce() { return new StringSelection(toPaste); } }; EditorActionManager actionManager = EditorActionManager.getInstance(); EditorActionHandler pasteActionHandler = actionManager.getActionHandler(ACTION_EDITOR_PASTE); final PasteHandler pasteHandler = new PasteHandler(pasteActionHandler); new WriteCommandAction.Simple(getProject(), new PsiFile[0]) { protected void run() throws Throwable { Component component = myFixture.getEditor().getComponent(); DataContext dataContext = DataManager.getInstance().getDataContext(component); pasteHandler.execute(myFixture.getEditor(), dataContext, producer); } }.execute(); }
@Override public Result preprocessEnter(@NotNull PsiFile file, @NotNull Editor editor, @NotNull Ref<Integer> caretOffset, @NotNull Ref<Integer> caretAdvance, @NotNull DataContext dataContext, @Nullable EditorActionHandler originalHandler) { // if we have something right now, use it, but don't wait for anything final Eddy.Output output = EddyFileListener.getOutputFor(editor); if (output == null) return Result.Continue; // only do this if a hint is showing if (!EddyFileListener.isHintShowing()) { return Result.Continue; } // check if we should be auto-applying if (!output.shouldAutoApply()) return Result.Continue; Project project = editor.getProject(); if (project == null) return Result.Continue; int co = editor.getCaretModel().getCurrentCaret().getOffset(); // autoExecute will commit the document caretOffset.set(caretOffset.get() - co + output.autoApply()); return Result.DefaultSkipIndent; }
@Override public void selectWordAtCaret(boolean honorCamelWordsSettings) { validateContext(true); removeSelection(); final EditorSettings settings = myEditor.getSettings(); boolean camelTemp = settings.isCamelWords(); final boolean needOverrideSetting = camelTemp && !honorCamelWordsSettings; if (needOverrideSetting) { settings.setCamelWords(false); } try { EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler( IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET); handler.execute(myEditor, myEditor.getDataContext()); } finally { if (needOverrideSetting) { settings.resetCamelWords(); } } }
static void truncatePrefix(final DataContext dataContext, LookupImpl lookup, final EditorActionHandler handler, final int hideOffset) { final Editor editor = lookup.getEditor(); if (!lookup.performGuardedChange(new Runnable() { @Override public void run() { handler.execute(editor, dataContext); } })) { return; } final CompletionProgressIndicator process = CompletionServiceImpl.getCompletionService().getCurrentCompletion(); if (lookup.truncatePrefix(process == null || !process.isAutopopupCompletion())) { return; } if (process != null) { if (hideOffset < editor.getCaretModel().getOffset()) { process.scheduleRestart(); return; } process.prefixUpdated(); } lookup.hide(); }
private static boolean handleBetweenSquareBraces(Editor editor, int caret, DataContext context, Project project, EditorActionHandler originalHandler) { String text = editor.getDocument().getText(); if (text == null || text.length() == 0) return false; final EditorHighlighter highlighter = ((EditorEx)editor).getHighlighter(); if (caret < 1 || caret > text.length() - 1) { return false; } HighlighterIterator iterator = highlighter.createIterator(caret - 1); if (mLBRACK == iterator.getTokenType()) { if (text.length() > caret) { iterator = highlighter.createIterator(caret); if (mRBRACK == iterator.getTokenType()) { originalHandler.execute(editor, context); originalHandler.execute(editor, context); editor.getCaretModel().moveCaretRelatively(0, -1, false, false, true); insertSpacesByGroovyContinuationIndent(editor, project); return true; } } } return false; }
@Override @RequiredDispatchThread public Result preprocessEnter(@NotNull final PsiFile file, @NotNull final Editor editor, @NotNull final Ref<Integer> caretOffsetRef, @NotNull final Ref<Integer> caretAdvance, @NotNull final DataContext dataContext, final EditorActionHandler originalHandler) { final int caretOffset = caretOffsetRef.get(); final Document document = editor.getDocument(); final PsiElement psiAtOffset = file.findElementAt(caretOffset); final PsiElement probablyDocComment = psiAtOffset instanceof PsiWhiteSpace && psiAtOffset.getText().startsWith("\n") ? psiAtOffset.getPrevSibling() : psiAtOffset == null && caretOffset > 0 && caretOffset == document.getTextLength() ? file.findElementAt(caretOffset - 1) : psiAtOffset; if(probablyDocComment != null && PsiTreeUtil.getParentOfType(probablyDocComment, CSharpDocRoot.class, false) != null) { document.insertString(caretOffset, DOC_LINE_START + " "); caretAdvance.set(4); return Result.Default; } return Result.Continue; }
@Override public void executeWriteAction(@Nonnull Editor editor, Caret caret, DataContext dataContext) { final Document document = editor.getDocument(); final int caretOffset = editor.getCaretModel().getOffset(); if (caretOffset < 1) { return; } final SelectionModel selectionModel = editor.getSelectionModel(); final CharSequence text = document.getCharsSequence(); final char c = text.charAt(caretOffset - 1); if (!selectionModel.hasSelection() && StringUtil.isWhiteSpace(c)) { int startOffset = CharArrayUtil.shiftBackward(text, caretOffset - 2, "\t \n") + 1; document.deleteString(startOffset, caretOffset); } else { final EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE); handler.execute(editor, caret, dataContext); } }
@Override public void selectWordAtCaret(final boolean honorCamelWordsSettings) { validateContext(true); myEditor.getCaretModel().doWithCaretMerging(() -> { removeSelection(); final EditorSettings settings = myEditor.getSettings(); boolean camelTemp = settings.isCamelWords(); final boolean needOverrideSetting = camelTemp && !honorCamelWordsSettings; if (needOverrideSetting) { settings.setCamelWords(false); } try { EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET); handler.execute(myEditor, this, myEditor.getDataContext()); } finally { if (needOverrideSetting) { settings.resetCamelWords(); } } }); }
@Override public Result preprocessEnter(@Nonnull final PsiFile file, @Nonnull final Editor editor, @Nonnull final Ref<Integer> caretOffsetRef, @Nonnull final Ref<Integer> caretAdvance, @Nonnull final DataContext dataContext, final EditorActionHandler originalHandler) { int caretOffset = caretOffsetRef.get(); if (!isApplicable(file, caretOffset)) { return Result.Continue; } int maxRBraceCount = getMaxRBraceCount(file, editor, caretOffset); if (maxRBraceCount > 0) { insertRBraces(file, editor, caretOffset, getRBraceOffset(file, editor, caretOffset), generateStringToInsert(editor, caretOffset, maxRBraceCount)); return Result.DefaultForceIndent; } return Result.Continue; }
public Result preprocessEnter(@NotNull final PsiFile file, @NotNull final Editor editor, @NotNull final Ref<Integer> caretOffset, @NotNull final Ref<Integer> caretAdvance, @NotNull final DataContext dataContext, final EditorActionHandler originalHandler) { /** * if we are between open and close tags, we ensure the caret ends up in the "logical" place on Enter. * i.e. "{#foo}<caret>{/foo}" becomes the following on Enter: * * {#foo} * <caret> * {/foo} * * (Note: <caret> may be indented depending on formatter settings.) */ if (file instanceof DustFile && isBetweenHbTags(editor, file, caretOffset.get())) { originalHandler.execute(editor, dataContext); return Result.Default; } return Result.Continue; }
@Override public boolean doEnter(Editor editor, PsiElement psiElement, boolean isModified) { PsiElement parent = psiElement.getParent(); if (!(parent instanceof PsiCodeBlock)) { return false; } final ASTNode node = psiElement.getNode(); if (node != null && CONTROL_FLOW_ELEMENT_TYPES.contains(node.getElementType())) { return false; } boolean leaveCodeBlock = isControlFlowBreak(psiElement); if (!leaveCodeBlock) { return false; } final int offset = parent.getTextRange().getEndOffset(); // Check if there is empty line after the code block. Just move caret there in the case of the positive answer. final CharSequence text = editor.getDocument().getCharsSequence(); if (offset < text.length() - 1) { final int i = CharArrayUtil.shiftForward(text, offset + 1, " \t"); if (i < text.length() && text.charAt(i) == '\n') { editor.getCaretModel().moveToOffset(offset + 1); EditorActionManager actionManager = EditorActionManager.getInstance(); EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_MOVE_LINE_END); final DataContext dataContext = DataManager.getInstance().getDataContext(editor.getComponent()); if (dataContext != null) { actionHandler.execute(editor, dataContext); return true; } } } editor.getCaretModel().moveToOffset(offset); return false; }
static boolean expandCodeBlock(Editor editor, PsiElement psiElement) { PsiCodeBlock block = getControlStatementBlock(editor.getCaretModel().getOffset(), psiElement); if (processExistingBlankLine(editor, block, psiElement)) { return true; } if (block == null) { return false; } EditorActionHandler enterHandler = getEnterHandler(IdeActions.ACTION_EDITOR_START_NEW_LINE); PsiElement firstElement = block.getFirstBodyElement(); if (firstElement == null) { firstElement = block.getRBrace(); // Plain enter processor inserts enter after the end of line, hence, we don't want to use it here because the line ends with // the empty braces block. So, we get the following in case of default handler usage: // Before: // if (condition[caret]) {} // After: // if (condition) {} // [caret] enterHandler = getEnterHandler(IdeActions.ACTION_EDITOR_ENTER); } editor.getCaretModel().moveToOffset(firstElement != null ? firstElement.getTextRange().getStartOffset() : block.getTextRange().getEndOffset()); enterHandler.execute(editor, ((EditorEx)editor).getDataContext()); return true; }
@Override public void selectWordAtCaret(final boolean honorCamelWordsSettings) { removeSelection(); EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler( IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET); handler.execute(myEditor, DataManager.getInstance().getDataContext(myEditor.getComponent())); }
@Override public void selectWordAtCaret(final boolean honorCamelWordsSettings) { validateContext(true); myEditor.getCaretModel().doWithCaretMerging(new Runnable() { @Override public void run() { removeSelection(); final EditorSettings settings = myEditor.getSettings(); boolean camelTemp = settings.isCamelWords(); final boolean needOverrideSetting = camelTemp && !honorCamelWordsSettings; if (needOverrideSetting) { settings.setCamelWords(false); } try { EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET); handler.execute(myEditor, CaretImpl.this, myEditor.getDataContext()); } finally { if (needOverrideSetting) { settings.resetCamelWords(); } } } }); }
@Override public Result preprocessEnter(@NotNull final PsiFile file, @NotNull final Editor editor, @NotNull final Ref<Integer> caretOffsetRef, @NotNull final Ref<Integer> caretAdvance, @NotNull final DataContext dataContext, final EditorActionHandler originalHandler) { int caretOffset = caretOffsetRef.get().intValue(); PsiElement psiAtOffset = file.findElementAt(caretOffset); if (psiAtOffset != null && psiAtOffset.getTextOffset() < caretOffset) { ASTNode token = psiAtOffset.getNode(); Document document = editor.getDocument(); CharSequence text = document.getText(); final Language language = psiAtOffset.getLanguage(); final Commenter languageCommenter = LanguageCommenters.INSTANCE.forLanguage(language); final CodeDocumentationAwareCommenter commenter = languageCommenter instanceof CodeDocumentationAwareCommenter ? (CodeDocumentationAwareCommenter)languageCommenter:null; if (commenter != null && token.getElementType() == commenter.getLineCommentTokenType() ) { final int offset = CharArrayUtil.shiftForward(text, caretOffset, " \t"); if (offset < document.getTextLength() && text.charAt(offset) != '\n') { String prefix = commenter.getLineCommentPrefix(); assert prefix != null: "Line Comment type is set but Line Comment Prefix is null!"; if (!StringUtil.startsWith(text, offset, prefix)) { if (text.charAt(caretOffset) != ' ' && !prefix.endsWith(" ")) { prefix += " "; } document.insertString(caretOffset, prefix); return Result.Default; } else { int afterPrefix = offset + prefix.length(); if (afterPrefix < document.getTextLength() && text.charAt(afterPrefix) != ' ') { document.insertString(afterPrefix, " "); //caretAdvance.set(0); } caretOffsetRef.set(offset); } return Result.Default; } } } return Result.Continue; }
@Override public Result preprocessEnter(@NotNull PsiFile file, @NotNull Editor editor, @NotNull Ref<Integer> caretOffset, @NotNull Ref<Integer> caretAdvance, @NotNull DataContext dataContext, EditorActionHandler originalHandler) { return Result.Continue; }
static void truncatePrefix(final DataContext dataContext, LookupImpl lookup, final EditorActionHandler handler, final int hideOffset, final Caret caret) { final Editor editor = lookup.getEditor(); if (!lookup.performGuardedChange(new Runnable() { @Override public void run() { handler.execute(editor, caret, dataContext); } })) { return; } final CompletionProgressIndicator process = CompletionServiceImpl.getCompletionService().getCurrentCompletion(); if (lookup.truncatePrefix(process == null || !process.isAutopopupCompletion())) { return; } if (process != null) { if (hideOffset < editor.getCaretModel().getOffset()) { process.scheduleRestart(); return; } process.prefixUpdated(); } lookup.hideLookup(false); }
@Override public Result preprocessEnter(@NotNull PsiFile file, @NotNull Editor editor, @NotNull Ref<Integer> caretOffsetRef, @NotNull Ref<Integer> caretAdvance, @NotNull DataContext dataContext, EditorActionHandler originalHandler) { if (!file.getLanguage().is(JsonLanguage.INSTANCE)) { return Result.Continue; } return super.preprocessEnter(file, editor, caretOffsetRef, caretAdvance, dataContext, originalHandler); }
@Override public Result preprocessEnter(@NotNull PsiFile file, @NotNull Editor editor, @NotNull Ref<Integer> caretOffsetRef, @NotNull Ref<Integer> caretAdvance, @NotNull DataContext dataContext, EditorActionHandler originalHandler) { if (!file.getLanguage().is(PythonLanguage.getInstance())) { return Result.Continue; } return super.preprocessEnter(file, editor, caretOffsetRef, caretAdvance, dataContext, originalHandler); }
private void doTest(String ext) throws Exception { final String baseName = getBasePath() + '/' + getTestName(true); final String fileName = baseName + "."+ext; @NonNls String afterFileName = baseName + "_afterUp." + ext; EditorActionHandler handler = new MoveStatementUpAction().getHandler(); performAction(fileName, handler, afterFileName); afterFileName = baseName + "_afterDown." + ext; handler = new MoveStatementDownAction().getHandler(); performAction(fileName, handler, afterFileName); }
private void performAction(final String fileName, final EditorActionHandler handler, final String afterFileName) throws Exception { configureByFile(fileName); final boolean enabled = handler.isEnabled(myEditor, null); assertEquals("not enabled for " + afterFileName, new File(getTestDataPath(), afterFileName).exists(), enabled); if (enabled) { WriteCommandAction.runWriteCommandAction(null, new Runnable() { @Override public void run() { handler.execute(myEditor, null); } }); checkResultByFile(afterFileName); } }
@Override public Result preprocessEnter(@NotNull final PsiFile file, @NotNull final Editor editor, @NotNull final Ref<Integer> caretOffset, @NotNull final Ref<Integer> caretAdvance, @NotNull final DataContext dataContext, final EditorActionHandler originalHandler) { final Project project = CommonDataKeys.PROJECT.getData(dataContext); if ((file instanceof XmlFile || HtmlUtil.supportsXmlTypedHandlers(file)) && isBetweenXmlTags(project, editor, file, caretOffset.get().intValue())) { editor.getDocument().insertString(caretOffset.get(), "\n"); if (project != null) { CodeStyleManager.getInstance(project).adjustLineIndent(editor.getDocument(), caretOffset.get() + 1); } return Result.DefaultForceIndent; } return Result.Continue; }
public Forward() { super(new EditorActionHandler(true) { @Override protected void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) { EmmetEditPointUtil.moveForward(editor, getFile(dataContext)); } }); }
public Backward() { super(new EditorActionHandler(true) { @Override protected void doExecute(Editor editor, @Nullable Caret caret, DataContext dataContext) { EmmetEditPointUtil.moveBackward(editor, getFile(dataContext)); } }); }
public Result preprocessEnter(@NotNull final PsiFile file, @NotNull final Editor editor, @NotNull final Ref<Integer> caretOffsetRef, @NotNull final Ref<Integer> caretAdvance, @NotNull final DataContext dataContext, final EditorActionHandler originalHandler) { int caretOffset = caretOffsetRef.get().intValue(); PsiElement psiAtOffset = file.findElementAt(caretOffset); if (file instanceof PropertiesFile) { handleEnterInPropertiesFile(editor, editor.getDocument(), psiAtOffset, caretOffset); return Result.Stop; } return Result.Continue; }
private static void insertLineFeedInString(Editor editor, DataContext dataContext, EditorActionHandler originalHandler, boolean isInsertIndent) { if (isInsertIndent) { originalHandler.execute(editor, dataContext); } else { EditorModificationUtil.insertStringAtCaret(editor, "\n"); } }
public static boolean isEnabled(@NotNull final Editor editor, @NotNull final DataContext dataContext, @Nullable final EditorActionHandler originalHandler) { final Project project = getProject(dataContext); if (project != null) { final Language language = PsiUtilBase.getLanguageInEditor(editor, project); if (language == GroovyLanguage.INSTANCE) { return true; } } return originalHandler == null || originalHandler.isEnabled(editor, dataContext); }
@Override public Result preprocessEnter( PsiFile file, Editor editor, Ref<Integer> caretOffset, Ref<Integer> caretAdvance, DataContext dataContext, EditorActionHandler originalHandler) { int offset = caretOffset.get(); if (editor instanceof EditorWindow) { file = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(file); editor = InjectedLanguageUtil.getTopLevelEditor(editor); offset = editor.getCaretModel().getOffset(); } if (!isApplicable(file, dataContext) || !insertIndent(file, offset)) { return Result.Continue; } int indent = SectionParser.INDENT; editor.getCaretModel().moveToOffset(offset); Document doc = editor.getDocument(); PsiDocumentManager.getInstance(file.getProject()).commitDocument(doc); originalHandler.execute(editor, editor.getCaretModel().getCurrentCaret(), dataContext); LogicalPosition position = editor.getCaretModel().getLogicalPosition(); if (position.column < indent) { String spaces = StringUtil.repeatSymbol(' ', indent - position.column); doc.insertString(editor.getCaretModel().getOffset(), spaces); } editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(position.line, indent)); return Result.Stop; }
@Override public Result preprocessEnter( @NotNull PsiFile file, @NotNull Editor editor, @NotNull Ref<Integer> caretOffsetRef, @NotNull Ref<Integer> caretAdvance, @NotNull DataContext dataContext, EditorActionHandler originalHandler) { if (!(file instanceof BuildFile)) { return Result.Continue; } return super.preprocessEnter( file, editor, caretOffsetRef, caretAdvance, dataContext, originalHandler); }
@Override public Result preprocessEnter(@NotNull PsiFile file, @NotNull Editor editor, @NotNull Ref<Integer> caretOffsetRef, @NotNull Ref<Integer> caretAdvance, @NotNull DataContext dataContext, EditorActionHandler originalHandler) { if (!file.getLanguage().is(JSGraphQLLanguage.INSTANCE)) { return Result.Continue; } return super.preprocessEnter(file, editor, caretOffsetRef, caretAdvance, dataContext, originalHandler); }
public AlignItAction() { super(new EditorActionHandler() { @Override public void execute(Editor editor, DataContext dataContext) { Application application = ApplicationManager.getApplication(); FrontEndAlignment alignment = application.getComponent(FrontEndAlignment.class); alignment.alignText(editor); } }); }
protected void backspace(final Editor editor) { CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() { @Override public void run() { EditorActionManager actionManager = EditorActionManager.getInstance(); EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE); actionHandler.execute(editor, DataManager.getInstance().getDataContext()); } }, "backspace", editor.getDocument()); }
protected void delete(@NotNull final Editor editor) { CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() { @Override public void run() { EditorActionManager actionManager = EditorActionManager.getInstance(); EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_DELETE); actionHandler.execute(editor, DataManager.getInstance().getDataContext()); } }, "delete", editor.getDocument()); }