cleanup (inspection "Java | Class structure | Utility class is not 'final'")
[idea/community.git] / platform / lang-impl / src / com / intellij / codeInsight / daemon / impl / EditorNotificationActions.java
1 // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2 package com.intellij.codeInsight.daemon.impl;
3
4 import com.intellij.codeInsight.intention.IntentionActionProvider;
5 import com.intellij.codeInsight.intention.IntentionActionWithOptions;
6 import com.intellij.openapi.editor.Editor;
7 import com.intellij.openapi.fileEditor.FileEditorManager;
8 import com.intellij.openapi.fileEditor.TextEditor;
9 import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl;
10 import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider;
11 import com.intellij.openapi.project.Project;
12 import org.jetbrains.annotations.NotNull;
13
14 import javax.swing.*;
15 import java.util.List;
16
17 final class EditorNotificationActions {
18   static void collectActions(@NotNull Editor hostEditor, @NotNull ShowIntentionsPass.IntentionsInfo intentions) {
19     Project project = hostEditor.getProject();
20     if (project == null) return;
21     FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
22     if (!(fileEditorManager instanceof FileEditorManagerImpl)) return;
23     TextEditor fileEditor = TextEditorProvider.getInstance().getTextEditor(hostEditor);
24     List<JComponent> components = ((FileEditorManagerImpl)fileEditorManager).getTopComponents(fileEditor);
25     for (JComponent component : components) {
26       if (component instanceof IntentionActionProvider) {
27         IntentionActionWithOptions action = ((IntentionActionProvider)component).getIntentionAction();
28         if (action != null) {
29           intentions.notificationActionsToShow.add(new HighlightInfo.IntentionActionDescriptor(action, action.getOptions(), null));
30         }
31       }
32     }
33   }
34 }