Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Launch (Develop) a JDT LS instance with Bazel extension

Pavel Mitrafanau edited this page May 9, 2021 · 2 revisions

Prerequisites:

  • JDK 11

Launch/Develop the project in Eclipse

  1. Launch an Eclipse instance
  2. Create and launch a clean workspace
  3. Open the repository by clicking File -> Open Projects from File System...
  4. In the Import view leave selected the following two and click Finish: bazel-ls-eclipse, bazel-ls-eclipse/com.salesforce.b2eclipse.jdt.ls
  5. Once the project is opened, you will see a lot of errors in the Problems view. It happens because we are on a default target platform. Locate the target platform’s file in the Explorer, open it and click Set as Active Target Platform.
  6. Once the target platform is set, there should be no errors. Next step - starting JDT LS instance. Locate the launch file in the Explorer and run it.

Problems you can face:

  1. Problems view continues to show some errors after the platform is set.
    • Try to rebuild the project (Project -> Clean...)
    • Try to reload the platform (same steps as making it active)
    • Try to restart the Eclipse
    • Make sure the proper Java runtime is set (JDK 11)
  2. Nothing happens after the launch.
    • Open the Console view manually and make sure there are no errors and Terminate button is enabled. If not, try to run the server again.

Launch/Develop the project in VS Code

If you don't use VS Code for PDE development (specifically for bazel-ls-eclipse) and just want to test how it works with already started JDT LS instance (e.g. through Eclipse) then proceed to the next section.

  1. Open the project directory from a VS Code instance;

  2. Install all the recommended extensions. You can do it in either ways:

    • Via popup prompt when you open the project. Click “Install All” and wait until the process is finished;
    • Manually. First open the Extensions tab and apply the @recommended filter. Then install the extensions one by one or all at once.

    The required set of extensions includes:

  3. Once the plugins are installed, wait until the target platform is loaded. Usually this process is started automatically. You will see a spinning icon in the status bar. More details can be found by clicking on the icon. If the process wasn’t started, locate the target platform’s file in the Explorer, right click on it and choose Reload Target Platform;

  4. Launch the JDT LS with Bazel support. Locate the launch file in the Explorer, right click on it and choose Debug PDE application.

Problems you can face:

  1. If you run the launch configuration in an Eclipse instance, it will override (reformat) some of its keys. E.g. selected_target_plugins will become selected_target_bundles with a slightly different format. In that case you won't be able to run the project in VS Code getting ClassNotFoundException. You will have to reset the changes to the launch configuration file to make it work again in VS Code.