Remove dagger generated classes from Android Studio's global search?
If you are talking about the generated MembersInjector
and Factory
classes:
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:
*_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).
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
:
David Rawson's answer doesn't help to get rid of not showing _Factory
classes when performing Find Usages
on the class name. 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//*
. 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. You may as well get rid of classes in test packages, thus only classes from production package will be found.