Search code examples
javaintellij-ideaintellij-plugin

What what is "project " referring to? (Intellij Plugin)


It says cannot resolve symbol.

Document currentDoc = FileEditorManager.getInstance(project).getSelectedTextEditor().getDocument();

Example 2:

StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
if (statusBar != null) statusBar.addWidget(widget, [Anchor], [disposable]);

Solution

  • This is the method i use and recommend:

    AnActionEvent.getData(LangDataKeys.PROJECT);
    

    You can include it like that:

    AnActionEvent.getProject()
    

    The answer is in the comments:

    Refer to these:

    Jetbrains Community post 1

    Jetbrains Community post 2

    Jetbrains Community post 3