Class SourceReferenceRegistry

java.lang.Object
io.quarkus.qute.debug.agent.source.SourceReferenceRegistry

public class SourceReferenceRegistry extends Object
Registry responsible for managing SourceResponse objects used by the Debug Adapter Protocol (DAP) to serve source content for Qute templates.

Each source reference corresponds to a unique integer ID associated with a specific URI. This allows the DAP client to request the source content of a template (e.g. a file embedded inside a JAR) by reference rather than by path.

Usage example:


 int ref = registry.registerSourceReference(uri);
 SourceResponse src = registry.getSourceReference(ref);
 
  • Constructor Details

    • SourceReferenceRegistry

      public SourceReferenceRegistry()
  • Method Details

    • getSourceReference

      public org.eclipse.lsp4j.debug.SourceResponse getSourceReference(int sourceReference)
      Returns the SourceResponse associated with the given source reference ID.
      Parameters:
      sourceReference - the ID assigned to the source reference
      Returns:
      the corresponding SourceResponse, or null if not found
    • registerSourceReference

      public int registerSourceReference(URI uri)
      Registers a new SourceResponse for the given URI and assigns it a unique source reference ID.

      This method reads the template content directly from the JAR or file specified by the URI, stores it in memory, and returns the assigned ID.

      Parameters:
      uri - the URI of the template (typically a jar:file:...!/... URI)
      Returns:
      a unique source reference ID
    • readFromJarUri

      public static String readFromJarUri(URI uri)
      Reads the content of the resource identified by the given URI.

      This method is primarily intended for reading files stored inside JARs (using jar:file:...!/... URIs), but also works for standard file URIs.

      Parameters:
      uri - the resource URI
      Returns:
      the content of the resource as a UTF-8 string, or an empty string if an error occurs
    • reset

      public void reset()
      Clears all registered source references.

      Typically called when restarting or detaching a debugging session.