Skip to content
View as Markdown

LspServer

Language Server Protocol (LSP) interface for Sandbox code intelligence operations.

This class wraps Toolbox LspApi operations and maps Toolbox API errors to Daytona SDK exceptions via ExceptionMapper. It supports starting/stopping language servers, notifying document open/close events, and retrieving completions and symbols.

Constructors

new LspServer()

public LspServer(LspApi lspApi)

Creates an LSP server wrapper using the Toolbox LSP API client.

Parameters:

  • lspApi LspApi - Toolbox LSP API client

Methods

start()

public void start(String languageId, String pathToProject)

Starts a language server for the specified language and project root.

This must be called before document notifications or code intelligence requests.

Parameters:

  • languageId String - language identifier (for example "python", "typescript")
  • pathToProject String - absolute or relative project root path inside the sandbox

stop()

public void stop(String languageId, String pathToProject)

Stops a language server for the specified language and project root.

Parameters:

  • languageId String - language identifier
  • pathToProject String - absolute or relative project root path inside the sandbox

didOpen()

public void didOpen(String languageId, String pathToProject, String uri)

Notifies the language server that a document has been opened.

Use this before requesting completions or symbols for a document to ensure the language server tracks it.

Parameters:

  • languageId String - language identifier
  • pathToProject String - absolute or relative project root path inside the sandbox
  • uri String - document URI (typically file://...)

didClose()

public void didClose(String languageId, String pathToProject, String uri)

Notifies the language server that a document has been closed.

Parameters:

  • languageId String - language identifier
  • pathToProject String - absolute or relative project root path inside the sandbox
  • uri String - document URI (typically file://...)

completions()

public CompletionList completions(String languageId, String pathToProject, String uri, int line, int character)

Retrieves completion candidates at a zero-based position in a document.

Parameters:

  • languageId String - language identifier
  • pathToProject String - absolute or relative project root path inside the sandbox
  • uri String - document URI (typically file://...)
  • line int - zero-based line number
  • character int - zero-based character offset on the line

Returns:

  • CompletionList - completion list returned by the language server

documentSymbols()

public List<LspSymbol> documentSymbols(String languageId, String pathToProject, String uri)

Returns all symbols defined in the specified document.

Parameters:

  • languageId String - language identifier
  • pathToProject String - absolute or relative project root path inside the sandbox
  • uri String - document URI (typically file://...)

Returns:

  • List\<LspSymbol\> - list of document symbols

workspaceSymbols()

public List<LspSymbol> workspaceSymbols(String query, String languageId, String pathToProject)

Searches workspace-wide symbols matching the provided query.

Parameters:

  • query String - symbol query text
  • languageId String - language identifier
  • pathToProject String - absolute or relative project root path inside the sandbox

Returns:

  • List\<LspSymbol\> - list of matching workspace symbols