The Ballerina Compiler Toolkit for Visual Studio Code
This toolkit introduces the capability to investigate and delve in to the syntax trees of Ballerina code and to retrieve the syntax API calls that are required to create a particular piece of Ballerina code. However, this extension only provides additional capabilities to support Ballerina developers. In order to experience language intelligence and other core features, install the Ballerina extension. Checkout the Visual Studio Marketplace for further details.
Quick Start
Setting up the Prerequisites
Before getting started, make sure you have installed the Visual Studio Code editor.
Installing the Ballerina Compiler Toolkit Extension
Follow the steps below to install the Ballerina Compiler Toolkit extension.
- Download and install Ballerina.
- Install the Ballerina Extension.
Tip: Alternatively, click
Ctrl + P
or (Cmd + P
in macOS) to launch the VS Code Quick Open screen, and enterext install WSO2.ballerina
to install the Ballerina VS Code Extension.
- Install the Ballerina Compiler Toolkit Extension from the VSCode marketplace.
Tip: Similarly, you can launch the VS Code Quick Open screen, and enter
ext install ballerina.ballerinacompilertoolkit
to install the Compiler Toolkit Extension.
- Open a Ballerina
.bal
file to activate the extension.
Capabilities
1. Ballerina Syntax Tree Visualizer
The Ballerina Compiler Toolkit includes the capabilities to generate the syntax tree for a given Ballerina source code, using which developers can retrieve a simplified representation of their code blocks for convenient analysis.
The capabilities of the visualizer are in 3 main forms.
- Generate the
complete syntax tree
of a Ballerina source file - Generate the
subtree of the syntax tree
for a particular block of code Locate a code segment
on the complete syntax tree
Representations
The syntax tree visualizer has two types of representations: graphical
and dropdown
.
Basic Usage
The command for the full syntax tree
retrieval can be found on the Command Palette.
Tip: The command palette can be viewed via
Ctrl + Shift + P
or (Cmd + Shift + P
in macOS).
The sub syntax tree retrieval
and locate code
options can be found as Code Actions.
Features
The syntax trees rendered through the visualizer have muliple features available in both the graphical and dropdown representations.
node details
* View
syntax diagnostics
* Track
Locate
the tree node on the text editor
*
Switch to full tree mode
from sub syntax trees and locate trees
*
2. Syntax API Quoter
The Ballerina syntax API quoter lists the API calls required to create the syntax tree for a given Ballerina source code. Hence, its capabilities can be leveraged by any developer who uses the Ballerina syntax API to create source code elements.
Basic Usage
The command for the syntax API quoter can be found on the Command Palette as well. Executing this command will copy the list of syntax API calls that are required by the Ballerina source code, to the clipboard.
Ask for Help
Create Github issues to reach out to us.