List of usage examples for com.intellij.openapi.editor.actionSystem TypedAction actionPerformed
public final void actionPerformed(@Nullable final Editor editor, final char charTyped, final DataContext dataContext)
From source file:com.intellij.application.options.codeInsight.editor.quotes.SelectionQuotingTypedHandlerTest.java
License:Apache License
private void doTest(final char c, @NotNull String before, @NotNull String expected) { myFixture.configureByText(PlainTextFileType.INSTANCE, before); final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction(); performAction(myFixture.getProject(), new Runnable() { @Override/* ww w . j a va2s . c om*/ public void run() { typedAction.actionPerformed(myFixture.getEditor(), c, ((EditorEx) myFixture.getEditor()).getDataContext()); } }); myFixture.getEditor().getSelectionModel().removeSelection(); myFixture.checkResult(expected); }
From source file:com.intellij.application.options.codeInsight.editor.quotes.SelectionQuotingTypedHandlerTest.java
License:Apache License
private void doTest(@NotNull final String cs, @NotNull String before, @NotNull String expected) { final boolean smarterSelection = Registry.is("editor.smarterSelectionQuoting"); Registry.get("editor.smarterSelectionQuoting").setValue(true); try {/* w ww. j av a 2 s . c om*/ myFixture.configureByText(PlainTextFileType.INSTANCE, before); final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction(); performAction(myFixture.getProject(), new Runnable() { @Override public void run() { for (int i = 0, max = cs.length(); i < max; i++) { final char c = cs.charAt(i); typedAction.actionPerformed(myFixture.getEditor(), c, ((EditorEx) myFixture.getEditor()).getDataContext()); } } }); myFixture.checkResult(expected); } finally { Registry.get("editor.smarterSelectionQuoting").setValue(smarterSelection); } }
From source file:com.intellij.application.options.codeInsight.editor.quotes.SelectionQuotingTypedHandlerTest.java
License:Apache License
public void testRuby7852ErrantEditor() { myFixture.configureByText(PlainTextFileType.INSTANCE, "\"aaa\"\nbbb\n\n"); myFixture.getEditor().getCaretModel().moveToOffset(0); myFixture.getEditor().getSelectionModel().setSelection(0, 5); final TypedAction typedAction = EditorActionManager.getInstance().getTypedAction(); performAction(myFixture.getProject(), new Runnable() { @Override//from w w w . j ava2s . c om public void run() { typedAction.actionPerformed(myFixture.getEditor(), '\'', ((EditorEx) myFixture.getEditor()).getDataContext()); } }); myFixture.getEditor().getSelectionModel().removeSelection(); myFixture.checkResult("'aaa'\nbbb\n\n"); myFixture.getEditor().getCaretModel() .moveToOffset(myFixture.getEditor().getDocument().getLineStartOffset(3)); performAction(myFixture.getProject(), new Runnable() { @Override public void run() { typedAction.actionPerformed(myFixture.getEditor(), 'A', ((EditorEx) myFixture.getEditor()).getDataContext()); typedAction.actionPerformed(myFixture.getEditor(), 'B', ((EditorEx) myFixture.getEditor()).getDataContext()); } }); myFixture.checkResult("'aaa'\nbbb\n\nAB"); }
From source file:com.intellij.codeInsight.CodeInsightTestCase.java
License:Apache License
protected static void type(char c, Editor editor) { EditorActionManager actionManager = EditorActionManager.getInstance(); DataContext dataContext = DataManager.getInstance().getDataContext(); if (c == '\n') { actionManager.getActionHandler(IdeActions.ACTION_EDITOR_ENTER).execute(editor, dataContext); return;//from www . j av a2s. c o m } TypedAction action = actionManager.getTypedAction(); action.actionPerformed(editor, c, dataContext); }
From source file:com.intellij.testFramework.EditorTestUtil.java
License:Apache License
public static void performTypingAction(Editor editor, char c) { EditorActionManager actionManager = EditorActionManager.getInstance(); if (c == BACKSPACE_FAKE_CHAR) { EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE); actionHandler.execute(editor, DataManager.getInstance().getDataContext()); } else if (c == SMART_ENTER_FAKE_CHAR) { EditorActionHandler actionHandler = actionManager .getActionHandler(IdeActions.ACTION_EDITOR_COMPLETE_STATEMENT); actionHandler.execute(editor, DataManager.getInstance().getDataContext()); } else if (c == SMART_LINE_SPLIT_CHAR) { EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_SPLIT); actionHandler.execute(editor, DataManager.getInstance().getDataContext()); } else if (c == '\n') { EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_ENTER); actionHandler.execute(editor, DataManager.getInstance().getDataContext()); } else {/*w w w. j a v a 2 s. co m*/ TypedAction action = actionManager.getTypedAction(); action.actionPerformed(editor, c, DataManager.getInstance().getDataContext()); } }