ReSharper C++ 2019.2: Faster indexing, improved C++20 support, new code analysis checks, and better Unreal Engine support
Please welcome the second major update of this year – ReSharper C++ 2019.2 – with many great new additions!
The long ongoing work on speeding up the indexing has finally come to fruition in this product release. We’ve significantly enhanced code completion and navigation, and added new code analysis checks, new formatter options, and new code hints.
At the same time, we have been working towards better compliance with the C++20 standard (even though it’s still in progress in the Committee!). We’ve also made the editor smarter and added features to help game developers using Unreal Engine get more from it.
Here are the main highlights – click each area for the details:
- Faster indexing
- More C++20 support
- Enhanced code inspections
- More descriptive summary tooltip in code completion
- Updated code hints
- Search a file with the Go to File member dialog, and other navigation updates
- New settings in the formatter
- Improved typing assist
- Sophisticated Unreal Engine support
Get the brand new build from our site and evaluate its features and enhancements completely free for 30 days:
Completely new preprocessor implementation is now in use for indexing stages. After almost a year of work, we have now polished the new implementation to bring a significant performance boost. The measurements on LLVM (LLVM+clang+LLDB+LLD, no tests, no benchmarks and no examples, 496 projects total) and Unreal Engine project (UE4.21 Simple Game), for example, show a 15-25% improvement:
In the future, we plan to completely remove the old preprocessor implementation, moving all the functionality to the newer one, as it seems more promising. Besides, we hope to improve a few other editor features by implementing a solution on top of this new preprocessor. So this is hopefully just the beginning!
More C++20 support
C++20 is almost ready to be signed off on by the C++ committee, even though there are significant changes still jumping into the process (for example, Contracts moved out of C++20 during the latest committee meeting). In the ReSharper C++ team, our intent is to keep up with the evolution of the language, which is why we have been working on C++20 compliance for several release cycles already. This time we added support for the following features:
char8_ttype (p0482). C++ is now a step closer to built-in UTF-8 support, and you can use an array of
char8_telements to represent a UTF-8 string. ReSharper C++ now understands and resolves this new type properly:
explicit(p0892). You can now conditionally declare
explicitconstructors (and conversion operators), and ReSharper C++ parses the syntax correctly.
- Pack expansion in lambda init-capture (p0780). The restriction on init-capture is removed and now the following syntax will be correct (and supported by ReSharper C++):
- Default constructible and assignable stateless lambdas (p0624). This is another proposal that fixes the language feature in a natural and consistent way, making lambdas as similar to function objects as possible. It allows stateless lambdas to be default constructible and assignable, and ReSharper C++ gets the corresponding parser fix too:
- C++20 fixes aggregate initialization, for example, prohibiting aggregates with user-defined constructors (p1008). ReSharper C++ catches any situations where constructors are deleted or defaulted and provides a corresponding error message:
This error is necessary to save you from unintended initialization, possible via the aggregate initialization.
constinit(p1143) specifiers are supported in ReSharper C++’s parser.
- C++20 will bring a set of improvements to structured bindings, which are now supported in ReSharper C++, for example, by extending them to be more like variable declarations (p1091):
Another fix supported by ReSharper C++ is a fix for the accessibility issue which allows structured bindings to be accessible members (not just public) (p0969). Funny story: did you know that the proposal was actually born from Timur Doumler’s work on CLion, a stand-alone cross-platform C++ IDE by JetBrains?
Updates to built-in code analysis
The code analysis engine in ReSharper C++ now understands your C++ code in even greater detail. It will help you catch a few new code smells:
- Missing a matched preprocessor directive is detected:
- Situations when an explicitly defaulted special member function is implicitly deleted:
- And, a redundant final function specifier in a final class:
And if you decide to eliminate the C-style cast used in your code with the help of the corresponding inspection, the Use static_cast quick-fix can now be run in bulk mode and as part of Code Cleanup. Similarly, bulk mode is now available for the quick-fixes for two inspections, Local variable may be const and Use auto. You can fix all such aspects at once!
When you look at the completion list, it’s useful to get more information about the completion items suggested right in-place. In ReSharper C++, the summary tooltip can be shown for each item in the completion list to help you with this (controlled by the Show summary checkbox on the Environment | IntelliSense | Completion Appearance page of the ReSharper options). And in v2019.2, it is even easier-to-read and more informative because it has a colorized description of the selected completion item and the documentation for it:
Code hints in ReSharper C++ help you instantly get a deeper understanding of the code in front of you without explicitly calling any other additional actions. They help with the list of parameters and the end of namespace definitions. And in v2019.2, we improved them further!
First of all, have you noticed the hint after the preprocessor directive in the screenshot of the unmatched preprocessor directive code inspection? Scroll up the page and check. ;) This hint will definitely come in handy for any complicated and nested directives structure.
Then, we’ve added hints for function arguments passed by a non-const reference:
And finally, hints in aggregate initialization expressions now show the names of the initialized base classes:
The Go to File member (
Alt+\) action quickly takes you to functions, classes/structs, and their members, matching the given string. Now it also allows you to search directly in a file. As a result of this text search, you’ll get all the places where the search string appears in the same dialog, right after the list of matching members:
Besides, the navigation was improved for default constructors, as you can now navigate to the default constructor called when an object is default initialized in variable declarations and new expressions, and find usages now includes default constructors’ usages in default initialization.
Finally, Go to symbol now hides symbols with qualified names. When an item is selected, Go to symbol jumps to its definition, similar to how Go to declaration does.
Formatter: new settings
A few new formatter options were added, covering various wrapping preferences:
And a few others to control the line indents and alignment:
- Use continuous line indent in function declaration and invocation parentheses.
- Use continuous line indent in initializer lists.
- Align initializer list arguments.
There are two small but valuable tweaks in this area. The first is about multiline comments. If you use single-line syntax in multiline comments, then they are automatically extended. Meanwhile, extending multiline comments now inserts correct indentation when virtual space is enabled:
And second, if you’d like to wrap the selection with braces – just select a block of code and type an opening brace.
Unreal Engine support
We are now putting lots of effort into more sophisticated support of Unreal Engine. The aim is to understand the specific UE4 code better and provide features for making game development with Unreal Engine in ReSharper C++ easier and more productive. We’ll take a more detailed look in a separate post, but for now, here are the highlights:
- Quick documentation popup for reflection specifiers.
- Summary documentation tooltip in reflection macro code completion lists.
- Both the Rename and Change Signature refactorings will also work correctly on RPC. functions, and will correctly rename or update the associated _Validate and _Implementation methods.
- Inspections for missing or incorrectly set reflection macros, including checks for incorrect inheritance, invalid nested declarations and warning that a UPROPERTY or UFUNCTION macro call before the declaration has no effect.
There are of course dozens of bug-fixes in this release, like step filters in case of Visual Studio 2019, better support for CMake projects, initial support for the “Per-Monitor DPI Awareness” mode in Visual Studio 2019, and much more.
That’s it! We recommend that you check out the ReSharper platform updates for v2019.2.
Get the brand new build from our site and evaluate the enhancements completely free for 30 days:
Subscribe to Blog updates
Thanks, we've got you!