What's New in IntelliJ Elixir 10.0.0

Umbrellas overhead
Elle Imhoff

Engineer

Elle Imhoff

IntelliJ Elixir, the Elixir plugin for JetBrains IDEs (IntelliJ IDEA, Rubymine, WebStorm, etc), version 10.0.0 has been released.

Dependency Management

The big feature of 10.0.0 was automatic module and library dependency management.

Project Structure for umbrella project with OTP app module dependencies and transitive library dependencies

Modules for Umbrella Project OTP Apps

In IntelliJ IDEA, each project can have one or more modules. Modules can have different content roots than the project and modules can depend on each other.

Prior to IntelliJ Elixir 10.0.0, when using Import project from external Mix model, each directory with a mix.exs file would be importable as a separate module:

  • the root directory of umbrella projects
  • each OTP Application in the apps/ directory.

When you were in a file in an apps/ application, searching for functions of module with Go To Symbol, you’d only see entries for the current IntelliJ module for the apps/APP directory. Not being able to use Go To Symbol to search in_umbrella: true functions was inconsistent with Go To Definition on the function call. Go To Definition did work because of the _build being shared and decompiled across IntelliJ modules.

In 10.0.0, in_umbrella: true dependencies have their corresponding module added as a dependency in Project Structure Modules, which makes the scopes for Go To Symbol match the resolution rules used by mix and elixirc.

External Libraries for mix and rebar3 Dependencies

Non-in_umbrella: true dependencies in deps no longer count as part of your project source code, so the “Include non-project symbols” works like JetBrains developed IDEs now.

Imgur

This means that if you use common names for functions, you no longer need to wade through all the hits from your libraries and are only presented with results from the code you wrote. This uses the built-in support from the JetBrain’s OpenAPI, so if there are no in-project results, non-project results are automatically shown.

Imgur

This separation of libraries is automatic because package management files are scanned when a project is imported and on any filesystem change.

Supported package manager files include:

  • mix.exs for mix
  • rebar.config for rebar3 if you’ve also installed the Erlang plugin (which I recommend so get all the features you like in Elixir in Erlang too.)

The deps in each format are then used to build a dependency tree and register all libraries in the Project Structure.

Imgur

To make the libraries external deps is automatically marked as Excluded.

Imgur

Excluding the dependencies while also marking them as Libraries makes them appear in External Libraries at the bottom of the Project Pane, so now the SDK is no longer lonely.

Imgur

This matches how Rubymine shows Rubygems.

Go To Module

Go To Class (Cmd+O on macOS / Ctrl+N on Windows/Linux) will search only module names.

Imgur

So, you no longer have to wade through function, macro, and module names when you know you’re only looking for a module as is the case with Go To Symbol.

Imgur

Hyperlinking Stacktraces from .eex Files

In addition to .ex and .exs files, now stacktraces involving .eex files are linked too.

Imgur

Test Runner

Match ExUnit.CliFormatter Output Format

Some of the newer features of the ExUnit.CliFormatter are now ported to the Test Runner:

  • rich diffs
  • ANSI colors
  • capture log output on failure

Imgur

Support Elixir 1.7 ExUnit Changes

Elixir 1.7 and 1.6 have different names for categories of ignored tests. They differentiate between excluded tests with the --exclude command line option and skipped test with the @tag :skip. The test runner now converts both to JetBrains’s ignored. The overall run will use the ignore icon, so you know you haven’t run all the tests too because of this change.

Imgur

Count Test Compilation Failures as Test Failures

mix test has a slight weakness when interface with external tools: the ExUnit.Formatter is only called during tests runs, so if the body of a test macro has a compilation error, the formatter is never called. Since the formatter is how ExUnit is transformed into the ##teamCity messages that JetBrains Test Runners understand, the formatter not being called leads to the unhelpful “Test framework quit unexpectedly” message in the Test Runner.

Since mix test is running in an external process and all stdio is piped through the plugin before being displayed, I was able to detect when compilation errors happen and then fake test failures if a stacktrace appeared to be coming from inside a test file.

Imgur

Debugger Filtered Modules

:crypto joins the growing list of NIF libraries that just really don’t want to be interpreted by the debugger, but don’t tell :int until they’ve crashed the module’s supervision tree. :crypto is now part of the default filtered modules list. If you have customized the list, you can add :crypto to your filter list.

Installation

You can install IntelliJ Elixir v10.0.0 from inside any of the support JetBrains IDEs.

I recommend using IntelliJ IDEA (Community or Ultimate) edition if you’re using umbrella projects as only it can support the new multi-module project features.

Pre-Release Builds

All these new features weren’t developed at once. Each one was merged as a separate PR. If you want to get features as soon as they are available and not wait for the next stable release, automatic canary builds are now published as GitHub releases marked as pre-release and on the canary release channel which can be added inside of JetBrain IDEs with this URL: https://plugins.jetbrains.com/plugins/canary/7522.

DockYard is a digital product agency offering exceptional user experience, design, full stack engineering, web app development, software, Ember, Elixir, and Phoenix services, consulting, and training.

Newsletter

Stay in the Know

Get the latest news and insights on Elixir, Phoenix, machine learning, product strategy, and more—delivered straight to your inbox.

Narwin holding a press release sheet while opening the DockYard brand kit box