intellij-idea - '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 SDK2020.3
开始,您应该使用 Java 11,而不是 8。
参考:https ://blog.jetbrains.com/platform/2020/09/intellij-project-migrates-to-java-11/
推荐阅读
- angular-cli - 当 ng build 运行良好时,为什么 ng build -c dev 会显示错误?
- dataframe - 如何为 DataName 系列分配名称?
- sed - 使用 SED 删除除模式之外的任何内容
- sql - 用对象数组替换整数数组
- javascript - Javascript:IIFE,稍后也调用它
- reactjs - useSWR - 如何传递配置对象来获取
- indexing - 掩码数组赋值
- tensorflow - 'NoneType' 对象在定义 Keras 模型时没有属性'_inbound_nodes'?
- javascript - 如何从列表中删除逗号?
- javascript - 在 Python Selenium 中访问 Instagram 帖子标题时遇到问题