Skip to content

Commit da05cdb

Browse files
committed
implement supports for hovers in debug adapter
1 parent 972a318 commit da05cdb

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

robotcode/debug_adapter/launcher/debugger.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -672,13 +672,24 @@ def evaluate(
672672
if evaluate_context is None:
673673
evaluate_context = EXECUTION_CONTEXTS.current
674674

675+
if context in [EvaluateArgumentContext.HOVER]:
676+
expression = f"${expression}"
675677
try:
676-
vars = evaluate_context.variables.current if frame_id is not None else evaluate_context.variables._global
677-
if self.VARS_RE.match(expression.strip()):
678-
result = vars.replace_string(expression)
678+
if expression:
679+
vars = (
680+
evaluate_context.variables.current if frame_id is not None else evaluate_context.variables._global
681+
)
682+
if self.VARS_RE.match(expression.strip()):
683+
result = vars.replace_string(expression)
684+
else:
685+
result = evaluate_expression(vars.replace_string(expression), vars.store)
679686
else:
680-
result = evaluate_expression(vars.replace_string(expression), vars.store)
687+
return EvaluateResult("")
688+
681689
except BaseException as e:
682-
result = e
690+
if context in [EvaluateArgumentContext.HOVER]:
691+
return EvaluateResult("")
692+
else:
693+
result = e
683694

684695
return EvaluateResult(repr(result), repr(type(result)))

robotcode/debug_adapter/launcher/server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ async def _evaluate(
217217
frame_id: Optional[int] = None,
218218
context: Union[EvaluateArgumentContext, str, None] = None,
219219
format: Optional[ValueFormat] = None,
220+
**kwargs: Any,
220221
) -> EvaluateResponseBody:
221222
result = Debugger.instance().evaluate(expression, frame_id, context, format)
222223
return EvaluateResponseBody(

robotcode/debug_adapter/server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ async def _initialize(self, arguments: InitializeRequestArguments) -> Capabiliti
8282
# supports_hit_conditional_breakpoints=True,
8383
support_terminate_debuggee=True,
8484
support_suspend_debuggee=True,
85+
supports_evaluate_for_hovers=True,
8586
# supports_loaded_sources_request=True,
8687
supports_terminate_request=True,
8788
# supports_data_breakpoints=True

0 commit comments

Comments
 (0)