Search in sources :

Example 1 with EditorActionHandler

use of com.intellij.openapi.editor.actionSystem.EditorActionHandler in project idea-handlebars by dmarcotte.

the class HbActionHandlerTest method doEnterTest.

/**
   * Call this method to test behavior when Enter is typed.
   * See class documentation for more info: {@link HbActionHandlerTest}
   */
protected void doEnterTest(@NotNull String before, @NotNull String expected) {
    final EditorActionHandler enterActionHandler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_ENTER);
    doExecuteActionTest(before, expected, new Runnable() {

        @Override
        public void run() {
            enterActionHandler.execute(myFixture.getEditor(), ((EditorEx) myFixture.getEditor()).getDataContext());
        }
    });
}
Also used : EditorEx(com.intellij.openapi.editor.ex.EditorEx) EditorActionHandler(com.intellij.openapi.editor.actionSystem.EditorActionHandler)

Example 2 with EditorActionHandler

use of com.intellij.openapi.editor.actionSystem.EditorActionHandler in project intellij-community by JetBrains.

the class CustomFileTypeEditorTest method performEndBlockAction.

private static void performEndBlockAction() {
    EditorActionHandler actionHandler = new CodeBlockEndAction().getHandler();
    actionHandler.execute(getEditor(), getCurrentEditorDataContext());
}
Also used : CodeBlockEndAction(com.intellij.codeInsight.editorActions.CodeBlockEndAction) EditorActionHandler(com.intellij.openapi.editor.actionSystem.EditorActionHandler)

Example 3 with EditorActionHandler

use of com.intellij.openapi.editor.actionSystem.EditorActionHandler in project intellij-community by JetBrains.

the class LeaveCodeBlockEnterProcessor method doEnter.

@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;
}
Also used : EditorActionManager(com.intellij.openapi.editor.actionSystem.EditorActionManager) PsiCodeBlock(com.intellij.psi.PsiCodeBlock) DataContext(com.intellij.openapi.actionSystem.DataContext) ASTNode(com.intellij.lang.ASTNode) EditorActionHandler(com.intellij.openapi.editor.actionSystem.EditorActionHandler) PsiElement(com.intellij.psi.PsiElement)

Example 4 with EditorActionHandler

use of com.intellij.openapi.editor.actionSystem.EditorActionHandler in project intellij-community by JetBrains.

the class GenerateJavadocTest method performAction.

private void performAction() {
    EditorActionManager actionManager = EditorActionManager.getInstance();
    EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_ENTER);
    actionHandler.execute(myEditor, DataManager.getInstance().getDataContext());
}
Also used : EditorActionManager(com.intellij.openapi.editor.actionSystem.EditorActionManager) EditorActionHandler(com.intellij.openapi.editor.actionSystem.EditorActionHandler)

Example 5 with EditorActionHandler

use of com.intellij.openapi.editor.actionSystem.EditorActionHandler in project intellij-community by JetBrains.

the class TextComponentSelectionModel method selectWordAtCaret.

@Override
public void selectWordAtCaret(final boolean honorCamelWordsSettings) {
    removeSelection();
    EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET);
    handler.execute(myEditor, null, DataManager.getInstance().getDataContext(myEditor.getComponent()));
}
Also used : EditorActionHandler(com.intellij.openapi.editor.actionSystem.EditorActionHandler)

Aggregations

EditorActionHandler (com.intellij.openapi.editor.actionSystem.EditorActionHandler)16 EditorActionManager (com.intellij.openapi.editor.actionSystem.EditorActionManager)7 ASTNode (com.intellij.lang.ASTNode)2 DataContext (com.intellij.openapi.actionSystem.DataContext)2 EditorEx (com.intellij.openapi.editor.ex.EditorEx)2 CodeBlockEndAction (com.intellij.codeInsight.editorActions.CodeBlockEndAction)1 CodeBlockStartAction (com.intellij.codeInsight.editorActions.CodeBlockStartAction)1 Template (com.intellij.codeInsight.template.Template)1 Document (com.intellij.openapi.editor.Document)1 Editor (com.intellij.openapi.editor.Editor)1 Project (com.intellij.openapi.project.Project)1 TextRange (com.intellij.openapi.util.TextRange)1 PsiCodeBlock (com.intellij.psi.PsiCodeBlock)1 PsiElement (com.intellij.psi.PsiElement)1 NonNls (org.jetbrains.annotations.NonNls)1