Skip to content

Latest commit

 

History

History
96 lines (66 loc) · 4.67 KB

DEVELOPING.md

File metadata and controls

96 lines (66 loc) · 4.67 KB

Developing Liberty Tools for Visual Studio Code

Note: Starting with the 0.1.12 early release, Java 17 is required to run Liberty Tools for Visual Studio Code.

Building Liberty Tools for Visual Studio Code

Ensure you have Node.js and npm installed.

  1. Fork this repository

  2. Clone your fork of this repository: git clone https://github.com/<your GitHub id>/liberty-tools-vscode

  3. Change to the liberty-tools-vscode directory: cd liberty-tools-vscode

  4. Run npm install

  5. Run npm run build

  6. Run npm run compile

  7. Run the extension in Debug and Run mode by selecting Run Extension or pressing F5 in Visual Studio Code.

    Alternatively, build a .vsix file and install the extension to Visual Studio Code with the command palette or Extensions activity bar.

    • Run vsce package to generate the liberty-tools-vscode-xxx.vsix file
    • Install the extension with the command palette:
      • Select Extensions: Install from VSIX... and choose the generated liberty-tools-vscode-xxx.vsix file
    • Install the extension with the Extensions activity bar:
      • Navigate to the Extensions activity bar, or use the shortcut Ctrl-Shift-X
      • Click the ... dropdown menu and select Install from VSIX and choose the generated liberty-tools-vscode-xxx.vsix file

Step 5 downloads the JARs for Liberty Config Language Server and Eclipse LSP4Jakarta that are consumed by the VS Code client. If you would like a different version of the language servers other than what is available to download, the following instructions explain how to build these JARs locally.

Language Servers

Build Liberty Config Language Server locally

  1. Run git clone https://github.com/OpenLiberty/liberty-language-server.git Make sure the cloned repo is in the same parent dir as liberty-tools-vscode
  2. Run npm run buildLcls
  3. Run steps 6 and 7 above

For more information on building Liberty Config Language Server, see the project documentation on GitHub. Note that there are prerequsites to building this project locally.

Build Eclipse LSP4Jakarta locally

  1. Run git clone https://github.com/eclipse/lsp4jakarta.git Make sure the cloned repo is in the same parent dir as liberty-tools-vscode
  2. Run npm run buildJakarta
  3. Run steps 6 and 7 above

For more information on building Eclipse LSP4Jakarta, see the project documentation on GitHub. Note that there are prerequisites to building this project locally.

Debugging Language Servers

When running the extension with locally built language servers, a debugger can be attached to the language server process. The debug ports are as follows:

  • Liberty-LemminX: 1054
  • Liberty Language Server: 8002
  • Jakarta LS: 8003

With the liberty-language-server project opened in VSCode, run Debug attach liberty-ls or Debug attach liberty-lemminx to attach the respective debugger to the running extension.

Localization

package.json

This follows Visual Studio Code extension standard: add localized strings in package.nls.{locale}.json. The default nls message file is package.nls.json.

Source code

  1. Add new messages in locales/{locale}.json file. If message has parameters, use curly brackets to enclose them: {0}, {1}...

  2. Add the following import statement in your source code:

    import { localize } from "../util/i18nUtil";
  3. Call method localize to return localized message.

    Example without parameters:

    const message = localize("my.message.key");

    Example with parameters:

    const message = localize("my.message.key.with.params", param1, param2);