Class EmbeddedApexLsBridge

java.lang.Object
io.github.apexdevtools.apexls.mcp.bridge.EmbeddedApexLsBridge
All Implemented Interfaces:
ApexLsBridge, AutoCloseable

public class EmbeddedApexLsBridge extends Object implements ApexLsBridge
Embedded bridge implementation that accesses apex-ls core functionality directly within the same JVM process.

This bridge uses the OrgAPI interface directly from the apex-ls JAR on the classpath, converting Scala Futures to Java CompletableFutures and results to JSON strings for consumption by the Java 17 MCP tools.

OrgAPI instances are cached per workspace to avoid expensive open() calls.

  • Constructor Details

    • EmbeddedApexLsBridge

      public EmbeddedApexLsBridge(MCPServerConfig config)
  • Method Details

    • initialize

      public void initialize() throws Exception
      Description copied from interface: ApexLsBridge
      Initialize the bridge and establish connection to apex-ls core.
      Specified by:
      initialize in interface ApexLsBridge
      Throws:
      Exception - if bridge initialization fails
    • isReady

      public boolean isReady()
      Description copied from interface: ApexLsBridge
      Check if the bridge is ready for operations.
      Specified by:
      isReady in interface ApexLsBridge
      Returns:
      true if bridge is connected and ready
    • getIssues

      public CompletableFuture<String> getIssues(String workspaceDirectory, boolean includeWarnings, int maxIssuesPerFile)
      Description copied from interface: ApexLsBridge
      Get static analysis issues for a workspace.
      Specified by:
      getIssues in interface ApexLsBridge
      Parameters:
      workspaceDirectory - path to workspace
      includeWarnings - include warning-level issues
      maxIssuesPerFile - maximum number of issues to return per file
      Returns:
      future containing issues in JSON format
    • findUsages

      public CompletableFuture<String> findUsages(String workspaceDirectory, String filePath, int line, int offset)
      Description copied from interface: ApexLsBridge
      Find usages of an identifier at a specific position.
      Specified by:
      findUsages in interface ApexLsBridge
      Parameters:
      workspaceDirectory - path to workspace
      filePath - path to file
      line - line number (0-based)
      offset - character offset within line
      Returns:
      future containing usages in JSON format
    • getDefinition

      public CompletableFuture<String> getDefinition(String workspaceDirectory, String filePath, int line, int offset)
      Description copied from interface: ApexLsBridge
      Get definition location for an identifier at a specific position.
      Specified by:
      getDefinition in interface ApexLsBridge
      Parameters:
      workspaceDirectory - path to workspace
      filePath - path to file
      line - line number (0-based)
      offset - character offset within line
      Returns:
      future containing definition location in JSON format
    • getWorkspaceInfo

      public CompletableFuture<String> getWorkspaceInfo(String workspaceDirectory)
      Description copied from interface: ApexLsBridge
      Get workspace information and metadata.
      Specified by:
      getWorkspaceInfo in interface ApexLsBridge
      Parameters:
      workspaceDirectory - path to workspace
      Returns:
      future containing workspace info in JSON format
    • getVersion

      public CompletableFuture<String> getVersion()
      Description copied from interface: ApexLsBridge
      Get version information from apex-ls core.
      Specified by:
      getVersion in interface ApexLsBridge
      Returns:
      future containing version string
    • getTestClassItemsChanged

      public CompletableFuture<String> getTestClassItemsChanged(String workspaceDirectory, String[] changedPaths)
      Description copied from interface: ApexLsBridge
      Find test classes that should be run based on changes to specific source files.
      Specified by:
      getTestClassItemsChanged in interface ApexLsBridge
      Parameters:
      workspaceDirectory - path to workspace
      changedPaths - array of file paths that have been changed
      Returns:
      future containing impacted test classes in JSON format
    • close

      public void close() throws Exception
      Description copied from interface: ApexLsBridge
      Shutdown the bridge and release resources.
      Specified by:
      close in interface ApexLsBridge
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception