As usual, a new release, new VS Code extension features for developers who want to view and edit code with this free editor.
4D v20 brings new capabilities to the Visual Studio Code editor through the 4D-Analyzer extension: Say hello to Document Syntax Checking, which will help the developer to type fewer mistakes, Code Folding and Indentation for a better look, and tool4d to allow faster LSP server starting.
Document syntax checking
When writing code, syntax checking is a way to help developers make their code safer.
For example, typing an “If” statement is a syntax error if the corresponding “End if” statement is missing. The developer often writes the same thing for parenthesis and a long list of typos.
As it has been available in the 4D code editor for a long time, you can now check the syntax errors in the VS Code editor.
Best part? Nothing to do from your end; all is automatic.
In VS Code, the syntax errors are displayed inline: the part of the code generating the error is underlined. And when hovering it, a tooltip appears, showing the same error explanation as in 4D:
As some developers don’t like to see their code underlined by the editor, we did like other VS Code extension by making this capability optional. You can activate or deactivate the syntax checking in the extension settings:
Code folding and indentation
Another useful capacity for developers is to contract and expand parts of code. In VS Code, a bracket is displayed before each foldable part of code when hovering over the left margin. For example, keyword blocks and class functions are foldable parts of code.
And when typing code inside a foldable code block, the cursor is automatically indented so that the code looks better for reading without any action.
tool4d application
4D v20 brings a new application called tool4d. As explained in this blog post, this application is a subset of 4D and is dedicated to script execution through Command Line Interface. But it also provides the LSP server that communicates with the VS Code extension! So you can now define tool4d in the server path of your 4D-Analyzer extension settings:
As tool4d is very small and doesn’t load many components, it is significantly faster to load! And on macOS, setting tool4d as an LSP server will avoid concurrent access to your 4D application.
Hope that all these new features help you use the 4D language in the VS Code editor!
We constantly strive to provide our users with the best possible experience, and we encourage you to share your thoughts and feedback on the 4D forum. Your feedback helps us better understand your needs and continuously improve our products and services.