Skip to main content

Metals v0.8.4 - Cobalt

· 7 min read

We are happy to announce the release of Metals v0.8.4, which will most likely be the last 0.8.x version.

Commits since last release174
Merged PRs55
Contributors9
Closed issues13
New features3

For full details: https://github.com/scalameta/metals/milestone/22?closed=1

Metals is a language server for Scala that works with VS Code, Vim, Emacs, Sublime Text, Atom and Eclipse. Metals is developed at the Scala Center and VirtusLab with the help from Lunatech along with contributors from the community.

TL;DR

Check out https://scalameta.org/metals/, and give Metals a try!

  • navigating to parent method
  • support for launch.json
  • new "Create new symbol" code action
  • miscellaneous improvements

Metals will now calculate if any definition of a method in the current file overrides another method, in which case it will show a new lens next to the method's position. Once clicked, the user will be able to go to the super method. Lenses also link to methods in external dependencies and are displayed in files from libraries. For this new feature to work make sure that you enable code lenses in your client.

Screenshot 2020-03-10 at 09 24 41

If they are found to be disturbing your workflow they can be easily disabled via the metals.superMethodLensesEnabled configuration option - they are enabled by default. For example in Visual Studio Code:

Screenshot 2020-03-09 at 16 24 21

These new lenses should be quick to calculate but if you notice significant slowdown you can also disable them, since when disabled they are not only not displayed but also not calculated at all.

There is also an exposed server command goto-super-method that can be mapped and used through shortcut in Visual Studio Code.

Screenshot 2020-03-10 at 09 38 49

It is possible to also navigate the whole inheritance hierachy at once using the new super-method-hierarchy command.

super-hierarchy

This new command can be invoked on a method definition. It calculates super method hierarchy and if more than one position is found it displays a quickPick window (same as the new scala file feature) which displays all super methods and allows a user to select one and jump to its definition.

As an example in Visual Studio Code it can be bound to a shortcut this way:

Screenshot 2020-03-10 at 09 48 55

Thanks to kpbochenek from VirtusLab for this new feature!

Support for 'launch.json'

Previously, it was only possible to launch main classes or tests via code lenses that would appear above a particular class. Now, we add a way for a user to be able specify the name of the the class or test to run. We will then automatically try to detect the build target, which that class/test belongs to and run it. In this release, we also add a way to specify the main class arguments.

launch_debug3

While this will be primarily useful for the Visual Studio Code Metals extension, it will also make it easier for other editors that support the Debug Adapter Protocol. To obtain the uri needed for starting a debug session users can now execute the debug-adapter-start command with params:

  • for main class
{
"mainClass": "com.foo.App",
"buildTarget": "foo",
"args": ["bar"]
}
  • for test class
{
"testClass": "com.foo.FooSuite",
"buildTarget": "foo"
}

buildTarget is an optional parameter, which might be useful if there are identically named classes in different modules. A uri will be returned that can be used by the DAP client.

More information about adding support for debugging is available here.

This awesome new feature was contributed by alekseiAlefirov from VirtusLab.

New 'Create new symbol...' code action

Previously we would propose to import a symbol (if available) in response to "missing symbol" errors. Now, thanks to gabro, we also propose to create a new class, case class, trait or object.

2020-03-23 17 49 31

This might be useful when sketching out a domain model and should improve user experience for fast prototyping.

Miscellaneous improvements

  • package is no longer added on imports from package objects
  • if user right clicks on a file in Visual Studio Code the option for New Scala file also shows now the same as for directories
  • a multiline string can now be formatted exclusively when using format selection on that string
  • added in ... to signify truncation in worksheets
  • fixed hover on Scala App trait and several other cases that showed up on Scala Play projects
  • messages about upgrading Scala versions are now more valid to the user
  • references in a file are sorted before showing them
  • better cursor position when creating new files using the New Scala file command
  • added "case class" option in NewFilesProvider

Contributors

Big thanks to everybody who contributed to this release!

$ git shortlog -sn --no-merges v0.8.3..v0.8.4
Olafur Pall Geirsson
Chris Kipp
Aleksei Alefirov
Gabriele Petronella
Tomasz Godzik
Krzysztof Bochenek
Alexandre Archambault
Scala Steward
Martin Duhem
Tomasz Pasternak
Łukasz Wawrzyk
Meriam Lachkar
duianto

Merged PRs

v0.8.4 (2020-04-10)

Full Changelog

Merged pull requests: