Scala Language Console (Nika builds)

New scala console comes with build 0.5.89 (http://confluence.jetbrains.net/display/SCA/Scala+Plugin+Nightly+Builds+for+Nika).

Now you can use full featured editor for editing code in console (just instead of Enter, use Shift + Enter).

For example:

And after execution:

This comes only with Nika scala plugin builds (this is the first difference between Nika and IDEA X plugins).

Posted in Uncategorized | 6 Comments

Real FSC support

Usual Scala compilation never seems fast enough. There are two main reasons why:

  • It takes a lot of time to start Scala compiler and to process standard libraries.
  • Scala compiler doesn’t support selective recompilation.

The first problem is solved by FSC (Fast Scala Compiler). FSC runs a compilation daemon to avoid subsequent compiler instantiations (at the price of increased memory usage).

However, FSC still re-compiles everything you throw at it (usually – the whole project, even if you’ve changed a single file). To speed up compilation further, we need to use a selective recompilation, that is provided only by third-party tools (like SBT or IDE).

So, the combination of IDEA and FSC can provide lightning-fast Scala compilation.

Scala plugin has been supporting FSC for a long time. Kind of… It was hard to configure and use FSC, settings was vague and compilation daemon was … you know, uncontrollable. Now that things have changed.

We can setup either internal FSC server (per project) or external (possibly remote) one:

Then we may use that server in any module we want:

So we can mix FSC with ordinary Scala compilers (when there are multiple versions of Scala used or when we need special compilation settings for some modules).

IDEA automatically manages internal FSC servers – it starts an instance when needed and stops it on application exit (or project close). Additionally, we can manually start, stop or reset compilation daemon using a menu on FSC status icon:

Besides FSC status icon (a little gear-gauge in the status bar) we are receiving notifications on FSC events:

P. S. Mac users may need to configure the OS X firewall for FSC communication.

Posted in Uncategorized | 15 Comments

IDEA 11 Scala plugin version

Recently we finally published plugin for IDEA 11 (http://plugins.intellij.net/plugin/?idea&id=1347). This post is about current plugin development state.

Now we have two major development branches:

Until IDEA 11 release almost all bugfixes will be in both versions. However I’m sure it’s not the same statement about major features, because of dependency on IDEA.

Nightly builds will be for both plugin versions:

Posted in Uncategorized | 16 Comments

Some Smart Completion

It’s not just “Some Completion”, it’s about scala.Some.

In case if you have expected type Option[AnyType] you possibly have something of type AnyType and you want to use it like Some(anyTypeValue). So now you can invoke smart completion two times and you will see such possibilities

And then you will get

Posted in Uncategorized | 1 Comment

Global members class name completion in Scala

Recently such functionality was implemented in Java editor. And now it’s also available in the latest nightly build of Scala plugin.

This feature is about how to use global names fast. You can invoke Ctrl + Alt + Space (Class Name Completion) on any prefix of known global method or value

Then you can choose member to import it with prefix

Or you can press Alt+Enter and choose importing member statically

 

Posted in Uncategorized | 1 Comment

Update nightlies daily

Generally, we recommend using nightly builds of Scala plugin to stay up to date in cutting-edge features and bug-fixes. Most nightlies are rather stable and may often work even better than “officially stable” releases.

Although we can always download the latest nightly build and update Scala plugin by-hand, there is now a better way to get recent versions.

Just add “http://www.jetbrains.com/idea/plugins/scala-nightly.xml”
into Settings / Updates / Plugin Hosts:

After that, you can receive notifications on new plugin nightlies:

Update with pleasure :)

Posted in Uncategorized | 7 Comments

Scala vs Kotlin vs Scala plugin

There are some concerns in Scala community surrounding the introduction of Kotlin.

Besides arisen Scala vs Kotlin battle, there’s a question on whether JetBrains will continue to develop IntelliJ Scala plugin.

To settle the doubts we would like to announce that despite Kotlin’s claim that “Scala is too complex and it’s very hard to make a good tooling support for it” we will continue to do our best to provide an excellent Scala support in IntelliJ IDEA.

We really love Scala, and we hope that both languages are great enough to rule in their own niches.


Posted in Uncategorized | 13 Comments

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:

Posted in Uncategorized | 3 Comments

Generate anonymous function feature

In Scala, you can use anonymous functions. Now you can generate them automatically in case if it’s method call argument.

Lets, for example you have the following code:

Then use smart completion (Ctrl + Shift + Space) to see an appropriate variant:

After the completion you will get:

This feature works like Live Template, so you will be able to replace variable names and abstract types (in the next example Int is chosen automatically for ‘foldLeft’ type parameter, but you can replace it, if you want).

Also you can use brace syntax for method call (then partial anonymous function will be generated):

After completion you will get:

Posted in Uncategorized | Tagged | 3 Comments

Redundant Return

Find it hard to shake of the Java-isms? Here’s a little inspection and quick fix to help out when you redundantly use `return`.

After the quick fix is applied:

What other anti-patterns do you notice in code written by recent converts from Java? Pattern Matching on booleans? Overuse of Option#isDefined? Providing inspections for these can help keep code clean and educate the programmer; we’re interested in what you thing is important.

Posted in Uncategorized | 5 Comments