Scope "Module" difference between Find in Files (Strg Shift F) vs Usage Search (Strg Alt F7)
Hello
I am wondering about IDEA behaviour in terms of Find in Files vs Usage Search when it comes to selecting Scope “Module”.
Say I have a Java EE webproject with src/main/java, src/main/resources, and src/main/webapp (for faces stuff, xhtml etc.).
Now within a .java file when doing “Find in Files (Strg Shift F)" I can select scope ”Module" and e.g. myproject.main. This will give me results from within the src/main/java files but also from within src/main/webapp.
When doing a usage search with Strg Alt F7 on a field that is referenced within xhtml files via EL-expression (e.g.: #{myBean.someProperty}) selecting Module ‘myproject.main’ will only yield usages within .java files; but NOT the usages within src/main/webapp xhtml files. (in the end this is main Module as well, isn't it?)
However at the bottom of the Usage Search window there is a hint "…<# usages are out of scope 'Module myproject.main>… Why this?
When I click on this hint the Module selector above will switch to “Project Files” and the *.xhtml files from src/main/webapp are shown.
I dont't get this difference. Why does usage search on Module not cover src/main/webapp while Find in Files does?
Please sign in to leave a comment.
Hi Rob,
Thanks for the detailed explanation and examples.
Short answer: this difference is expected at the moment and comes from how Find in Files and Find Usages define and apply their scopes.
Why the results differ:
src/main/java,src/main/resources, andsrc/main/webapp*.xhtmlfiles.*.xhtmlfiles live, even though those files belong to the same module from the project-structure point of viewsrc/main/webappare found by the code that understands EL, but they are considered outside the active scope. That’s why you see the hint at the bottom,N usages are out of scope 'Module myproject.main', and why switching the scope to Project Files immediately reveals those usages.So in practice, “Module” in Find in Files = whole module content roots, while “Module” in Find Usages = element’s code use-scope in the selected module, which currently treats the web root differently.
What you can do now:
*.xhtml, run Find Usages and:Ok @... . Thx for the thorough explanation!