Apex Language Server

The Apex Language Server is an IDE-agnostic way for tools to access code-editing capabilities such as code completion, go to definition, find all usage, and refactoring. The Apex Language Server is a part of the Salesforce Extension Pack. It provides a powerful way for Salesforce Extensions for VS Code and Code Builder to implement an Apex analyzer that’s also accessible to other IDEs.

The Apex Language Server is an implementation of the Language Server Protocol 3.0 specification. The Language Server Protocol allows a tool (in this case, VS Code) to communicate with a language smartness provider (the server). We built the Apex Language Server using this common specification to enable our tooling partners to improve the smartness of their tools.

For more information, watch the video of our Dreamforce ’17 presentation, Building Powerful Tooling For All IDEs Through Language Servers.

Dreamforce '17 Presentation

If you are a developer looking to integrate with the Apex Language Server, use the apex-jorje-lsp.jar file.

See the languageServer.ts file for an example of initializing and communicating with the Apex Language Server.

Hover over {} in the status bar to view the current status of the Apex Language Server. To always have visibility into the status, pin the status message. The Apex Language Server status is now persistantly visible in the status bar until it is unpinned.

Apex Language Server Status

To set the Apex Language Server restart behavior, from Settings:

  1. Select File > Preferences > Settings (Windows or Linux) or Code > Settings > Settings (macOS).
  2. Under Salesforce Apex Configuration, select Restart Behavior, then select the restart behavior from the dropdown:
SettingDescription
promptGive the user an option to choose between a simple restart and a reset.
restartPerform a simple restart of the Apex Language Server without resetting the database.
resetPerform a clean restart of the Apex Language Server and reset the database.

To restart the Apex Language Server, hover over {} in the status bar. Make sure an Apex class or trigger is open in Editor View. You can also run the SFDX: Restart Apex Language Server command from the command palette. The restart option available from the status bar reflects your restart behavior setting. Simple and clean reset options are available from the command palette.

To clear the Apex Language Server's indexing, delete the PROJECT_DIR/.sfdx/tools/<Salesforce Release> directory and restart VS Code.