Intellij : Find usages , but exclude test files from results

Intellij Idea

Intellij Idea Problem Overview


Anyone knows how to exclude test files from find usages results ?

Like everything that is under : src/test/

Intellij Idea Solutions


Solution 1 - Intellij Idea

In the Find usages result panel, you can group by test/production. There is a button for that.

enter image description here

Solution 2 - Intellij Idea

Intellij Ultimate 11 version has an option to search in "Project production files".

Just press Alt+F7 on a usage and look on Scope.

Solution 3 - Intellij Idea

I found this answer extremely helpful:

https://stackoverflow.com/a/45958976/5449497

By putting !*Test.java into the File Mask textfield you can exclude Testfiles from your search results within the project.

Solution 4 - Intellij Idea

Skip tests files pattern

You are able to create a custom search Scope
> A scope is a subset of files, packages and/or directories in your project, to which you can limit the application of specific operations, e.g. search, code inspection, insertion of copyright notices, etc.

Edit -> Find -> Find Usages Settings...

enter image description here

Use pattern

!file:*Test.java or !file:*Test.java&&!file:*Tests.java or !test:*.*&&!test:*

All your scopes you can find

Android Studio -> Preferences -> Appearance & Behavior -> Scopes  

Also you can customise a pattern by using syntax

[Skip generated files pattern]

Solution 5 - Intellij Idea

BTW: I am using the latest version of Intellij 2020.3

steps to follow:

  1. Create your own Scope (Settings –> Appearance & Behaviour –> Scopes)

enter image description here

  1. Display Find Usages Settings dialog (Ctrl + Alt + Shift + F7)

  2. Select your custom scope from the dropdown menu and click on Find

  3. For the second time, Display Find Usages Settings dialog (Ctrl + Alt + Shift + F7)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRomanView Question on Stackoverflow
Solution 1 - Intellij IdeaDagRView Answer on Stackoverflow
Solution 2 - Intellij IdeaVicView Answer on Stackoverflow
Solution 3 - Intellij IdeaDouy789View Answer on Stackoverflow
Solution 4 - Intellij IdeayoAlex5View Answer on Stackoverflow
Solution 5 - Intellij IdeaIkbelView Answer on Stackoverflow