Ballerina Language Server — Demystifying Goto Definition

Nadeeshaan Gunasinghe
Ballerina Swan Lake Tech Blog
4 min readDec 31, 2019

--

Source: https://paperpull.com/high-definition-wallpaper-of-a-ballerina/

Note: This article is based from the BallerinaLang v1.1.* onwards

Introduction

Currently, Ballerina Language Server implements LSP v3.14. With the latest Ballerina release v1.1.0 onwards, users will be able to use the Goto Definition feature to find the definition of a certain symbol reference.

In this article, I’m going to take you through the design and the implementation of Goto Definition feature in the Ballerina Language Server.

Activity Diagram

There are three main actors involved as shown in the above Activity Diagram. Each of these actors works as a phase in the process of finding the definition of a given token or in this case if we state precisely the definition of a variable reference at a certain cursor position.

Implementation

Text Document Service

This is the entry point of the definition request sent from the Language Client. Below is the sample of the current implementation

--

--

Nadeeshaan Gunasinghe
Ballerina Swan Lake Tech Blog

Autor, Technical Lead at WSO2, Microservices Enthusiast, Full-stack Developer, Hardcore Cricket Fan, Sci-fi Addict ;)