Skip to content

Instantly share code, notes, and snippets.

@dkandalov
Last active September 12, 2021 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkandalov/5979943 to your computer and use it in GitHub Desktop.
Save dkandalov/5979943 to your computer and use it in GitHub Desktop.
One-liner to show PSI viewer dialog. Normally it's only enabled in plugin projects.(This is a mini-plugin for https://github.com/dkandalov/live-plugin)
import com.intellij.internal.psiView.PsiViewerDialog
import static liveplugin.PluginUtil.*
registerAction("showPsiViewerDialog", "ctrl shift P") { event ->
new PsiViewerDialog(project, currentEditorIn(event.project)).show()
}
@alshain
Copy link

alshain commented Feb 22, 2019

The constructor has changed at some point, it is currently PsiViewerDialog(@NotNull Project project, @Nullable Editor selectedEditor) {

New version:

import com.intellij.internal.psiView.PsiViewerDialog
import static liveplugin.PluginUtil.*

registerAction("showPsiViewerDialog", "ctrl shift P") {
  new PsiViewerDialog(project, false, null, null).show()
}

For the current file, it's

import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.internal.psiView.PsiViewerDialog

import static liveplugin.PluginUtil.*

registerAction("Show Psi Viewer Dialog for Current File", "ctrl shift P") { AnActionEvent e->
  // IntelliJ way
  //def editor = com.intellij.openapi.actionSystem.CommonDataKeys.EDITOR.getData(e.getDataContext())
  // live-plugin way
  new PsiViewerDialog(project, currentEditorIn(e.project)).show()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment