How do I get Android Studio to stop returning generated code in search results?

android, android-studio

Solution

The way I've been doing to ignore generated classes in advanced search is adding `!file:*intermediates*/&&!file:*generated*/&&!lib:*..*` to a new Custom Scope, like this:

14-October-2015 Update: I have improved the pattern by also excluding the `!lib:*..*` from the search. Thanks.

Problem

Every time I use `Search In Path` in Android Studio, I end up with generated code being returned as the first section of results. I usually search for something in `*.java,*.xml`, and usually investigate the first few results before I realize I'm looking at `Generated Code`. Is there a way to omit the generated code results from being returned as part of the result list, while still allowing the search to read all of the *.java and *.xml files in my project? I have a feeling this is something beyond ridiculously simple, but I just can't find the right button to toggle. In the same vein, is it possible to ignore generated classes when loading files or types? I keep getting the generated `MyClass$$ViewInjector` classes appearing first in open files, and it's just annoying...

Original source

Related problems