Scala logo

Scala Plugin

Scala Plugin for IntelliJ IDEA and Android Studio


Cherish your packages

After the introduction of chained package clauses in Scala 2.8 we have the ability to rewrite “package” as “package foo; package bar” in order to automatically import all “foo” package entities (so, these two declarations are not equivalent).

Scala plugin used to flatten packagings structure on moving or copying classes, but now there’s a better algorithm, that preserves desired package chaining. Let’s consider the following example:

If we move that class to “” package we will get the following:

In addition to explicit package chaining we can specify a base package in a module facet:

After that, all packages that start with the base prefix will be chained automatically.

Moreover, there’s a warning about the lack of chaining at the base level:

We can use a build-in “quick fix” to split that declaration automatically:

We can also split and join such lines using Smart Enter (Ctrl + Shift + Enter) and Join Lines (Ctrl + Shift + J) actions. Here’s how it works:

After Ctrl + Shift + Enter we will get:

Then we may join the packages again with Ctrl + Shift + J:

P.S. Thanks to Jason Zaugg for some of these features