在我的 Intellij 插件项目中找不到 PsiClass

Can not find PsiClass in my Intellij plugin project

许多教程提到了一个 class - PsiClass,但我在我的项目中找不到这个 class。 我的 build.gradle 如下:

plugins {
    id 'java'
    id 'org.jetbrains.intellij' version '0.4.16'
    id 'org.jetbrains.kotlin.jvm' version '1.3.61'
    id 'idea'
}

apply plugin: "org.jetbrains.intellij"
apply plugin: 'java'
apply plugin: 'idea'

group 'com.github.boybeak.adapter'
version '0.1'

sourceCompatibility = 1.8

repositories {
    /*google()
    jcenter()*/
    mavenCentral()
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
//    implementation group: 'com.github.boybeak', name: 'any-adapter', version: '1.1.2'
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

intellij {
    /*version '192.7142.36'*/
    type 'AI'
    plugins 'android'
    localPath '/Applications/Android Studio.app'
}

我的 IDEA 版本:

IntelliJ IDEA 2019.3.1 (Community Edition) Build #IC-193.5662.53, built on December 18, 2019 Runtime version: 11.0.5+10-b520.17 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o macOS 10.15.3 GC: ParNew, ConcurrentMarkSweep Memory: 990M Cores: 4 Registry: Non-Bundled Plugins: DBN, OdpsStudio, no.tornado.tornadofx.idea

我应该在我的项目中添加更多库吗?

经过一番搜索,我找到了解决办法。 https://intellij-support.jetbrains.com/hc/en-us/community/posts/360005055559-Missing-classes-after-upgrade-to-2019-2-2

像这样改变我的Gradle:

intellij {
    /*version '192.7142.36'*/
    type 'AI'
    plugins 'android', 'java'
    localPath '/Applications/Android Studio.app'
}

android

之后添加Java插件

如果您使用 build.gradle.kts

,请添加 Kotlin 脚本解决方案
intellij {
    ...
    setPlugins("java")
}

最新的 Idea Plugin 模板 suggests gradle.properties 作为插件依赖的来源

// gradle.properties
platformPlugins = ...

// build.gradle.kts
val platformPlugins: String by project

intellij {
    setPlugins(*platformPlugins.split(',').map(String::trim).filter(String::isNotEmpty).toTypedArray())
}