Whats new in Xtext 2.2

See what was new in the previous release

Xtext 2.2 offers a lot of new features and improvements. All in all, over 110 bug reports and feature requests have been solved since Xtext 2.1. Here is a summary of the most significant enhancements:

Changes to Xtext

Guava and Inject 3.0

Xtext ships now with Google Guava 10 and Google Guice 3.0.

Embedding Xbase - Xtext editor
Embedded Form Editor

An Xtext editor can now easily be embedded into form-based editors.

@Inject EmbeddedEditorFactory factory;

factory.newEditor(resource).
        showErrorAndWarningAnnotations().
        readOnly().
        withParent(aComposite)

Changes to Xtend

Language Improvements

Constructors

It is now possible to declare constructors in Xtend classes. To avoid redundant typing of long class names, constructors are always named "new".

Xtend - Constructors
Static Members

Fields and Methods can now be static. Even though best practices suggest to avoid statics, they can be needed to integrate with other frameworks or to implement Java's "main" method.

Xtend - Static Members
Field Initializer

Field declarations can now specify an expression to initialized the field with a value. Note, that since in Xtend everything is an expression, fields can be initialized with whole blocks.

Xtend - Member Field Initializers
"throws" Clause

Methods can now specify which exceptions they throw. However, Xtend does not require you to catch or pass on checked exceptions, since all exceptions are treated as unchecked.

Xtend - Member Field Initializers

Tool Improvements

Get Started Easily

Getting started is now simpler than ever:

  1. Create a new Java Project
  2. Create a new Xtend class via "New..." "Xtend Class"
  3. In the Xtend class, trigger the Quick Fix to add the Xtend library to the class path
Xtend - Member Field Initializers
"Run as ..."

Via the "Run As ..." and "Debug As ..." menus and keyboard shortcuts, Xtend files can now be executed as Java Application, JUnit Test and JUnit Plug-In Test.

Xtend - Run as Java Application
Xtend - Run as JUnit Application
Maven Support

Xtend compilation can be executed standalone. No Eclipse required. There even is a Maven plugin for that. Also Xtend's standard lib is available from a Maven repository. Read more »

<build>
    <plugins>
        <plugin>
            <groupId>org.eclipse.xtend2</groupId>
            <artifactId>xtend-maven-plugin</artifactId>
            <version>2.2.0</version>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
Type Hierarchy

JDT's Type Hierarchy does now also work for Xtend classes. In the screenshot, you can see an inheritance hierarchy that mixes Java and Xtend classes.

Xtend - Type Hierarchy
Quick Fix
"Implement Members"

In case an Xtend class extends an abstract class or implements an interface, there is now a Quickfix available to create stubs for all methods that need to be implemented.

Xtend - Member Field Initializers
Xtend Lib

Xtend ships with a small set of libraries, which are now available in a predefined container. There also is a quick fix to add this library to your project's class path conveniently. The library can alternatively be retrieved from a Maven repository : Read more »

Xtend - Type Hierarchy
Xtend - Type Hierarchy