Cannot resolve extended Interface of PsiElement
Answered
Hello, I'm trying to create extension for JS/TS, but for some reason, I cannot use PsiTreeUtil class:
PsiTreeUtil.findChildrenOfType(root, JSObjectLiteralExpression::class.java);
Editor says, there is a type mismatch with required: PsiElement!, provided: JSObjectLiteralExpression!
But When I look into JSObjectLiteralExpression it is an interface that does extends PsiElement (although it's about 4 levels deeper).
Why that interface cannot be used for searching elements, even when it does extend PsiElement?
Please sign in to leave a comment.
Hi,
It should work correctly. Maybe there is some IDE glitch. Please try to use File | Invalidate Caches... and reimport your project.
If it doesn't help, please provide more information, like build script, error screenshots, etc. The full source code of the project would be perfect.
Clear caches and re-import did not help, but I've actually try to run it, and it does not fail, so it's truly just some IDE issue, not the code itself.

Source code with example code:
https://gitlab.com/IceExplosive/orchesty-plugin/-/blob/test/src/main/kotlin/orchesty/action/Test.kt
Currently I'm using
IntelliJ IDEA 2022.2.1 (Ultimate Edition)
Build #IU-222.3739.54, built on August 16, 2022
Kotlin: 222-1.7.10-release-334-IJ3739.54
Hi,
I noticed that you use very outdated Gradle and Gradle IntelliJ Plugin.
Please update them to the latest versions and see if it solves the issue.