[英]Remove dagger generated classes from Android Studio's global search?
It is really irritating.这真的很烦人。 I need more time to find some class because of dagger 2.
由于匕首 2,我需要更多时间来找到一些 class。
If you are talking about the generated MembersInjector
and Factory
classes: 如果您正在讨论生成的
MembersInjector
和Factory
类:
MyClass_MembersInjector.java
MyClass_Factory.java
you can prevent these from coming up in the Ctr-N or Cmd-O dialog by adding them to the ignored files list in File / Settings / Editor / FileTypes
and adding the appropriate wildcards to the Ignore files and folders
edittext: 您可以通过将它们添加到
File / Settings / Editor / FileTypes
文件类型中的忽略文件列表并将相应的通配符添加到Ignore files and folders
edittext中来阻止它们出现在Ctr-N或Cmd-O对话框中:
*_MembersInjector.java; *_Factory.java;
will cause most of the generated classes to be ignored: 将导致大多数生成的类被忽略:
Before: 之前:
After: 后:
You can even add Dagger*.java
to the list if you don't even want to see the generated component (even though this is rather useful for the project). 如果你甚至不想看到生成的组件,你甚至可以将
Dagger*.java
添加到列表中(即使这对项目非常有用)。
Update: 更新:
If you are talking about not having the classes appear in auto-import/auto-complete this is done through Settings / Editor / General / Auto Import
: 如果您所说的没有在自动导入/自动完成中显示类,则可通过
Settings / Editor / General / Auto Import
:
David Rawson's answer doesn't help to get rid of not showing _Factory
classes when performing Find Usages
on the class name. 在对类名执行
Find Usages
时,David Rawson的答案无助于摆脱不显示_Factory
类。 This is what will be shown: 这将是显示的内容:
This can be resolved with creating a new scope which will disregard generated files. 这可以通过创建一个忽略生成的文件的新范围来解决。
Here's the regex for generated files in app
module: !file[app]:build/generated//*
. 这是
app
模块中生成文件的正则表达式: !file[app]:build/generated//*
。 But you may as well use "Exclude recursively" button locating the directory you want to get rid of. 但是你也可以使用“排除递归”按钮找到你想要删除的目录。
Now, change the search scope to newly created: 现在,将搜索范围更改为新创建的:
And this will be the output: 这将是输出:
No _Factory
classes. 没有
_Factory
类。 You may as well get rid of classes in test packages, thus only classes from production package will be found. 您也可以在测试包中删除类,因此只能找到生产包中的类。
In Android Studio, go to在 Android Studio 中,转到
File -> Settings -> Editor -> File Types -> Ignored Files and Folders
文件 -> 设置 -> 编辑器 -> 文件类型 -> 忽略的文件和文件夹
and add wild cards.并添加通配符。 Enter apply.
输入申请。
For Hilt , you can add following flags/wildcards *_MembersInjector.java; *_Factory.java; *_Providers.java; *_Bindings.java; *_HiltComponents_*.java; *_Provide*.java
对于Hilt ,您可以添加以下标志/通配符
*_MembersInjector.java; *_Factory.java; *_Providers.java; *_Bindings.java; *_HiltComponents_*.java; *_Provide*.java
*_MembersInjector.java; *_Factory.java; *_Providers.java; *_Bindings.java; *_HiltComponents_*.java; *_Provide*.java
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.