|
| 1 | +# Language Server and Implementation |
| 2 | +This repository contains the source code for the example implementation of a language server referenced in the book \title of the book\. |
| 3 | +This language server implementation is associated with an example client implementation as well. The referenced client implementation is done for the [VS Code](https://code.visualstudio.com/) client. |
| 4 | + |
| 5 | +## About the Book |
| 6 | +### Authors |
| 7 | +- Nadeeshaan Gunasinghe - Technical Lead, WSO2 Inc (Pvt) Ltd. |
| 8 | +**Contact:** |
| 9 | +Email - nadeeshaangunasinghe@gmail.com |
| 10 | +LinkedIn - https://www.linkedin.com/in/nadeeshaan/ |
| 11 | +Github: https://github.com/nadeeshaan |
| 12 | + |
| 13 | +- Nipuna Marcus - Technical Lead, WSO2 Inc (Pvt) Ltd |
| 14 | +**Contact:** |
| 15 | +Email - nipunamarcus2@gmail.com |
| 16 | +LinkedIn - linkedin.com/in/nipuna-marcus-0b721143 |
| 17 | +Github: https://github.com/NipunaMarcus |
| 18 | + |
| 19 | +### Introduction |
| 20 | + |
| 21 | +## Technologies |
| 22 | +- The client implementation is done with [TypeScript](https://www.typescriptlang.org/). |
| 23 | +- Language Server implementation is done with Java and Java-11 would be preffered |
| 24 | +- Language Server implementation is done for the [Ballerina](https://ballerina.io/) programming language. The default implementation is done for [Ballerina Swan Lake Beta 3](https://ballerina.io/downloads/). You can read more and learn about Ballerina programming language in the [official doccumentation](https://ballerina.io/learn/) |
| 25 | +- [Gradle](https://gradle.org/) is used as the build tool for the server component |
| 26 | +- [Node JS](https://nodejs.org/en/) [v12.20.0 at least] and [NPM](https://www.npmjs.com/) [6.14.x at least] is used as for the client component |
| 27 | + |
| 28 | +## How to build |
| 29 | +This repository contains two components as the client and the server implementation. You have to build these components individually. |
| 30 | + |
| 31 | +##### Step 1 |
| 32 | +Clone the repo |
| 33 | + |
| 34 | +##### Step 2 |
| 35 | +**Build the Server Implementation** |
| 36 | +Go to the repo root and execute the following command to build the server implementation. |
| 37 | +`./gradlew clean build` |
| 38 | +The server implementation will copy the particular uber-jar artifact to `REPO_ROOT/client` directory. |
| 39 | + |
| 40 | +**Build the Client Implementation** |
| 41 | +Go to the `REPO_ROOT/client/ls-client` directory and execute the following command to install the Dependencies |
| 42 | +`npm install` |
| 43 | +Now execute the following command to build the client and generate the `.vsix` VS Code plugin artifact |
| 44 | +`npm run build` |
| 45 | + |
| 46 | +## Using the Extension and the Language Server |
| 47 | +### Prerequisites |
| 48 | +- Install [Ballerina SwanLake Beta3](https://ballerina.io/downloads/swan-lake-archived/) |
| 49 | +- Install [Java](https://www.oracle.com/java/technologies/downloads/) |
| 50 | +- Install [VS Code](https://code.visualstudio.com/Download) |
| 51 | + |
| 52 | +### Usage |
| 53 | +- Install the built `.vsix` extension artifact. The plugin itself will start the language server once a `.bal` file is opened |
| 54 | +- Open a Ballerina source file from the VSCode editor. |
| 55 | +- Explore the language features such as auto-completions, find references, and etc |
| 56 | + |
| 57 | +## Debugging the Implementation |
| 58 | +### Enable trace logs for the server implementation |
| 59 | +- You can explore the trace logs for the messages passed between the language server and the client by adding the following configuration option in the user settings. |
| 60 | +`"ballerina-lang-client.trace.server": "verbose"` |
| 61 | + |
| 62 | +### Debugging the Language Server |
| 63 | +##### Step 1 |
| 64 | +Open the `REPO_ROOT/client/ls-client/` directory in VS Code. |
| 65 | + |
| 66 | +##### Step 2 |
| 67 | +Go to `REPO_ROOT/client/ls-client/.vscode/launch.json` file and set the `LSDEBUG` config value to `true` |
| 68 | + |
| 69 | +##### Step 3 |
| 70 | +Run the extension as shown in the figure |
0 commit comments