首页 > 解决方案 > '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-ideaintellij-plugin

解决方案


从 IntelliJ SDK2020.3开始,您应该使用 Java 11,而不是 8。

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


推荐阅读