Background/Situation
In a project that contains both Java code and non-Java resources (for example, a Java EE web project with src/main/java, src/main/resources, and src/main/webapp content roots), the Find in Files and Find Usages actions return different results when the Module scope is selected.
For a Java field referenced from an EL expression such as #{myBean.someProperty} in an .xhtml file:
- Find in Files (Ctrl+Shift+F) with Scope: Module <myproject.main> returns matches in
.javafiles and in.xhtmlfiles undersrc/main/webapp. - Find Usages (Alt+F7) with the same Module scope returns usages only in
.javafiles. The.xhtmlmatches are excluded.
The Find Usages results panel displays a hint at the bottom: N usages are out of scope 'Module <myproject.main>'. Clicking the hint switches the scope to Project Files and reveals the missing matches.
Question
Why does Find Usages with the Module scope exclude references that Find in Files with the same scope finds?
Answer
The two actions use different search algorithms and apply the Module scope differently.
Find in Files
A text-based search. With Scope: Module, IntelliJ IDEA searches all files under the module's content roots, regardless of file type. Matches in src/main/java, src/main/resources, and src/main/webapp are all returned.
Find Usages
A code-aware search that operates on symbols (fields, methods, classes) rather than raw text. For each symbol, IntelliJ IDEA computes a use scope — the set of locations where the symbol can be referenced according to language semantics — and intersects it with the scope selected in the UI.
For Java fields, the computed use scope is narrower than the module's content roots. It currently does not include web resource roots such as src/main/webapp, even when those roots belong to the same module in the project structure. References found by framework-aware code (for example, the EL/JSF handler) are reported as out-of-scope matches in the panel hint rather than as in-scope usages.
Workaround
To include references in web resources and other non-source roots:
- In the Find Usages results panel, click the
N usages are out of scope 'Module ...'hint to switch the scope to Project Files. - Or open the Find Usages Settings dialog (Ctrl+Alt+Shift+F7) and select Project Files or Project and Libraries in the Scope field.
If only text occurrences are needed and semantic context is not required, use Find in Files with Scope: Module.
Additional Relevant Phrases
find usages module scope xhtml; find usages misses references; usages are out of scope module; find usages vs find in files; EL expression find usages; JSF references find usages; find usages skip webapp; Java field usages xhtml not found
Comments
0 comments
Please sign in to leave a comment.