Ballerina VSCode Plugin — Language Intelligence
Focus
Today developers heavily depend on the IDEs with plugins to make their life easier with auto-completion, diagnostics, refactoring options and various language intelligence features. In VSCode Ballerina Plugin, all the Language Intelligence capabilities are provided via a Language Server Implementation. Let’s have a look at the available Language Intelligence support as follows,
Semantic and Syntactic Diagnostics
When there are syntax or semantic errors in your code, you’ll be notified with appropriate diagnostics during the development time, as shown below. Detailed description when hovering over the red lines will provide the same compile-time error message to maintain the consistency.
Suggestions and Auto-Completion
You can experience suggestions of keywords, variables, code snippets for various language constructs such as functions, services, iterable constructs and, etc visible for a given scope. You can access the contents of modules available in you ballerina home repo as well as in the distribution. We’ll discuss more on these available completions and suggestions options in my next article in detail.
Go to Definition
Go to definition will allow you to navigate to the definition of a variable, a function, an Object and etc, within the same file, in a separate file in the same module or in a file of a separate module in the same project as well.
Find all References
Will allow you to find all the references of a selected variable, a function, an Object and etc, within the same file, in a separate file in the same module or in a file of a separate module in the same project as well.
Code Actions
There are code actions available allowing you to accomplish various tasks much easier. Based on the diagnostics, current scope where the cursor resides. As an example,
- Add documentation for an entity such as function, service, resource, object, record and etc.
- Add documentation for all the available entities in the current file
- Add missing import
- Create Variable definition
- Create an undefined function
Find more about the available code actions in detail here.
Refactoring options
Refactoring options such as,
- Renaming a variable, function name, and other entities
- Auto import missing imports on completion item selection
- Adding documentation, functions which are undefined, creating variables are supported via the code actions
are supported in the current implementation.
Hover support
Hover support will provide you quick information about a certain entity. For an example, if you hover over a function name you can see function description, parameter information and the return type description. Likewise, hover over an entity name of an Object or Record will provide you with the object/ record’s description as well as the field descriptions.
Signature Help Support
Signature help support will provide you with the information about the function parameters’ descriptions while you are typing. Signature help will automatically trigger when you type the open parenthesis — “(“ as well as the comma — “,”.
Document Symbols
Document symbols will provide you with the list of all the visible symbols including, functions, services, endpoints, and etc in a certain file.
You can trigger the palette via ctrl + shift + O
Workspace Symbols
Workspace symbols will provide you all the symbols visible in the current project. These symbols include the services in multiple modules in the same project, functions, Objects, and etc.
You can trigger the palette via ctrl + T
These are the currently available stable features which have been shipped with the Ballerina VSCode Plugin. I’ll be continuously updating/ editing this post when adding the new features as well as during the alteration. If you have any Issues or feature requests please create a Github Issue here under the Component/LanguageSever label. :)