java.lang.Object
io.quarkus.qute.debug.agent.DebuggeeAgent
- All Implemented Interfaces:
JavaSourceResolver,Debugger
The
DebuggeeAgent manages the debugging process for Qute templates.
It acts as the core component on the debuggee side:
- Tracks and manages Qute
Engineinstances for debugging. - Manages breakpoints, stack frames, scopes, and variables.
- Receives trace events from Qute templates and maps them to DAP events.
- Notifies registered
DebuggerListeners of relevant events (stopped, threads changes, output, termination, etc.).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDebuggerListener(DebuggerListener listener) Registers a debugger listener to receive debug events.CompletableFuture<org.eclipse.lsp4j.debug.CompletionsResponse> completions(org.eclipse.lsp4j.debug.CompletionsArguments args) Provides code completions for the specified context.CompletableFuture<org.eclipse.lsp4j.debug.EvaluateResponse> Evaluates the given expression in the context of the specified frame.findStackFrame(Integer frameId) Finds a stack frame by its ID across all threads.org.eclipse.lsp4j.debug.Scope[]getScopes(int frameId) Returns the variable scopes for the given stack frame.org.eclipse.lsp4j.debug.SourceResponsegetSourceReference(int sourceReference) Returns the source code template for a given source reference.getSourceTemplateRegistry(io.quarkus.qute.Engine engine) org.eclipse.lsp4j.debug.StackTraceResponsegetStackFrames(int threadId, Integer startFrame, Integer levels) Returns the stack frames for the specified thread.getState(int threadId) Returns the current state of the remote debugger for a given thread.org.eclipse.lsp4j.debug.ThreadgetThread(int threadId) Returns the thread with the given ID.org.eclipse.lsp4j.debug.Thread[]Returns the list of threads known to the debugger.org.eclipse.lsp4j.debug.Variable[]getVariables(int variablesReference) Retrieves the variables for a given variable reference.booleanReturns whether the debugger is currently enabled.voidnext(int threadId) Moves to the next statement for the given thread (alias for step over).voidonAfterResolve(io.quarkus.qute.trace.ResolveEvent event) voidonBeforeResolve(io.quarkus.qute.trace.ResolveEvent event) Called whenever a Qute template node is processed.voidonEndTemplate(io.quarkus.qute.trace.TemplateEvent event) Called when template execution ends.voidonStartTemplate(io.quarkus.qute.trace.TemplateEvent event) Called when a template starts executing.voidpause(int threadId) Pauses the execution of the template engine on the specified thread.voidremoveDebuggerListener(DebuggerListener listener) Removes a debugger listener and unlocks all threads if there are no listeners left.voidreset()Resets the agent by unlocking all threads and clearing tracked engines.Resolves the Java method or class referenced from a Qute template for the purpose of setting breakpoints.voidresume(int threadId) Resumes the execution of the template engine on the specified thread.org.eclipse.lsp4j.debug.Breakpoint[]setBreakpoints(org.eclipse.lsp4j.debug.SourceBreakpoint[] sourceBreakpoints, org.eclipse.lsp4j.debug.Source source) Sets breakpoints in a source file.voidsetEnabled(boolean enabled) Enables or disables the debugger.voidsetJavaSourceResolver(JavaSourceResolver javaSourceResolver) voidstepIn(int threadId) Performs a "step in" operation for the given thread.voidstepOut(int threadId) Performs a "step out" operation for the given thread.voidstepOver(int threadId) Performs a "step over" operation for the given thread.voidTerminates the debugging session.voidtrack(io.quarkus.qute.Engine engine) Starts tracking the given Qute engine for debugging.voidUnlocks and terminates all debuggee threads, then clears all tracked engines.
-
Constructor Details
-
DebuggeeAgent
public DebuggeeAgent()Creates a newDebuggeeAgentinstance.
-
-
Method Details
-
track
public void track(io.quarkus.qute.Engine engine) Starts tracking the given Qute engine for debugging.- Parameters:
engine- the engine to track.
-
getState
Description copied from interface:DebuggerReturns the current state of the remote debugger for a given thread.- Specified by:
getStatein interfaceDebugger- Parameters:
threadId- the ID of the thread- Returns:
- the current
DebuggerStateof the thread
-
pause
public void pause(int threadId) Description copied from interface:DebuggerPauses the execution of the template engine on the specified thread. -
resume
public void resume(int threadId) Description copied from interface:DebuggerResumes the execution of the template engine on the specified thread. -
onStartTemplate
public void onStartTemplate(io.quarkus.qute.trace.TemplateEvent event) Called when a template starts executing.- Parameters:
event- the start template event.
-
onBeforeResolve
public void onBeforeResolve(io.quarkus.qute.trace.ResolveEvent event) Called whenever a Qute template node is processed.- Parameters:
event- the resolve event representing the current node.
-
onAfterResolve
public void onAfterResolve(io.quarkus.qute.trace.ResolveEvent event) -
onEndTemplate
public void onEndTemplate(io.quarkus.qute.trace.TemplateEvent event) Called when template execution ends.- Parameters:
event- the end template event.
-
setBreakpoints
public org.eclipse.lsp4j.debug.Breakpoint[] setBreakpoints(org.eclipse.lsp4j.debug.SourceBreakpoint[] sourceBreakpoints, org.eclipse.lsp4j.debug.Source source) Description copied from interface:DebuggerSets breakpoints in a source file.- Specified by:
setBreakpointsin interfaceDebugger- Parameters:
sourceBreakpoints- the breakpoints to setsource- the source file where breakpoints are applied- Returns:
- the actual breakpoints that were set
-
getThread
public org.eclipse.lsp4j.debug.Thread getThread(int threadId) Description copied from interface:DebuggerReturns the thread with the given ID. -
getThreads
public org.eclipse.lsp4j.debug.Thread[] getThreads()Description copied from interface:DebuggerReturns the list of threads known to the debugger.- Specified by:
getThreadsin interfaceDebugger- Returns:
- an array of
Threadobjects
-
addDebuggerListener
Description copied from interface:DebuggerRegisters a debugger listener to receive debug events.- Specified by:
addDebuggerListenerin interfaceDebugger- Parameters:
listener- the listener to register
-
removeDebuggerListener
Removes a debugger listener and unlocks all threads if there are no listeners left.- Specified by:
removeDebuggerListenerin interfaceDebugger- Parameters:
listener- the listener to remove.
-
unlockAllDebuggeeThreads
public void unlockAllDebuggeeThreads()Unlocks and terminates all debuggee threads, then clears all tracked engines. -
terminate
public void terminate()Description copied from interface:DebuggerTerminates the debugging session. -
stepIn
public void stepIn(int threadId) Description copied from interface:DebuggerPerforms a "step in" operation for the given thread. -
stepOut
public void stepOut(int threadId) Description copied from interface:DebuggerPerforms a "step out" operation for the given thread. -
stepOver
public void stepOver(int threadId) Description copied from interface:DebuggerPerforms a "step over" operation for the given thread. -
next
public void next(int threadId) Description copied from interface:DebuggerMoves to the next statement for the given thread (alias for step over). -
completions
public CompletableFuture<org.eclipse.lsp4j.debug.CompletionsResponse> completions(org.eclipse.lsp4j.debug.CompletionsArguments args) Description copied from interface:DebuggerProvides code completions for the specified context.- Specified by:
completionsin interfaceDebugger- Parameters:
args- theCompletionsArgumentsfor the current context- Returns:
- a
CompletableFuture<org.eclipse.lsp4j.debug.CompletionsResponse>with the suggested completions
-
getSourceReference
public org.eclipse.lsp4j.debug.SourceResponse getSourceReference(int sourceReference) Description copied from interface:DebuggerReturns the source code template for a given source reference.- Specified by:
getSourceReferencein interfaceDebugger- Parameters:
sourceReference- the source reference- Returns:
- the source code template for a given source reference
-
getStackFrames
public org.eclipse.lsp4j.debug.StackTraceResponse getStackFrames(int threadId, Integer startFrame, Integer levels) Description copied from interface:DebuggerReturns the stack frames for the specified thread.- Specified by:
getStackFramesin interfaceDebugger- Parameters:
threadId- the ID of the threadstartFrame- the index of the first frame to return; if omitted frames start at 0.levels- the maximum number of frames to return. If levels is not specified or 0, all frames are returned.- Returns:
- an array of
StackFrameobjects and the total frames
-
getScopes
public org.eclipse.lsp4j.debug.Scope[] getScopes(int frameId) Description copied from interface:DebuggerReturns the variable scopes for the given stack frame. -
getVariables
public org.eclipse.lsp4j.debug.Variable[] getVariables(int variablesReference) Description copied from interface:DebuggerRetrieves the variables for a given variable reference.- Specified by:
getVariablesin interfaceDebugger- Parameters:
variablesReference- the reference ID for the variable- Returns:
- an array of child
Variableobjects
-
evaluate
public CompletableFuture<org.eclipse.lsp4j.debug.EvaluateResponse> evaluate(Integer frameId, String expression, String context) Description copied from interface:DebuggerEvaluates the given expression in the context of the specified frame.- Specified by:
evaluatein interfaceDebugger- Parameters:
frameId- the ID of the stack frame (nullable)expression- the expression to evaluatecontext- the evaludation context- Returns:
- a
CompletableFuturethat completes with the evaluation result
-
findStackFrame
Finds a stack frame by its ID across all threads. -
getVariablesRegistry
-
getSourceTemplateRegistry
-
setJavaSourceResolver
-
setEnabled
public void setEnabled(boolean enabled) Description copied from interface:DebuggerEnables or disables the debugger.- Specified by:
setEnabledin interfaceDebugger- Parameters:
enabled-trueto enable the debugger,falseto disable it
-
isEnabled
public boolean isEnabled()Description copied from interface:DebuggerReturns whether the debugger is currently enabled. -
reset
public void reset()Resets the agent by unlocking all threads and clearing tracked engines. -
resolveJavaSource
public CompletableFuture<JavaSourceLocationResponse> resolveJavaSource(JavaSourceLocationArguments params) Description copied from interface:JavaSourceResolverResolves the Java method or class referenced from a Qute template for the purpose of setting breakpoints.The
JavaSourceLocationArgumentscontains the parsed information from aqute-java://URI. The method returns aCompletableFuturethat completes with aJavaSourceLocationResponsecontaining the Java file URI and the start line of the template content (or the method/class if applicable).- Specified by:
resolveJavaSourcein interfaceJavaSourceResolver- Parameters:
params- the arguments describing the Java element to resolve- Returns:
- a future completing with the resolved Java source location
-
getJavaSourceResolver
-