Find Class (CTRL+N) Filter By Scope

The title pretty much sums up what I'd like. I'm working in a large multi-module maven project; ctrl+n works great but when I'm primarily working in 1 module, or 1 scope, it'd be nice if ctrl+n could be limited to my current scope or module.

6 comments
Comment actions Permalink

You can do such. You just need to use the Find File (CTRL+SHIFT+N) action. Then in your search, prefix it with part of the module name. For example, if I want to find ApplicationSearchDialog in the module named "my-ui-module", I can simply enter:
ui/App

Notice I do not need to include the full module name. Just enough to make it unique. You still have camel case available. So I could Narrow the above down as such:
ui/AppSD
or even just
ui/ASD

Here's a screenshot using this technique on the Logback project across its modules to find something in the "logback-core" module by typing "core/Lo"
screenshot.png

0
Comment actions Permalink

Thanks for the quick response and adequate workaround, I suppose my next logical suggestion would be to extend this feature to the default CTRL+N search. My muscle memory is trained for CTRL+N ;)

0
Comment actions Permalink

mmadson wrote:

I suppose my next logical suggestion would be to extend this feature to the default CTRL+N search. My muscle memory is trained for CTRL+N ;)

I believe the reason why it does not work is simple. Ctrl+N searches the classpath. Ctrl+Shift+N searches the project file system. But remember, in the Find Class dialog (Ctrl+N) you can narrow down by package. That means, that if you have a good mapping of modules to packages, you can do the same with Ctrl+N. For example, in the Logback project, all base packages are "ch.qos.logback.${moduleName}" For example, files from the logback-core module are in "ch.qos.logback.core". So I can accomplish the same search as above in the Find Class dialog by entering:
core.Lo
In some ways, this is an improved search since I end up seeing inner classes (from the core module) that start with the name "Lo". Using Ctrl+Shift+N I only get class files.

screenshot.png

I could also enter
c.Lo
but I get results from both the "core" and the "classic" modules.
Notice in the above screenshot that I do get files in subpackages of the ch.qos.logback.core  package, such as the class ch.qos.logback.core.net.LoginAuthenticator. If I wanted to narrow that down to the ones in the core.net package, I can simply enter core.n.Lo Then I only see the classes in the core.net package.

Enjoy.

1
Comment actions Permalink

Ha! Even better, now I don't have to retrain myself. Still, that filter button seems a bit underused and being able to click it and say Filter results to Scope X, would save me from having to type my module (package) name each time.

0
Comment actions Permalink

Your best bet would be to open a feature request:  http://youtrack.jetbrains.com

0
Comment actions Permalink

Thanks for all your help Mark, the youtrack issue for those interested:

http://youtrack.jetbrains.com/issue/IDEA-88006  

0

Please sign in to leave a comment.