List of usage examples for com.intellij.openapi.actionSystem IdeActions ACTION_EDITOR_START_NEW_LINE
String ACTION_EDITOR_START_NEW_LINE
To view the source code for com.intellij.openapi.actionSystem IdeActions ACTION_EDITOR_START_NEW_LINE.
Click Source Link
From source file:com.goide.completion.BracesInsertHandler.java
License:Apache License
@Override public void handleInsert(@Nonnull InsertionContext context, LookupElement item) { Editor editor = context.getEditor(); CharSequence documentText = context.getDocument().getImmutableCharSequence(); int offset = skipWhiteSpaces(editor.getCaretModel().getOffset(), documentText); if (documentText.charAt(offset) != '{') { Project project = context.getProject(); Template template = TemplateManager.getInstance(project).createTemplate("braces", "go", myOneLine ? "{$END$}" : " {\n$END$\n}"); template.setToReformat(true);/*w w w. j a va 2s . com*/ TemplateManager.getInstance(project).startTemplate(editor, template); } else { editor.getCaretModel().moveToOffset(offset); ApplicationManager.getApplication().runWriteAction(() -> { EditorActionHandler enterAction = EditorActionManager.getInstance() .getActionHandler(IdeActions.ACTION_EDITOR_START_NEW_LINE); enterAction.execute(editor, editor.getCaretModel().getCurrentCaret(), ((EditorEx) editor).getDataContext()); }); } }
From source file:com.intellij.codeInsight.editorActions.smartEnter.CommentBreakerEnterProcessor.java
License:Apache License
private static EditorActionHandler getEnterHandler() { return EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_START_NEW_LINE); }
From source file:com.intellij.codeInsight.editorActions.smartEnter.JavaSmartEnterProcessor.java
License:Apache License
protected static EditorActionHandler getEnterHandler() { return EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_START_NEW_LINE); }
From source file:com.intellij.codeInsight.editorActions.smartEnter.PlainEnterProcessor.java
License:Apache License
@Override public boolean doEnter(Editor editor, PsiElement psiElement, boolean isModified) { PsiCodeBlock block = getControlStatementBlock(editor.getCaretModel().getOffset(), psiElement); if (processExistingBlankLine(editor, block, psiElement)) { return true; }/*from ww w. j a va 2 s .c o m*/ EditorActionHandler enterHandler = getEnterHandler(IdeActions.ACTION_EDITOR_START_NEW_LINE); if (block != null) { 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; }
From source file:com.shape.idea.completion.BracesInsertHandler.java
License:Apache License
@Override public void handleInsert(InsertionContext context, LookupElement item) { final Editor editor = context.getEditor(); final CharSequence documentText = context.getDocument().getImmutableCharSequence(); int offset = skipWhiteSpaces(editor.getCaretModel().getOffset(), documentText); if (documentText.charAt(offset) != '{') { Project project = context.getProject(); Template template = TemplateManager.getInstance(project).createTemplate("braces", "shp", myOneLine ? "{$END$}" : " {\n$END$\n}"); template.setToReformat(true);/*from w w w . j a v a2 s . c om*/ TemplateManager.getInstance(project).startTemplate(editor, template); } else { editor.getCaretModel().moveToOffset(offset); ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { EditorActionHandler enterAction = EditorActionManager.getInstance() .getActionHandler(IdeActions.ACTION_EDITOR_START_NEW_LINE); enterAction.execute(editor, editor.getCaretModel().getCurrentCaret(), ((EditorEx) editor).getDataContext()); } }); } }
From source file:runnable.CreateNewlineAndJumpRunnable.java
License:Apache License
@Override public void run() { final Project project = _editor.getProject(); Runnable runnable1 = new Runnable() { @Override// w ww . j a v a 2 s . c o m public void run() { Caret caret = _editor.getCaretModel().getCurrentCaret(); caret.moveToOffset(_offsetToJump); DataContext dataContext = DataManager.getInstance().getDataContext(_editor.getComponent()); EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_START_NEW_LINE) .execute(_editor, caret, dataContext); } }; WriteCommandAction.runWriteCommandAction(project, runnable1); }