IntelliJ IDEA 14.0.0 Web Help

Scope

On this page:

Basics

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. Besides, you can configure coloring for each scope to see at once what sort of file you are dealing with.

Scopes get more helpful as your project grows larger. There are a lot of predefined scopes that cover basic cases. Additionally, you can add your custom scopes to the project. For example, you can create custom scopes for tests or for files you are responsible for in a team.

Types of scopes

Scopes can be either shared or local:

  • Shared scopes are accessible for the team members via VCS and are stored at the project level. If the project has a file-based format, the shared scopes are stored in the *.ipr file; if the project has a directory-based format, the shared scopes are stored in the misc.xml file.
  • Local scopes are intended for personal use only and are stored in your workspace ( *.iws file in the file-based project format, or in the file workspace.xml in the directory-based format).

If necessary, you can share a local scope, make a shared scope local, or create a copy of the scope. For more information, see Configuring Scopes and File Colors.

Defining scopes

IntelliJ IDEA provides a special language that enables you to flexibly define the sets of entities included in a scope. See Scope Language Syntax Reference for details.

To create and edit scopes, use the Scopes page of the Settings dialog. Scopes are defined in the following modes:

  • Manually, by specifying file masks according to the scope language syntax in the Pattern text box.
  • By selecting files and folders and clicking the buttons Include, Include Recursively, Exclude, and Exclude Recursively. Based on the inclusion/exclusion, IntelliJ IDEA creates an expression and displays it in the Pattern.

    Refer to the section Configuring Scopes and File Colors.

You can explore the available scopes in the Project tool window.

Scopes coloring

Files belonging to different scopes can be highlighted in different colors throughout the products's user interface: in navigation lists, in the editor tabs, in the Project window . This allows much faster and easier navigation in large projects.

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.

For detailed instructions on how to configure the scope order and scope-color associations, see Configuring Scopes and File Colors.

Predefined scopes

IntelliJ IDEA provides a number of predefined scopes, for example:

  • Project Files. This scope includes all the files within the project content roots (seeModule Contents). Module dependencies (libraries and SDKs), generally, are not included in this scope.
  • Problems. This scope is available only as a view in the Project tool window. It includes the files within the project content roots in which syntactic errors are found.
  • Project and Libraries. This scope includes all the files within the project content roots, and also all module dependencies (libraries and SDKs). In the Project tool window, this scope corresponds to the scope view All.
  • Project Production Files. This scope is similar to the Project Files scope. The difference is that the test source roots are not included. In the Project tool window, this scope corresponds to the scope view Production.
  • Project Test Files. This scope is limited to the project test source roots. In the Project tool window, this scope corresponds to the scope view Tests.
  • Non-Project Files. This scope is available only as a view in the Project tool window. It is limited to module dependencies (libraries and SDKs).
  • Changed Files. This scope corresponds to all changed files, that is, ones associated with all existing changelists.
  • Default. This scope corresponds to the files associated with the changelist  Default.
  • Favorite '<name>'. This scope corresponds to a list of favorite items with the specified name. See Managing Your Project Favorites.
  • Selected files. This scope corresponds to the files currently selected in IntelliJ IDEA (e.g. in the Project tool window).

Predefined scopes cannot be edited.

See Also

Last modified: 12 November 2014
comments powered by Disqus