Child pages
  • Auto Import of Classes
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 14 Next »

Scala plugin automatically inserts import statements for the class names you are using.

When you type a class name, the editor automatically suggests the fully qualified name and offers you to press Alt+Enter to insert appropriate import statement.

The auto import settings can be adjusted in the Settings Dialog:

  1. Press Ctrl+Alt+S to open the Settings Dialog
  2. Expand Code Style and click Scala
  3. Select Imports tab.

Scala language gives you a number of ways to use import statements:

  • Import not fully qualified class names
  • Declare an import statement in any code block
  • Use placeholders to import more than one class in a single statement

Scala plugin provides the support for all these language features:

  • Auto import feature inserts the shortest qualified name, if possible. Otherwise, the _root_ qualifier is added.
  • All import statements from one package are collapsed to a single statement. 
  • If a class name matches only a single valid package, it's imported on-the-fly, without requiring you to press Alt+Enter.
  • Import statements can be inserted anywhere in the file, not only the header.
  • If a number of classes imported from a package exceeds a specified threshold, the import is collapsed to a package level.
  • No labels