The Eclipse IDE 2022-06 (4.24) was recently released and numerous improvements were made over the past year. This article covers the most notable improvements, and is based on the New and Noteworthy content for Eclipse IDE releases 4.21 to 4.24.
Use the below links to jump to different sections of the article if there are particular improvements you’re interested in.
- Platform improvements
- Java development tools (JDT) improvements
- Debug improvements
- Eclipse plug-in development environment (PDE) improvements
________________________________
Platform Improvements
Many notable improvements have been made to the Eclipse Platform over the past year:
- Dark theme improvements in Windows
- Support for multiple carets and selections
- Commands for multiple carets and selections
- Default encoding for workspaces and projects
- Large file associations preferences
- Find actions can open files from file system
- New BorderLayout
Dark Theme Improvements in Windows
Dark theme improvements in Windows include:
- Widgets such as Table, Tree, CTabFolder, ToolBar, and MenuItem now support dark-theme tool-tips.
- The window title bar is now styled in the default dark theme.
- Buttons are now styled natively in dark theme.
- The Text widget now supports improved search and cancel buttons in the dark theme.
Support for Multiple Carets and Multiple Selections
Text editors and the underlying StyledText widget now support multiple carets and multiple selections. Multiple selections allows most edit operations — text replacement or insertion, extending selection to next word or to next line, copy/paste, and others — to apply simultaneously on all selected ranges.
This support is based on the new setSelectionRanges(int[] ranges) API in StyledText, which allows the user to pass an arbitrary number of selection ranges. When multiple ranges are used, the text widget displays them as distinct carets and selection ranges, and allows simultaneous edits at those locations.
Commands for Multiple Carets and Selections
Text editors now provide various commands to support multiple carets and selections that can be bound to user-defined keyboard shortcuts for easy selection of text regions in text editors. No default keys have been assigned yet, but they can be assigned using Window > Preferences > Keys.
Default Encoding for Workspaces and Projects
The Eclipse IDE now sets explicit encoding for new workspaces and new projects. Existing workspaces or projects with encoding already set are not affected and keep their original encoding.
Encoding for workspaces:
- If the IDE is started without an explicit default encoding set, UTF-8 is set as the default encoding for new workspaces.
- If encoding was specified at IDE startup as a JVM system property or by product customization preference, the custom encoding is persisted as the default encoding for new workspaces.
Encoding for projects:
- All new projects created in new workspaces also have explicit default encoding set, and they derive that encoding from the workspace encoding, not from random encoding taken from current OS settings.
- All new projects created with the 2022-06 (4.24) IDE release have explicit default project encoding set after creation, based on the workspace default encoding. Explicit project encoding makes it easier to share projects between workspaces with different encodings.
- If a project doesn’t have explicit encoding set, the IDE displays a warning and provides a quick fix that sets the project default encoding to the workspace encoding.
Large File Associations Preferences
A new set of preferences allows developers to specify which editor is used to open large files of a specific type so they can choose editors that scale better for large project files. For example, they can choose a text editor for large, generated sources, or an external editor for very large files that are not handled well by Eclipse IDE editors.
Find Actions Can Open Files From File System
The Find Actions command now allows a file to be opened if the query is the path of an existing file on the filesystem.
BorderLayout
The Standard Widget Toolkit (SWT) now supports a new layout type called BorderLayout that allows placing of controls as shown below.
________________________________
JDT Improvements
There are also several major improvements in the Eclipse JDT we’d like to highlight:
- Support for new Java versions
- JUnit quick fixes and feature additions
- New quick fixes and quick assists
- Code assist support added for modules
- New cleanups for String concatenations
Support for New Java Versions
Improved Java 17 support includes the following Java 17 features:
- JEP 306: Restore Always-Strict Floating-Point Semantics
- JEP 406: Pattern Matching for switch (Preview)
- JEP 409: Sealed Classes (Final)
Improved Java 18 support includes the following Java 18 features:
- JEP 420: Pattern Matching for switch (Second Preview)
- JEP 413: Code Snippets in Java API Documentation
JUnit Quick Fixes and Features
Mockito-based tests frequently use org.mockito.ArgumentMatchers.* This has been added to the Java favorites in the preferences under Java > Editor > Content Assist > Favorites. With this update, the organize imports action in the IDE automatically adds static imports for these classes if you use them in your tests.
For Java 16 and higher, JUnit tests can now be implemented as records. Right-clicking on an individual test, or the record itself, and selecting Run as lets you execute the test using the JUnit Plug-in Test or JUnit Test context menu choices.
JUnit support has been updated to JUnit 5.8.1, which adds support for JUnit 5 @Suite.
New Quick Fixes and Quick Assists
A new quick fix has been created to provide the Surround with try-with-resources action for resource leaks and potential resource leaks when the resource in question implements the AutoCloseable interface.
Two new quick fixes have been added to create a sub-type for a sealed type that doesn’t have any permitted types — a sealed super class. When selected, the appropriate new Class/Record/Interface wizard opens.
These quick fixes have been added to fix the error: Sealed class or interface lacks the permits clause and no class or interface from the same compilation unit declares Cls1 as its direct superclass or superinterface.
Code Assist Support for Modules
Code assist support has been added for modules in @see, @link, and @linkplain javadoc tags for projects using Java 15 or higher.
Pressing Ctrl + Space at the cursor location suggests module names the project has access to.
Pressing Ctrl + Space at the cursor location shows the packages the selected module exports.
Pressing Ctrl + Space at the cursor location shows the classes in the selected package.
New Cleanups
A new cleanup and quick assist has been added to convert appropriate String concatenations into Java Text Blocks. Appropriate String concatenations have at least three non-empty substrings with one per line and use Java 15 or higher.
With the clean-up, the code shown in the first screen is changed to the code shown in the second screen.
Additional cleanups include:
- Removing unused private method parameters
- Converting code to use StringBuilder instead of StringBuffer, which has synchronized methods and is slower than StringBuilder
If removing unused private method parameters might lead to a conflict with another method, the private method is renamed to be unique. The cleanup is not available if there is a method reference to the method, as in stream.filter(MyClass::foo).
__________________________________
Debug Improvements
Many new features have been added to improve the Debugging experience for Lambda expressions and in general. Here are the top five:
- Lambda Entry Breakpoints
- Variable evaluation in current execution stack
- Object labeling during debugging
- New Launch Configuration view
- Console support for stack from debug view
Lambda Entry Breakpoint
Entry breakpoints for lambda expressions can be added during debugging, which enables the debugger to stop at the lambda expression entry point instead of at the first expression on the line. You can see the breakpoint in the Breakpoints view for the functional interface. Double clicking the breakpoint in the Breakpoints view displays the associated lambda expression in the editor.
You can add a new lambda entry breakpoint by selecting Toggle Lambda Entry Breakpoint from the Ruler context menu or the Run menu. You can select a particular lambda expression to add the breakpoint; if none is selected, the entry breakpoint is added to the first lambda expression on the line. You can add only one breakpoint per line.
Evaluate Variables in Current Execution Stack
In debug mode, you can now evaluate variables in the current execution stack frame and the stack frames below it, regardless of the selected stack frame. Variables are defined in the current focused Java class.
Label Objects During Debugging
Because it's not always easy to distinguish between object instances when debugging a Java application, we added the ability to set a label on individual objects.
After setting the label, the object is displayed with a distinctive color and the label everywhere it appears.
Labeled object in Expressions view:
Launch Configuration View
The new Launch Configuration View provides quick access to all your launch configurations with no need to enter the launch dialogs.
Console Support for Stack from Debug View
The Java Stack Trace Console now supports navigation to Java types for Java stack traces copied from the Debug view using the Copy Stack action. The console underlines type names and line numbers. Clicking a link brings you to the corresponding source code. If the type name is not unique, the default Select type dialog is displayed so you can select the right type.
____________________________________
Eclipse PDE Improvements
This section highlights the following Eclipse PDE improvements:
- Addition of spies
- Eclipse views with browser technology
- Reference targets inside targets
- A new option to automatically include requirements when launching an application or product
Addition of Spies
Seven different spies have been added to PDE, which can be accessed using Window > Spies. Opening any spy opens a separate spy window with the relevant tracing and tracking information.
Eclipse Views With Browser Technology
A new plugin template called “View using browser technology” creates views and editors using the browser technology instead of the SWT.
You can create a plug-in with a browser-technology-view using File > New > Other... > Plug-in Project. On the templates page, select the last option, as shown below.
You can select one of two JavaScripts: a Workbench Interaction or a Game.
The Workbench Interaction view (left below) shows how to interact with the workbench using JavaScript, whereas Game view (right below) shows how to run a standalone web application inside a view.
Reference Targets Inside Targets
It’s now possible to reference a target file from within a different target file, which is useful in multiple scenarios. For example, you can:
- Use a target from a remote location, such as a GitHub repository using the http protocol, in your local IDE
- Use a target deployed at a maven repository using the mvn:<groupid>:<artifactid>:<version> (this requires m2eclipse with PDE integration)
- Extend an existing local target using eclipse-variables
- Combine any of the above options
A New Option to Automatically Include Requirements When Launching an Application or Product
The launch configuration and the content tab on the product editor have a new checkbox option that automatically adds required plug-ins or features when launching an Eclipse or Equinox application.
By default, this option is enabled for launch configurations based on features and disabled for those based on products, which reflects the previous behavior. In the product editor, the option is enabled by default.
Other PDE Improvements
Other PDE improvements include:
- API analysis now runs parallel to build job
- Removing re-exports is now flagged as a breaking change
- A new quick fix for Automatic-Module-Name header is redundant
Learn More and Download the Eclipse IDE
To learn more about these and other improvements in the Eclipse IDE over the past year and download the latest version visit the Eclipse IDE webpage.