VS Code: Go To Definition & Signature Help
4D v19 R6 brought the support of external source code editors (e.g., Visual Studio Code), allowing them to handle 4D code and provide them with standard functionalities such as syntax highlighting using the Visual Studio Code extension.
4Dv19 R7 brings two new capabilities: Go To Definition and Signature Help.
Setting up code syntax highlighting using the Visual Studio Code extension
We recently talked about our new Visual Studio Code extension allowing VS Code to communicate with 4D for code management. The syntax highlighting was the first Language Server Protocol feature in 4D v19 R6. Let’s see how to customize your source code rendering.
A brand new Visual Studio Code extension at your disposal
4D now supports the Language Server Protocol to allow external source code editors to handle 4D code and provide them with standard functionalities such as syntax highlighting, syntax help, go to definition, or type ahead. Let’s see how to take advantage of it in Visual Studio Code.
New Tips & Tricks for your 4D Applications
by Add Komoncharoensiri, Director of Technical Services at 4D Inc
As you know, 4D Knowledge Base is a library of information about the 4D technology where weekly tech tips and monthly technotes are actively published. If you missed the last tips on the KB, that’s fine; here is a compilation from the past few weeks.
This blog post covers 12 tips:
Access your component classes from your host project
Components can now publish classes! And even better, if your application is still in binary mode, you can now benefit from classes and object-oriented development by using a component (in project mode) to create your own classes and use them from your (binary mode based) application.
New possibilities to customize the code editor
When it comes to customizing the code editor, everyone thinks of the font and colors of the code. But it is also possible to customize the code editor window and some interactions with the code. Everyone has their own preferences and ways of working.
Moreover, the most essential part of a code editor is the writing code area. With 4D v19 R4, we have redesigned the editor to highlight your code and give it as much space as possible.
This is precisely why 4D v19 R4 enables you to show or hide the ten clipboards. If you don’t use all ten clipboards, you can lighten the toolbar with the “Show clipboard” preference.
Saving project source code without tokens
Commands, constants, tables and fields are stored with their tokens in the project source code files (4dm files). This allows 4D to rename them automatically. But sometimes, you would like these source code files to be stored without tokens for a better readability with a version control system or an external code editor, or for better code sharing between projects. Let’s see how to make 4D store source code without these tokens.
Tag your comments, a feature by developers for developers
Comments are essential in a developer’s life. When we work on a new feature, we often add comments that are reminders. For example:
- to validate a part of code with a colleague,
- to refactor a function,
- to fix code that is slowing down the performance,
- to split a method or a class into sections,
- to prepare the skeleton of a class and add a todo comment inside each function.
Even if you write some straightforward code, try reading it months or years later. Will it still seem simple, or would you wish you’d added comments?
4D v19 R4 takes comments to a whole new level with comment tags that enables you to better organize your comments.
Improved productivity with Object check syntax
Auto-completion for classes is available since 4D v18 R4. This feature simplifies code writing and limits errors in function names, for example. But it doesn’t avoid them entirely; it’s easy to reverse two letters or to forget a capital letter, and then have to spend time looking for why your code doesn’t work.
So what better way than to ask 4D to check if the classes or functions already exist?
Starting with 4D v19 R4, a warning is displayed in the code editor if you call a function that does not exist.
Quickly jump to different functions of a class
Classes were introduced with 4D v18 R3. They allow you to organize your business logic and separate it from the UI part more quickly.
Classes are composed of several functions of varying lengths, so it’s not always easy to find the function you want to modify, or to move from one function to another. You can use the explorer, which displays classes and functions, but when you’re coding in the editor window, you don’t want to waste time changing windows.
With 4D v19 R4, the list of functions in your class is displayed in the code editor toolbar, allowing you to easily jump to a specific function.
Contact us
Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!
* Your privacy is very important to us. Please click here to view our Policy