Early Access Program

CLion 1.5 EAP: new code generation possibilities and improved auto-import

Hi,

Previous CLion EAP build included variadic templates support and was called experimental, since we were not sure about the quality of the support and the performance. After a week we see that though some issues and regressions are still present, the overall impression is positive, so we decided to push variadic templates to the upcoming release.

Today another EAP build is available for download, and its main focus is code generation.

Generate definitions and more

CLion helps you implement your ideas at the speed of thought with the code generation features, getting routine and mundane tasks out of your way. The set of features includes Override/Implement, generating constructors/destructors and getter/setter functions, ‘Surround with’ and Live Templates, and create from usage possibility.

Override and Implement actions generate stubs for virtual member functions from any of base classes. Having a couple of requests related to these features, we now added generate definitions (Shift+Ctrl+D on Windows/Linux, ⇧⌘D on OS X), that (we believe you can guess!) generates definitions for existing declarations. If the caret is placed inside the class, then the definition will be located right there in-place. In other cases, CLion will ask you about possible destinations (if several are possible):
generate_definitions

By the way, Override/Implement features now work in the same way, asking for a destination (if several options are available) or generating code in-place for the caret located inside the class. That means if you want the function to be generated in a header file – locate the caret in that class in your header file, and if you want it in the source file – execute action there.

Generate definitions can be called in various ways:

  • By pressing Shift+Ctrl+D on Windows/Linux, ⇧⌘D on OS X.
  • From the generate menu (Alt+Insert in Windows/Linux, ⌘N on OS X):
    generate_menu
  • As an intention action (Alt+Enter) – the only difference from the above is that intention action can generate only one definition at a time, while other options allow you to generate several function definitions at once.

This also makes Implement action more logical and consistent with other JetBrains IDEs – now it just overrides pure virtual functions from base classes.

Try this new feature and let us know what you think!

Auto-import

Another big change introduced in this EAP build is an improved auto-import. Import assistance in CLion allows you to add includes automatically when non-imported symbol is met. Just press Alt+Enter and the include statement will be added, no need to move cursor from the current position and interrupt your editing session.
Some unexpected headers were suggested for STL symbols before. In this EAP build we’ve implemented special heuristics to solve the problem for C++ files and STL symbols, and we encourage you to evaluate the changes:
auto_import

Besides, this build addresses the following problems:

  • When the code generation is called or Extract Function refactoring is invoked, the enum types arguments and return types are now passed by value, not by reference (CPP-5781).
  • The bug with generating incorrect implementation for functions with default value is fixed (CPP-1889).
  • The bug with Rename that didn’t update non-code usages in case refactor preview was called is now fixed (CPP-5471).

As usual, full release notes are available by the link. Download the build 144.4199 from the confluence page. Unfortunately, due to some technical issues patches are not available this time. We are sorry for the inconvenience.

Read about all new features coming to the next release on Preview Next Version page on our site.

The CLion Team
JetBrains
The Drive to Develop

Discover more