psiviewer icon indicating copy to clipboard operation
psiviewer copied to clipboard

Show Psi structure for selected text / language injections

Open sschuberth opened this issue 1 year ago • 4 comments

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.

sschuberth avatar Jun 25 '24 06:06 sschuberth

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.

hurricup avatar Jun 25 '24 06:06 hurricup

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...

sschuberth avatar Jun 25 '24 06:06 sschuberth

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

hurricup avatar Jun 25 '24 07:06 hurricup

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

hurricup avatar Jun 25 '24 07:06 hurricup