JetBrains / psiviewer

PSI Viewer for IntelliJ IDEA plugin development
GNU General Public License v2.0
185 stars 40 forks source link

Show Psi structure for selected text / language injections #96

Open sschuberth opened 3 months ago

sschuberth commented 3 months ago

For writing detekt / ktlint rules I have test code like

val findings = rule.lint(
    // language=Kotlin
    """
    if (true) {
        println("Inside block.")
    }

    println("This statement is valid.")
    """.trimIndent()
)

findings should beEmpty()

However, due to the text inside """ just being a string for PsiViewer, I cannot conveniently see it's AST. It would be great if there was a mode to run PsiViewer just on some arbitrary selected text (which would allow me to select the text within """), or probably better, if a Kotlin language injection would be respected and the AST for the injected code would be displayed.

hurricup commented 3 months ago

Most likely this plugin won't be updated anymore in favor of built-in psi viewer. The only advantage of this one was the objects introspection, but the built it one can do this now. So probably better try it and put requests into youtrack.

sschuberth commented 3 months ago

I didn't even know there was a built-in Psi viwer 😅 Where can I find it? I don't see anything related in the "Tools" / "Kotlin" menu...

hurricup commented 3 months ago

you need to run the ide in internal mode I believe to make it available.

hurricup commented 3 months ago

https://plugins.jetbrains.com/docs/intellij/enabling-internal.html