Skip to content

Commit bf985f7

Browse files
committed
implement conditional breakpoints
1 parent 99a6031 commit bf985f7

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

robotcode/debug_adapter/launcher/debugger.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ def set_breakpoints(
295295
return []
296296

297297
def process_state(self, source: Optional[str], line_no: Optional[int], type: Optional[str]) -> None:
298+
from robot.running.context import EXECUTION_CONTEXTS
299+
from robot.variables.evaluation import evaluate_expression
300+
298301
if self.state == State.Stopped:
299302
return
300303

@@ -354,6 +357,17 @@ def process_state(self, source: Optional[str], line_no: Optional[int], type: Opt
354357
if source in self.breakpoints:
355358
breakpoints = [v for v in self.breakpoints[source].breakpoints if v.line == line_no]
356359
if len(breakpoints) > 0:
360+
for point in breakpoints:
361+
if point.condition is not None:
362+
try:
363+
vars = EXECUTION_CONTEXTS.current.variables.current
364+
hit = bool(evaluate_expression(vars.replace_string(point.condition), vars.store))
365+
except BaseException:
366+
hit = False
367+
368+
if not hit:
369+
return
370+
357371
self.state = State.Paused
358372
self.send_event(
359373
self,

robotcode/debug_adapter/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ async def _initialize(self, arguments: InitializeRequestArguments) -> Capabiliti
7878
return Capabilities(
7979
supports_configuration_done_request=True,
8080
# supports_function_breakpoints=True,
81-
# supports_conditional_breakpoints=True,
82-
# supports_hit_conditional_breakpoints=True,
81+
supports_conditional_breakpoints=True,
82+
supports_hit_conditional_breakpoints=True,
8383
support_terminate_debuggee=True,
8484
support_suspend_debuggee=True,
8585
supports_evaluate_for_hovers=True,

0 commit comments

Comments
 (0)