use of com.intellij.codeInsight.CodeInsightActionHandler in project intellij-community by JetBrains.
the class GotoSuperAction method invoke.
@Override
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
int offset = editor.getCaretModel().getOffset();
final Language language = PsiUtilCore.getLanguageAtOffset(file, offset);
final CodeInsightActionHandler codeInsightActionHandler = CodeInsightActions.GOTO_SUPER.forLanguage(language);
if (codeInsightActionHandler != null) {
DumbService.getInstance(project).withAlternativeResolveEnabled(() -> codeInsightActionHandler.invoke(project, editor, file));
}
}
use of com.intellij.codeInsight.CodeInsightActionHandler in project intellij-community by JetBrains.
the class OverrideImplementUtil method registerHandlerForComplementaryAction.
private static void registerHandlerForComplementaryAction(final Project project, final Editor editor, final PsiElement aClass, final boolean toImplement, final MemberChooser<PsiMethodMember> chooser) {
final JComponent preferredFocusedComponent = chooser.getPreferredFocusedComponent();
final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
@NonNls final String s = toImplement ? "OverrideMethods" : "ImplementMethods";
final Shortcut[] shortcuts = keymap.getShortcuts(s);
if (shortcuts.length > 0 && shortcuts[0] instanceof KeyboardShortcut) {
preferredFocusedComponent.getInputMap().put(((KeyboardShortcut) shortcuts[0]).getFirstKeyStroke(), s);
preferredFocusedComponent.getActionMap().put(s, new AbstractAction() {
@Override
public void actionPerformed(final ActionEvent e) {
chooser.close(DialogWrapper.CANCEL_EXIT_CODE);
// invoke later in order to close previous modal dialog
TransactionGuard.getInstance().submitTransactionLater(project, () -> {
CodeInsightActionHandler handler = toImplement ? new OverrideMethodsHandler() : new ImplementMethodsHandler();
handler.invoke(project, editor, aClass.getContainingFile());
});
}
});
}
}
use of com.intellij.codeInsight.CodeInsightActionHandler in project intellij-community by JetBrains.
the class PresentableActionHandlerBasedAction method update.
@Override
protected void update(@NotNull Presentation presentation, @NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext dataContext, @Nullable String actionPlace) {
// avoid evaluating isValidFor several times unnecessary
CodeInsightActionHandler handler = getValidHandler(editor, file);
presentation.setEnabled(handler != null);
if (handler instanceof ContextAwareActionHandler && !ActionPlaces.isMainMenuOrActionSearch(actionPlace)) {
presentation.setVisible(((ContextAwareActionHandler) handler).isAvailableForQuickList(editor, file, dataContext));
}
if (presentation.isVisible() && handler instanceof PresentableCodeInsightActionHandler) {
((PresentableCodeInsightActionHandler) handler).update(editor, file, presentation);
}
}
use of com.intellij.codeInsight.CodeInsightActionHandler in project intellij-community by JetBrains.
the class PresentableActionHandlerBasedAction method getValidHandler.
@Nullable
private CodeInsightActionHandler getValidHandler(@NotNull Editor editor, @NotNull PsiFile file) {
Language language = PsiUtilCore.getLanguageAtOffset(file, editor.getCaretModel().getOffset());
final CodeInsightActionHandler codeInsightActionHandler = getLanguageExtension().forLanguage(language);
if (codeInsightActionHandler != null) {
if (codeInsightActionHandler instanceof LanguageCodeInsightActionHandler) {
if (((LanguageCodeInsightActionHandler) codeInsightActionHandler).isValidFor(editor, file)) {
return codeInsightActionHandler;
}
} else {
return codeInsightActionHandler;
}
}
return null;
}
use of com.intellij.codeInsight.CodeInsightActionHandler in project intellij-community by JetBrains.
the class JavaGotoSuperTest method doTest.
private void doTest() {
configureByFile(getBasePath() + getTestName(false) + ".java");
final CodeInsightActionHandler handler = CodeInsightActions.GOTO_SUPER.forLanguage(JavaLanguage.INSTANCE);
handler.invoke(getProject(), getEditor(), getFile());
checkResultByFile(getBasePath() + getTestName(false) + ".after.java");
}
Aggregations