Insert imports on paste

For a long time Scala users have been deprived of conveniences offered by automatic imports insertion on code paste (which most Java-developers take as a matter of course). Now it’s time to take our revenge!

Here’s where the main switch lays:

Now we can take some code with many dependencies of different kinds:

Then select desired lines and copy them, as usual:

Afterwards, let’s paste them here:

After code insertion we have a choice to import required dependencies (those that are not  already available):

Consequently, we have all needed dependencies automatically restored and thus our types, methods, packages, conversions and extractors accessible:

The same functionality also works for Java-to-Scala converted code. For instance, let’s copy foo method from the following Java snippet:

When we paste paste that method to a Scala destination we will be asked to automatically convert Java code to Scala:

After the code is automagically converted, we still have a choice to handle dependencies:

Here’s a result of the integral automation:

About Pavel Fatin

IntelliJ Scala plugin developer (http://pavelfatin.com)
This entry was posted in Uncategorized. Bookmark the permalink.

3 Responses to Insert imports on paste

  1. Quartz says:

    YEEEEEEEEEEEESSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS

  2. OlegYch says:

    So cool!
    You are the best.

  3. Every day I read this blog and it pleases me to be written here posts.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>