What’s it all about?
In June 2018 SAP has introduced the new application programming model for SAP Cloud Platform based on Core Data & Services (CDS) as known from S/4HANA and ABAP. While SAP Web IDE provides you with advanced support and tools tailored for the new programming model, the CDS language support is actually independent from concrete development environments. This was made possible by a concept called Language Server Protocol (LSP), introduced by Microsoft in Visual Studio Code but now supported in a wide variety of other IDEs including Atom, Eclipse, Emacs, VI and of course Visual Studio. This enabled us to quickly support the CDS language also in VS Code on top of SAP Web IDE. Since we use VS Code a lot internally for local development we decided to provide our CDS extension also to external customers, provided free of charge under SAP Developer License. It gives you freedom of choice to bring your own tools and develop in whichever environment you are most comfortable with.
What’s in it for me?
Well, a lot! Let’s have a brief look at the most prominent features.
It goes without saying that colorful syntax highlighting greatly improves readability of code.
Code completion is the bread-and-butter when learning new languages because it guides you through the permissible tokens at any source location. Snippets are larger code completions that help you creating typical larger code blocks like Entities in CDS.
The Outline view gives you a high-level overview of the logical hierarchy of a source file so that you can quickly navigate between sections and elements. The Breadcrumb at the top of the source editor shows the path the the currently selected element.
Especially when reusing elements from other reuse modules, you often want to Go to Definition to understand how certain elements were defined.
Likewise, Find References guides you to the places where a certain element is used in your project context.
Mark Occurrences is especially helpful when assessing large amounts of source code. It quickly gives you a semantically correct overview where else a certain symbol is used in your current editor.
Last not least, when your code is syntactically incorrect, you can quickly see errors in Problems and Explorer views, as well as directly in the code.
You may also adjust the behavior of many of the operations in the settings. Restrict the selection with ‘cds’ in the filter input field to get options specific for the CDS language server, or e.g. ‘suggest’ to tweak the code completion behavior.
These are just a few of the features defined by the Language Server Protocol. Further protocol operations include, for instance, Code Actions (like refactor/rename) or Document Formatting (also known as beautify or pretty-print). As soon as our CDS Language Server implementation learns these operations, all LSP-enabled editors can automatically support the corresponding features.
Where can I get it?
Installing this extension for VS Code is rather simple. Just follow these steps
- Go to https://tools.hana.ondemand.com/#cloud-vscodecds
- Download the vsix file via the link on the right side
- Accept the license agreement, if not done already
- Start VS Code
- Install the downloaded vsix file in VS Code using command Install from VSIX… (default is F1 to trigger command input)
- VS Code will ask you to restart once the extension is successfully installed.
The extension will check for updates every time you start VS Code and offer you the choice of installing an available update.
You can trigger the update also manually by executing the command Update CDS Language Support. If a newer version is available, the extension will notify you.
If you already have the latest version the following popup appears.
At the moment, CDS Language Support for VS Code is not yet available on the VS Code Marketplace.
What’s your opinion?
As you have seen, the VS Code extension for CDS brings a number of useful editor features to the local development scenario, including code completion, go to definition, find references, among others. This neatly demonstrates how the Language Server Protocol concept allows domain tool vendors to quickly serve more than one IDE.
Your feedback is our chance to make this extension better suited to your needs. If you have an S-user, please use standard SAP support and open an incident on component BC-XS-CDX. If not, feel free to drop a comment on this blog.
- Is this useful for you?
- What is missing?
- Are there other IDEs in which you would like to see CDS language support?
Any issues, feedback, or feature requests are highly appreciated; thanks in advance.
About the Authors
Writing good software requires team work. Blogging sometimes as well …
Christoph Pohl is product owner and architect for development tools on SAP Cloud Platform and SAP HANA.
Jörg Mann is a developer for development tools on SAP Cloud Platform and SAP HANA.
René Jeglinsky is a technical writer committed to enable and support developers on SAP Cloud Platform and XS Advanced.