Remove dagger generated classes from Android Studio global search?
If you are talking about generated classes MembersInjector
and Factory
:
MyClass_MembersInjector.java
MyClass_Factory.java
you can prevent them from appearing in the dialog, Ctr-Nor Cmd-Oby adding them to the list of ignored files in File / Settings / Editor / FileTypes
and adding appropriate wildcards to the edit text Ignore files and folders
:
*_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 (although this is quite useful for a project).
Update:
If you are talking about classes not showing up in auto import / autocomplete mode, this is done with Settings / Editor / General / Auto Import
:
source to share
David Rawson's answer doesn't help to get rid of not showing classes _Factory
on runtime Find Usages
for a class name. Here's what will be shown:
You can solve this problem by creating a new scope that will ignore the generated files.
Here is the regular expression for the generated files in the module app
: !file[app]:build/generated//*
. But you can also use the Exclude Recursively button to find the directory you want to get rid of.
Now change the search scope to the newly created one:
And this will be the output:
There are no _Factory
classes. You can also get rid of the classes in the test packages, so only the classes from the production package will be found.
source to share