'com.intellij.psi.PsiElement' 的依赖项缺失或冲突

Missing or conflicting dependencies for 'com.intellij.psi.PsiElement'

我正在开发一个 IDEA 插件。但是更新Intellij IDEA后,ide总是显示导致代码补全失败的警告:

Cannot access class 'com.intellij.psi.PsiElement'. Check your module classpath for missing or conflicting dependencies

我已经尝试升级 gradle 插件或依赖版本,不幸的是它不起作用。

我的 build.gradle 根项目目录中的脚本:

plugins {
    id 'org.jetbrains.intellij' version '1.1.6'
    id "org.jetbrains.kotlin.jvm" version '1.5.21'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.5.21'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2'
}

intellij {
    version '2021.2'
    plugins = ['java','Kotlin']
}

patchPluginXml {
    changeNotes.set(
            """
            Add change notes here.<br>
            <em>most HTML tags may be used</em>
            """
    )
}
test {
    useJUnitPlatform()
}

我的 plugin.xml 文件:

<idea-plugin>
    <id>org.example.TestPlugin</id>
    <name>Plugin display name here</name>
    <vendor email="support@yourcompany.com" url="http://www.yourcompany.com">YourCompany</vendor>

    <description><![CDATA[
    Enter short description for your plugin here.<br>
    <em>most HTML tags may be used</em>
    ]]></description>

    <!-- please see https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html
         on how to target different products -->
    <depends>com.intellij.modules.platform</depends>
    <depends>org.jetbrains.kotlin</depends>

    <extensions defaultExtensionNs="com.intellij">
        <!-- Add your extensions here -->
    </extensions>

    <actions>
        <!-- Add your actions here -->
        <action id="TestAction" class="org.example.TestAction" text="TestAction" description="TestAction">
            <add-to-group group-id="GenerateGroup" anchor="last"/>
        </action>
    </actions>
</idea-plugin>

我的项目有什么问题?感谢您的回答!

自从 IntelliJ SDK 2020.3,你应该使用 Java 11,而不是 8。

参考:https://blog.jetbrains.com/platform/2020/09/intellij-project-migrates-to-java-11/