0

I am trying to follow the instructions on this page for creating actions in an IntelliJ plugin. I have copied the code exactly as written, however the code does not work when run. When I click run code, IntelliJ opens in a new window. According to the above page, the plugin should work in that window. However, the plugin, which is supposed to add an item to the tools menu, does not work. The additional item does not appear in the menu. Additionally, I get this (possibly unrelated) warning message when I run the code.

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.intellij.util.ReflectionUtil to field java.awt.event.InvocationEvent.runnable
WARNING: Please consider reporting this to the maintainers of com.intellij.util.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2020-10-22 17:40:24,829 [   6980]   WARN - tellij.ide.SystemHealthMonitor - issue detected: bundled.jre.version.message 
2020-10-22 17:40:27,369 [   9520]   WARN - ion.impl.NotificationCollector - Notification group 'Heap Dump Analysis' is already registered in whitelist 
2020-10-22 17:40:27,369 [   9520]   WARN - ion.impl.NotificationCollector - Notification group 'Low Memory' is already registered in whitelist 
2020-10-22 17:40:28,602 [  10753]   WARN - Container.ComponentManagerImpl - Do not use constructor injection (requestorClass=org.jetbrains.android.compose.AndroidComposeAutoDocumentation) 
2020-10-22 17:40:29,801 [  11952]   WARN - tartup.impl.StartupManagerImpl - Activities registered via registerPostStartupActivity must be dumb-aware: org.jetbrains.kotlin.idea.configuration.ui.KotlinConfigurationCheckerComponent$projectOpened$1@133a2dbe 
2020-10-22 17:40:35,401 [  17552]   WARN - com.intellij.util.xmlb.Binding - no accessors for org.jetbrains.kotlin.idea.highlighter.KotlinDefaultHighlightingSettingsProvider 
2020-10-22 17:40:51,973 [  34124]   WARN - com.intellij.util.xmlb.Binding - no accessors for org.jetbrains.kotlin.idea.core.script.configuration.utils.ScriptClassRootsStorage

I don't know what this warning message is or how to fix it. I am including my source code in the event that I have copied something incorrectly from the instruction page linked above.

PopupDialogAction.java

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.pom.Navigatable;
import org.jetbrains.annotations.NotNull;

public class PopupDialogAction extends AnAction {

    @Override
    public void update(AnActionEvent e) {
        // Set the availability based on whether a project is open
        Project project = e.getProject();
        e.getPresentation().setEnabledAndVisible(project != null);
    }

    @Override
    public void actionPerformed(@NotNull AnActionEvent event) {
        // Using the event, create and show a dialog
        Project currentProject = event.getProject();
        StringBuffer dlgMsg = new StringBuffer(event.getPresentation().getText() + " Selected!");
        String dlgTitle = event.getPresentation().getDescription();
        // If an element is selected in the editor, add info about it.
        Navigatable nav = event.getData(CommonDataKeys.NAVIGATABLE);
        if (nav != null) {
            dlgMsg.append(String.format("\nSelected Element: %s", nav.toString()));
        }
        Messages.showMessageDialog(currentProject, dlgMsg.toString(), dlgTitle, Messages.getInformationIcon());
    }

}
hsz
  • 148,279
  • 62
  • 259
  • 315
qwerty
  • 810
  • 1
  • 9
  • 26
  • https://stackoverflow.com/questions/50251798/what-is-an-illegal-reflective-access – Jeff Scott Brown Oct 22 '20 at 21:54
  • @JeffScottBrown I'm not really sure how to fix this. Is the issue caused by that fact that I am using the default package? – qwerty Oct 22 '20 at 21:57
  • 2
    See https://youtrack.jetbrains.com/issue/IDEA-210683. – CrazyCoder Oct 22 '20 at 22:02
  • "Is the issue caused by that fact that I am using the default package?" - No, I don't think so. – Jeff Scott Brown Oct 22 '20 at 22:23
  • @JeffScottBrown Being that the messages were warnings rather than errors, do they explain why the plugin didn't work at all? – qwerty Oct 22 '20 at 23:16
  • `"do they explain why the plugin didn't work at all"` - Unlikely. – Jeff Scott Brown Oct 23 '20 at 13:45
  • @JeffScottBrown Then the Illegal reflective access isn't the problem here. There has to be something wrong with the code. What else should I post in the question? I'm trying to narrow down what the issue is, but I don't know where to begin. – qwerty Oct 23 '20 at 14:36
  • You haven't described what the problem is aside from listing warnings and saying `"however the code does not work when run"`. What is it that does not work? – Jeff Scott Brown Oct 23 '20 at 14:59
  • @JeffScottBrown The plugin is supposed to add an item to the *tools* menu, but the item does not appear. The plugin is simply not running in the IntelliJ window that opens when I run it. – qwerty Oct 23 '20 at 15:20

0 Answers0