Type-aware highlighting

Type-aware highlighting is a part of error highlighting that relies on type system.

Some errors can be found without using type information, for example:

Other errors, however, require a knowledge of entities type:

Type-aware highlighting allows to spot such errors before compilation.

Why isn’t it enabled by default?

The feature is in beta (or maybe in alpha) and sometimes may report “false errors” in regular code. Usually, such “errors” “found” only in a truly complex code, and, normally, everything works just fine.

Scala plugin doesn’t rely on compiler to analyze code. We’re implementing our own model of the language, and sometimes it’s challenging, especially when it comes to Scala’s type system and type inference (to size up the problem, you may try to formally “infer” a type of “foo”.map(_ + 1) expression by hand).

Should you enable it?

Unless such highlighting produces too much false “red code” in your project, you can benefit from better code analysis. It’s recommend to try type-aware highlighting in a particular project to evaluate whether it’s good there.

How to configure it?

In every project (with at least one Scala facet used) IDEA initially suggest to try type-aware highlighting, so you may configure it right off the bat:

You can always toggle type-aware highlighting using Ctrl+Alt+Shift+E shortcut or by clicking the highlighting icon on statusbar:

There’s a notification shown on each highlighting status change:

How to deal with false errors?

So, the truth is you have to remember that sometimes there’s no spoon error.
To help us to fix a highlighting glitch you may report it to YouTrack as usual or by pressing Alt+Enter on wrong highlight:

About Pavel Fatin

Programming enthusiast, technology advocate. IntelliJ Scala plugin developer at JetBrains, https://pavelfatin.com
This entry was posted in Uncategorized. Bookmark the permalink.

6 Responses to Type-aware highlighting

  1. Alain O'Dea says:

    I have been very happy with this feature. Besides some issues with XML patterns and DSL applications like Squeryl (both known and acknowledged in YouTrack) this works very well. It gets better with every nightly and is a very helpful way of seeing errors early without having to compile.

  2. wolverian says:

    It seems pretty crazy to implement your own Scala type inferencer. The presentation compiler isn’t powerful/usable enough?

  3. v6ak says:

    Great. But I don’t uderstand such crazy keyboard shortcut :(

  4. Chris Cobb says:

    I don’t see this features in intellij 12.1 CE on the mac (no icon on the bottom, trying the toggle shortcut and various mac equivalent bindings had no effect). Is this a UE only feature?

  5. Chris Cobb says:

    update: I just noticed that I’m in a java project and this is a feature of the scala plugin. Is it safe to say this is a scala only feature?

Leave a Reply

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