RAD Studio 10.4.2 was planned as a feature-focused followup to the quality-focused release of 10.4.1. However, besides delivering some major features we also fixed more issues in 10.4.2 than in the previous release!
This applies as much to Code Insight, or DelphiLSP, as to other parts of Delphi 10.4.2. Let’s have a look at what’s new. First, the features…
Error Insight — now Error, Warning and Hint Insight
For many years you’ve been able to see code errors detected ahead of time before you compile, shown via a red zigzag underline in the code editor (a ‘red squiggly’.) One of the great improvements we made with the introduction of DelphiLSP in 10.4 was to make sure these indications were always correct: there is a 1:1 correlation between the marker in the code editor and the compiler errors you’d see if you compiled the code, and all errors shown in the editor and Structure pane are correct.
In 10.4.2 we’ve extended this so you can see warnings and hints in the code editor too. Warnings and hints provide valuable information about your code, issues that won’t prevent compilation but may prevent your app running the way you want. Showing these live in the editor as you type gives you much faster feedback and turnaround to fix issues in your code. And for those who prefer to compile without any warnings or hints – a great goal – seeing them inline will be invaluable.
In 10.4.2, we didn’t enable this by default, so that the code editor would not be covered in multiple colours for those whose code has many warnings and hints. After initial customer feedback we may turn it on by default in 10.5! But for this release, you can turn it on in the IDE Options > User Interface > Editor > Language page, ‘Error Insight’ tab, ‘Error Insight Display’ combo box:
This tab lets you choose between seeing: errors only; errors and warnings; or errors, warnings and hints. We recommend you turn on showing all three.
Editor Rendering and Other Naming Problems
‘Error Insight’ is a great name – except now it could really be called Error, Warning and Hint Insight. (No, we haven’t changed how we refer to the feature.)
Another great name was ‘red squigglies’… except that’s now ‘red, amber and blue squigglies.’ But that’s not all. Now they may not even be squiggles at all! The Department Of Naming Things Real Good here at Embarcadero is quite unhappy with all the new features we’re providing you with this release. Look at this:
In 10.4.2, we want to ensure the code editor markers are clear and easy to see, plus we know our customers often like to customise the IDE to their own preferences. For those reasons we have four different ways to render the underline: the traditional zigzag, but also a curved wave (like other IDEs), a line of dots (my personal favourite, since I think it’s understated and elegant but still clear, and insist I am not overthinking an analysis of a few pixels at all), and a solid underbar. We hope you’ll enjoy configuring this, and especially if you have a high-resolution monitor or eyesight issues that you’ll find the marker style- that suits your needs.
We also show an icon in the editor gutter. This makes it easy to spot errors, warnings or hints when scrolling fast. Like the other changes here, this can be controlled or completely turned off if you wish.
Insight in the Editor Status Bar and Tooltips
If you have enough horizontal room, the status bar at the bottom of the code editor will now give you an overview of the number of errors, warnings and hints in the current unit.
If you mouse over an error (or warning or hint) we’ve also tweaked how this is displayed.
LSP Server Activity
Have you ever wondered what the Code Insight engine is doing, what it’s processing, and when it might be ready to give results? In 10.4.2, a small bar at the bottom of the Projects view lists the LSP server’s activity.
In March 2015, over a year before I joined Embarcadero and at a time when I had no idea I might work here one day, let alone be responsible for this part of Delphi, I entered the Quality Portal feature request RSP-10217. It’s a popular QP report with 117 votes and 41 watchers. The request was to extend Ctrl+Click, which navigates to the declaration of a symbol, to allow you to Ctrl+Click on the ‘inherited’ keyword.
I am very happy to say that in 10.4.2 this feature is implemented. You can Ctrl+Click on the ‘inherited’ keyword and, if qualified with a method such as ‘inherited Create’, also Ctrl+Click on the method name, which will also be understood as navigating to that inherited method.
Why is this such a useful addition? Navigating to where something is defined is very helpful for learning about it and finding out what it does, and it’s why Ctrl+Click in general is useful. But the functionality used to work only on symbol names. When you invoke an inherited method, or in other words invoke the implementation in an ancestor class, that too is something you want to be able to navigate to to find out what it does: in fact this is highly useful because moving around within an inheritance hierarchy is important for understanding your object-oriented code. There used to be no way to find the inherited method. Now there is!
In a final touch, code completing after the ‘inherited’ keyword will now only list methods from ancestor classes.
… and Quality!
All the above are new features, sometimes really neat new features. But as I mentioned at the start of this post, 10.4.2 was a big quality release as well. For DelphiLSP, sometimes this has meant fixing bugs. But it’s also meant revising features – tweaking, adjusting, ensuring they work in less common scenarios, changing behaviour based on feedback, and more. Here’s a list of just some of the fixes, tweaks, changes, adjustments and polish we’ve added to DelphiLSP this release.
- Code completion functions in IFDEF blocks for inbuilt macros which the compiler has defined in some situations, such as UNICODE or MSWINDOWS
- Many improvements to which units are showing when code completing in the uses clause (it will also show .pas and .dcu files in the search and project paths; you can disable DCUs if you need in the Project Options on a per-platform level); plus a unit ‘stem’ (like ‘Winapi’ in ‘Winapi.Windows’) is also listed; it even indicates to you when a unit you’re completing is already in the uses clause!
- Many improvements to overload resolution, which will be visible when Ctrl+Click-ing an overloaded method, or displaying Parameter Insight when there are multiple overloads for a method
- Ctrl+Click-ing on a method implementation will go to its declaration, and vice versa. Ctrl+Click navigation also works for calls to instantiated generic methods, in many cases on symbols in incorrect (uncompilable) code; and on the Exit inbuilt’s argument; plus improvements using it in a uses clause
- Many improvements for generics, including completing in generic classes showing strict private/protected symbols; find declaration finding fields and properties in generic types; finding generic methods in another unit; and more
- Many improvements completing and navigating to: attributes; scoped enums (they will display and complete the enumeration with their scope); listing resource strings; navigating to properties and property getter/setters; and more
- Documentation display improvements, including showing XMLDoc during parameter completion
- Many performance tweaks. Even the executable is a smaller size now.
And that’s not it – there are many, many more tweaks, changes, and quality fixes throughout all of DelphiLSP. The above is perhaps a quarter of the list, and you’ll notice many dot points cover multiple items. Each one has other items – there are more tweaks to handling .pas and .dcu lookup, for example, which aren’t mentioned, or more tweaks around parameter completion, or tweaks around how the IDE inserts text, or…
The impression I’d like to communicate is just how much has been revised and improved in 10.4.2. Many of the above items you might not notice: they are subtle improvements. The general sense is that code completion and related features just work when you expect them to, as you expect them to.
Not only does Code Insight in Delphi and RAD Studio 10.4.2 come with some really useful new features, including commonly requested ones — warnings and hints in the editor! Ctrl+click on ‘inherited’! See what the LSP server is doing! — the entire feature has many quality revisions. The feedback we’ve got so far has been very favourable, and we highly recommend you install 10.4.2 as soon as you can.