Search in sources :

Example 1 with IntentionActionProvider

use of com.intellij.codeInsight.intention.IntentionActionProvider in project intellij-community by JetBrains.

the class EditorNotificationActions method collectDescriptorsForEditor.

public static void collectDescriptorsForEditor(@NotNull Editor editor, @NotNull List<HighlightInfo.IntentionActionDescriptor> descriptors) {
    Project project = editor.getProject();
    if (project == null)
        return;
    FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
    if (!(fileEditorManager instanceof FileEditorManagerImpl))
        return;
    TextEditor fileEditor = TextEditorProvider.getInstance().getTextEditor(editor);
    List<JComponent> components = ((FileEditorManagerImpl) fileEditorManager).getTopComponents(fileEditor);
    for (JComponent component : components) {
        if (component instanceof IntentionActionProvider) {
            IntentionActionWithOptions action = ((IntentionActionProvider) component).getIntentionAction();
            if (action != null) {
                descriptors.add(new HighlightInfo.IntentionActionDescriptor(action, action.getOptions(), null));
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) TextEditor(com.intellij.openapi.fileEditor.TextEditor) FileEditorManagerImpl(com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl) IntentionActionWithOptions(com.intellij.codeInsight.intention.IntentionActionWithOptions) IntentionActionProvider(com.intellij.codeInsight.intention.IntentionActionProvider)

Aggregations

IntentionActionProvider (com.intellij.codeInsight.intention.IntentionActionProvider)1 IntentionActionWithOptions (com.intellij.codeInsight.intention.IntentionActionWithOptions)1 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 TextEditor (com.intellij.openapi.fileEditor.TextEditor)1 FileEditorManagerImpl (com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl)1 Project (com.intellij.openapi.project.Project)1