IntelliJ IDEA 2017.3 Help

Scopes

File | Settings | Appearance and Behavior | Scopes for Windows and Linux
IntelliJ IDEA | Preferences | Appearance and Behavior | Scopes for macOS
Ctrl+Alt+S settings


A scope is a set of files to which various operations apply. Using this dialog, you can define scopes for the various IntelliJ IDEA actions, for example, Find Usages, or Code Inspections.

Main toolbar

ItemTooltipDescription
addAdd scope
Insert
Click this button to add a new local or shared scope.
deleteDelete
Delete
Click this button to delete the selected scope from the list.
copyCopy configuration
Ctrl+D
Click this button to create a copy of the selected scope.
ioSave asClick this button to have the selected local scope saved as shared or a selected shared scope as local.
arrowUp arrowDown Move Up/Move DownUse these buttons to move the scopes up and down in the list.

If some file is included into several scopes, the order of the scopes becomes important: IntelliJ IDEA uses the color of the uppermost scope (shown in the Scopes settings page) to highlight such file. Of course, you can change the order of the scopes, and thus the resulted highlighting.

Scope configuration controls

ItemDescription
NameIn this text box, specify the scope name.
PatternIn this text box, specify the pattern that defines the current scope. The following elements and structures can be used:
  1. The file: modifier. The element is mandatory.
  2. The * asterisk to denote any symbol in a file name or file extension.
  3. Logical operators AND (&&), OR (||), and NOT (!).

For more information, see Scope Language Syntax Reference.

Do one of the following:

  • Type or edit the pattern manually in the text field Pattern.
  • Click expand icon, or press Ctrl+NumPad Plus to type or edit in the expanded area. (Click collapse icon or press Ctrl+NumPad - to return to a single-line area.)
  • Choose the desired files in the Project Tree View and use the buttons described below to make IntelliJ IDEA generate the corresponding pattern automatically.

Storing empty or incorrect patterns is not allowed. In such cases, you will be prompted with the Syntax Error warning.

Examples

  • file[MyMod]:src/main/java/com/example/my_package//* - include in a project all the files from module "MyMod", located in the specified directory and all subdirectories.
  • src[MyMod]:com.example.my_package..* - recursively include all classes in a package in the source directories of the module.
  • lib:com.company..*||com.company..* - recursively include all classes in a package from both project and libraries.
  • test:com.company.* - include all test classes in a package, but not in subpackages.
  • [MyMod]:com.company.util.* - include all classes and test classes in the package of the specified module.
  • file:*.js||file:*.coffee - include all JavaScript and CoffeeScript files.
  • file:*js&&!file:*.min.* - include all JavaScript files except those that were generated through minification, which is indicated by the min extension.
IncludeClick this button to have the selected element included in the scope. The corresponding expression is automatically generated and added to the expression in the Pattern text box.

If the current element is a folder, the nested subfolders are ignored.

Include RecursivelyClick this button to have the selected folder included in the scope, together with the nested subfolders. The corresponding expression is automatically generated and added to the expression in the Pattern text box.
ExcludeClick this button to have the selected element excluded from the scope. The corresponding expression is automatically added to the Pattern. If the current element is a folder, the nested subfolders are ignored.
Exclude RecursivelyClick this button to have the selected folder excluded from the scope, together with the nested subfolders. The corresponding expression is automatically added to the Pattern field.

Scope toolbar

ItemTooltipDescription
Project tree viewThe tree view contains all the files available in your project. In the view, select the desired files to be included in the current scope and have the scope definition pattern generated automatically. The message on the toolbar shows the total number of available files and the number of files included in the scope. See also the color legend below. Use the toolbar buttons described below to change the view presentation.

The way of presentation of the project tree view, the available controls and scopes language syntax depend on the selection in project vs package drop-down list.

flattenPackagesFlatten PackagesWhen the button is pressed, all the packages are displayed as a single-level tree view. This enables you to find a package somewhere deep within the project by its name without going through the entire tree hierarchy.
compactEmptyPackagesCompact Empty Middle PackagesThis option lets you specify how or whether empty packages are to be shown. (Empty packages are ones that contain nothing but other packages.)
groupByScopeTypeGroup by Scopes TypeWhen this button is pressed, the items in the tree-view are grouped below three nodes:
  • Library Classes
  • Production Classes
  • Test Classes

This button is only available for the Package presentation of scopes.

showFilesShow FilesIf this button is pressed, source files are displayed explicitly in the tree view. When the files are shown, they can be selected for exclusion/inclusion into a pattern.
scope_pattern

If this button is not pressed, the files are hidden.

commonfilterShow Included OnlyWhen the button is pressed, the tree shows only the elements that are included in the scope.
scope project vs package
Use this drop-down box to define how you want the project files to be displayed in the tree view. The available options are:
  • Project
  • Packages

The project tree view presentation, scopes language syntax and the available toolbar buttons differ depending on the selection.

Legend of the project tree view

ItemDescription
green squareFolders and files included in scope.
BlackFolders and files excluded from scope.
blue squareFolders that contain both excluded and included files and subfolders.
Last modified: 6 March 2018

See Also