Gradle在IntelliJ Plugin项目中尝试使用PsiMethod生成类失败 [英] Gradle fails trying to build class using PsiMethod in IntelliJ Plugin project

查看:155
本文介绍了Gradle在IntelliJ Plugin项目中尝试使用PsiMethod生成类失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Intellij插件项目,无需使用PsiMethod类就可以成功构建该项目.我已经使用此

通过将其添加到平台设置SDK中:

这现在增加了智能感知能力,使我能够通过CMD + click导航到PsiMethod类.

但是,如果我尝试运行插件" gradle配置.它会因运行:runIde的错误而停止.

从bash运行compileJava命令,我得到:

  $ ./gradlew compileJava>任务:compileJava失败/Users/cody/IdeaProjects/plugintest/src/main/java/com/plugintest/TestClass.java:104:错误:找不到符号PsiMethod containsMethod = PsiTreeUtil.getParentOfType(element,PsiMethod.class);^符号:类PsiMethod位置:类ParticleContainerManager/Users/cody/IdeaProjects/plugintest/src/main/java/com/plugintest/TestClass.java:104:错误:找不到符号PsiMethod containsMethod = PsiTreeUtil.getParentOfType(element,PsiMethod.class);^符号:类PsiMethod位置:类ParticleContainerManager注意:某些输入文件使用或覆盖不推荐使用的API.注意:有关详细信息,请使用-Xlint:deprecation重新编译.2个错误 

intellij中的gradle源集如下:

当我CMD +单击PsiMethod类时,它显示以下JAR源:

此源位于以下父文件夹中:

如何将该源添加到我的gradle配置中?是不是应该自动检测我的项目intellisense正在使用什么?

我是否需要在项目目录中的gradle.*文件中进行某些更改?

使用Yann的答案:

我已将以下行添加到我的build.gradle文件中:

  intellij {版本'2019.2'插件'java'} 

它有效!

解决方案

请确保添加 Java 插件作为单独的依赖项.现在从2019.2开始是必须的: https://blog.jetbrains.com/platform/2019/06/java-functionality-extracted-as-a-plugin/

I have a Intellij plugin project that I can successfully build without using the PsiMethod class. I've generated this project using this intellij plugin guide

As soon as I add in code using PsiMethod class (from the Intellij SDK code_samples directory)

The intellisense cannot find any GOTO information for the class.

I can then switch my project settings module from JAVA_1.8.0 to

by adding it into the platform settings SDKs:

This now adds intellisense, and gives me the ability to navigate to the PsiMethod class by CMD+click.

However, If I try and run my "plugin" gradle configratuion. it halts with an error running :runIde.

Running compileJava command from bash I get:

$ ./gradlew compileJava


> Task :compileJava FAILED
/Users/cody/IdeaProjects/plugintest/src/main/java/com/plugintest/TestClass.java:104: error: cannot find symbol
            PsiMethod containingMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
            ^
  symbol:   class PsiMethod
  location: class ParticleContainerManager
/Users/cody/IdeaProjects/plugintest/src/main/java/com/plugintest/TestClass.java:104: error: cannot find symbol
            PsiMethod containingMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
                                                                              ^
  symbol:   class PsiMethod
  location: class ParticleContainerManager
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors

The gradle source sets in intellij are as follows:

And when I CMD+Click the PsiMethod class, it shows the following JAR source:

This source is in the following parent folder:

How can I add this source into my gradle configuration? shouldn't it be autodetecting what my projects intellisense is tapping into?

Do I need to change something in the gradle.* files inside the project directory?

EDIT: Using Yann's Answer:

I've added the following line to my build.gradle file:

intellij {
    version '2019.2'
    plugins 'java'
}

and it works!

解决方案

Please make sure to add Java plugin as separate dependency. This is now necessary starting with 2019.2: https://blog.jetbrains.com/platform/2019/06/java-functionality-extracted-as-a-plugin/

这篇关于Gradle在IntelliJ Plugin项目中尝试使用PsiMethod生成类失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆