从Android Studio的全局搜索中删除匕首生成的类?

时间:2017-07-05 09:21:27

标签: android android-studio intellij-idea dagger-2 dagger

真的很烦人。因为匕首2,我需要更多的时间来找一些课。

2 个答案:

答案 0 :(得分:9)

如果您正在讨论生成的MembersInjectorFactory类:

MyClass_MembersInjector.java
MyClass_Factory.java

您可以通过将它们添加到File / Settings / Editor / FileTypes中的忽略文件列表并添加 Ctr-N Cmd-O 对话框来阻止它们出现适当的通配符Ignore files and folders edittext:

the ignore files and folders dialog in IntelliJ

*_MembersInjector.java; *_Factory.java;将导致大多数生成的类被忽略:

<强>之前:

before applying the settings

<强>后:

after applying the settings

如果您甚至不想看到生成的组件,您甚至可以将Dagger*.java添加到列表中(即使这对项目非常有用)。

<强>更新

如果您所说的不是自动导入/自动完成课程,则可以通过Settings / Editor / General / Auto Import完成:

auto import settings dialog in IntelliJ

答案 1 :(得分:4)

在类名上执行_Factory时,David Rawson的回答并没有帮助摆脱不显示Find Usages类的问题。这将是显示的内容:

enter image description here

这可以通过创建一个新的范围来解决,该范围将忽略生成的文件。

enter image description here

enter image description here

这是app模块中生成文件的正则表达式:!file[app]:build/generated//*。但你也可以使用&#34;递归排除&#34;按钮找到你想要摆脱的目录。

enter image description here

现在,将搜索范围更改为新创建的:

enter image description here

这将是输出:

enter image description here

没有_Factory个课程。您也可以在测试包中删除类,因此只能找到生产包中的类。