Search in sources :

Example 1 with IntentionActionWithOptions

use of com.intellij.codeInsight.intention.IntentionActionWithOptions 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)

Example 2 with IntentionActionWithOptions

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

the class SdkSetupNotificationTestBase method assertSdkSetupPanelShown.

protected static void assertSdkSetupPanelShown(EditorNotificationPanel panel, String expectedMessagePrefix) {
    assertNotNull(panel);
    final IntentionActionWithOptions action = panel.getIntentionAction();
    assertNotNull(action);
    final String text = action.getText();
    assertNotNull(text);
    if (!text.startsWith(expectedMessagePrefix)) {
        final int length = Math.min(text.length(), expectedMessagePrefix.length());
        assertEquals(expectedMessagePrefix, text.substring(0, length));
    }
}
Also used : IntentionActionWithOptions(com.intellij.codeInsight.intention.IntentionActionWithOptions)

Aggregations

IntentionActionWithOptions (com.intellij.codeInsight.intention.IntentionActionWithOptions)2 IntentionActionProvider (com.intellij.codeInsight.intention.IntentionActionProvider)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