Search in sources :

Example 1 with LanguageCodeInsightActionHandler

use of com.intellij.lang.LanguageCodeInsightActionHandler in project intellij-community by JetBrains.

the class OverrideMethodsHandler method invoke.

@Override
public final void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
    if (!EditorModificationUtil.checkModificationAllowed(editor))
        return;
    if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)) {
        return;
    }
    Language language = PsiUtilCore.getLanguageAtOffset(file, editor.getCaretModel().getOffset());
    final LanguageCodeInsightActionHandler codeInsightActionHandler = CodeInsightActions.OVERRIDE_METHOD.forLanguage(language);
    if (codeInsightActionHandler != null) {
        codeInsightActionHandler.invoke(project, editor, file);
    }
}
Also used : Language(com.intellij.lang.Language) LanguageCodeInsightActionHandler(com.intellij.lang.LanguageCodeInsightActionHandler)

Example 2 with LanguageCodeInsightActionHandler

use of com.intellij.lang.LanguageCodeInsightActionHandler in project intellij-community by JetBrains.

the class DelegateMethodsAction method isValidForFile.

@Override
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull final PsiFile file) {
    Language language = PsiUtilCore.getLanguageAtOffset(file, editor.getCaretModel().getOffset());
    final LanguageCodeInsightActionHandler codeInsightActionHandler = CodeInsightActions.DELEGATE_METHODS.forLanguage(language);
    if (codeInsightActionHandler != null) {
        return codeInsightActionHandler.isValidFor(editor, file);
    }
    return false;
}
Also used : Language(com.intellij.lang.Language) LanguageCodeInsightActionHandler(com.intellij.lang.LanguageCodeInsightActionHandler)

Example 3 with LanguageCodeInsightActionHandler

use of com.intellij.lang.LanguageCodeInsightActionHandler 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;
}
Also used : Language(com.intellij.lang.Language) CodeInsightActionHandler(com.intellij.codeInsight.CodeInsightActionHandler) LanguageCodeInsightActionHandler(com.intellij.lang.LanguageCodeInsightActionHandler) LanguageCodeInsightActionHandler(com.intellij.lang.LanguageCodeInsightActionHandler) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with LanguageCodeInsightActionHandler

use of com.intellij.lang.LanguageCodeInsightActionHandler in project intellij-community by JetBrains.

the class DelegateMethodsHandler method invoke.

@Override
public final void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
    if (!EditorModificationUtil.checkModificationAllowed(editor))
        return;
    if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)) {
        return;
    }
    Language language = PsiUtilCore.getLanguageAtOffset(file, editor.getCaretModel().getOffset());
    final LanguageCodeInsightActionHandler codeInsightActionHandler = CodeInsightActions.DELEGATE_METHODS.forLanguage(language);
    if (codeInsightActionHandler != null) {
        codeInsightActionHandler.invoke(project, editor, file);
    }
}
Also used : Language(com.intellij.lang.Language) LanguageCodeInsightActionHandler(com.intellij.lang.LanguageCodeInsightActionHandler)

Example 5 with LanguageCodeInsightActionHandler

use of com.intellij.lang.LanguageCodeInsightActionHandler in project intellij-community by JetBrains.

the class ImplementMethodsHandler method invoke.

@Override
public final void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
    if (!EditorModificationUtil.checkModificationAllowed(editor))
        return;
    if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)) {
        return;
    }
    Language language = PsiUtilCore.getLanguageAtOffset(file, editor.getCaretModel().getOffset());
    final LanguageCodeInsightActionHandler codeInsightActionHandler = CodeInsightActions.IMPLEMENT_METHOD.forLanguage(language);
    if (codeInsightActionHandler != null) {
        codeInsightActionHandler.invoke(project, editor, file);
    }
}
Also used : Language(com.intellij.lang.Language) LanguageCodeInsightActionHandler(com.intellij.lang.LanguageCodeInsightActionHandler)

Aggregations

Language (com.intellij.lang.Language)5 LanguageCodeInsightActionHandler (com.intellij.lang.LanguageCodeInsightActionHandler)5 CodeInsightActionHandler (com.intellij.codeInsight.CodeInsightActionHandler)1 Nullable (org.jetbrains.annotations.Nullable)1