--- layout: post title: Xtend 2.7.0 Release Notes date: 2014-09-02 09:30:28 categories: releasenotes ---

Version 2.7 got many new features, bug fixes and performance improvements (full bugzilla list). The most noteworthy changes are the following.

Language

Sugared Lambdas With Zero And More Than Two Arguments

It is now allowed to leave out parameter declarations for all lambda expressions using a positional syntax, similar to Apple's Swift:

#[1, 2, 3].reduce[$0 + $1]

Unqualified Enum Usage

Enum constants in annotations and switch expressions can be referenced without their type name.
@Retention(RUNTIME)

Inner Type of Parameterized Types

Type inference for parameterized inner classes was improved and supports types like
OuterType<T>.InnerType

Deprecated and Dead Code Analysis

The validator will now detect use of deprecated API and is much better at finding dead code. Would you have spotted the following?

Library

New Extension Methods on Iterables

The standard library has new extension methods for Iterables, including min/max, groupBy and indexed.

#["Xtend", "Java", "Eclipse"].maxBy[length]

New Active Annotations

New Active Annotations have been added to free you of some repetitive tasks. The new @Accessors generates getters and setters, with fine grained control and even for all fields of a class if you want. The @Delegate annotation automatically implements the delegation pattern for you, so you only need to concentrate on methods that you actually want to implement differently than just delegating. Here is an example:

interface I {
def void m1()
def void m2()
def void m3()
}
class A implements I {
override m1() {}
override m2() {}
override m3() {}
}
class B implements I {
//all methods automatically implemented
@Delegate A delegate = new A
}

Other additions include @ToString, @EqualsHashCode, @FinalFieldsConstructor and a new @Data (the old one is now deprecated as well as @Property).

Active Annotations API Improvements

The active annotation API integrates even deeper with the IDE. Every generated element can (and should) now declare its source element. This tracing information is used in places like the outline view. A separate validation phase has been added, so the end result after running all transformations can be validated. Also, changes to classes and even arbitrary resources that the annotation processor requested are detected and lead to automatic rebuilds.

IDE Features

Debugging

Xtend breakpoints can now have conditions. Conditions are written in Java, so you get full access even to synthetic variables inserted by the Xtend compiler. Of course you also get content assist in the condition editor.

Breakpoints can now be toggled, enabled/disabled and inspected via the ruler context menu.

Content Assist

Content Assist has become a lot faster and more accurate at the same time. It will now also retain the "is"-prefix of boolean properties.

Performance Improvements

Performance has reached a new level with big improvements to Content Assist, parallel code generation and lots of fine tuning. Also, Xtend will now cancel jobs (like outline refreshing) when you start typing again, making the editor much more responsive.

Outline with Java-Mode

The outline view now supports two modes: One shows the original Xtend AST, the other one shows the resulting Java AST. This is very useful in the presence of Active Annotations that add a lot of new members to a class.

Organize imports on packages

You can now use "Organize Xtend Imports" on whole packages via the "Source" context menu.

Template proposals support import

A new type of template variable was added. It adds an import to an Xtend file when the template is inserted. This greatly reduces the need for qualified type names in templates.

Open return type

Ever wondered what you can do with the type of a variable or the return type of a method? You can now CTRL-Click on feature calls and open the declaration of the return type of that call.

Show errors from derived Java files

By using black box Java code within active annotations the generated Java source could sometimes have errors while the Xtend code is fine. In those cases, the errors are now shown at the appropriate locations in Xtend as well.

Maven and Java 8

The Xtend Maven plugin is now toolchain-aware. Using this, you can for instance run Maven on Java 8, but compile against a JDK 6.