编译时创建的类在 IntelliJ 中显示为不存在 [英] Compile-time created class is shown as non-existent in IntelliJ
问题描述
动机:
我想试试编译时注释处理是否适合我的问题.它需要开箱即用,没有编译器参数等.
I'd like to try if compile-time annotation processing fits my problem. It needs to work out of the box, no compiler arguments etc.
当前状态:
我有:
- 注释
- 注释处理器
- 包含这两者的 .jar 和包含 FQCN 我在 META-INF/services 中的处理器
- The annotation
- An annotation processor
- A .jar containing both of these and a javax.annotation.processing.Processor file containing the FQCN of my processor in META-INF/services
应该发生什么:
- 它应该自动检测处理器
- 它应该处理注释并创建一个新类(WiredAnnotated)
- 我应该能够在一个编译步骤(而不是多个阶段)中使用这个类
- 我不想让编辑器接受生成的这个类(例如 AndroidAnnotations 也管理这个)立>
- It should autodetect the processor
- It should process the annotation and create a new class (WiredAnnotated)
- I should be able to use this class in one step of compilation (not multiple phases)
- I wan't the editor to accept this class is generated (e.g. AndroidAnnotations manages this as well)
实际发生了什么:
- 它会自动检测处理器
- 它创建了一个新类(在 out/production/*/generated/)
- 我可以使用这个类
- 源代码看起来不错
- 反编译时看起来也不错
我尝试了什么:
- 重启 IntelliJ
- 使缓存无效
- 检查注释处理器的输出
截图:
编译时,它确实按预期工作.我想这与检查错误的目录有关.
When compiling, it actually works as expected. I guess it has something to do with inspecting the wrong directories.
有人知道我做错了什么吗?我是否错过了可以帮助您的信息?
Does anyone have an idea/clue on what I'm doing wrong? Did I miss information which could help you help me?
提前致谢,直到
推荐答案
好吧,您需要将您的
out/production/*/generated/
添加到项目源文件夹中.因此,IntelliJ 将了解您生成的类.Well, you need to add you
out/production/*/generated/
to projects source folder. So, IntelliJ will know about your generated classes.您可以通过右键单击目录>将目录标记为源根目录来实现.
You can make it via Right click on directory > Mark directory as source root.
或
项目结构 (F4) > 模块 > 源选项卡 > 源文件夹应该包含所有包含源代码的目录,生成一个 inludes.
Project structure (F4) > Modules > Sources tab > Source folders should contain all directories with your source codes, generated one inludes.
在 android 中,根文件夹中有一个
gen
目录,但请注意,它发出蓝色或绿色光,这意味着它被标记为源文件夹,它也可以在项目结构 > 模块中看到.它包含R
、BuildConfig
和Manifest
.In android there is a
gen
dir in root folder, but notice, it glows blue or green which means it marked as Source folder, it is also visible in Project structure > Modules. It containsR
,BuildConfig
andManifest
.这篇关于编译时创建的类在 IntelliJ 中显示为不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!