@@ -347,12 +347,16 @@ async def get_keyword_references_from_tokens(
347
347
node : ast .AST ,
348
348
kw_token : Optional [Token ],
349
349
arguments : Optional [List [Token ]],
350
+ unescape_kw_token : bool = False ,
350
351
) -> AsyncGenerator [Location , None ]:
352
+ from robot .utils .escaping import unescape
353
+
351
354
if kw_token is not None and is_not_variable_token (kw_token ):
352
355
kw : Optional [KeywordDoc ] = None
353
356
kw_matcher = KeywordMatcher (kw_doc .name )
357
+ kw_name = unescape (kw_token .value ) if unescape_kw_token else kw_token .value
354
358
355
- for lib , name in yield_owner_and_kw_names (kw_token . value ):
359
+ for lib , name in yield_owner_and_kw_names (kw_name ):
356
360
if lib is not None :
357
361
lib_matcher = KeywordMatcher (lib )
358
362
if (
@@ -364,7 +368,7 @@ async def get_keyword_references_from_tokens(
364
368
if name is not None :
365
369
name_matcher = KeywordMatcher (name )
366
370
if kw_matcher == name_matcher :
367
- kw = await namespace .find_keyword (str ( kw_token . value ) )
371
+ kw = await namespace .find_keyword (kw_name )
368
372
369
373
if kw is not None and kw == kw_doc :
370
374
yield Location (
@@ -386,7 +390,6 @@ async def get_keyword_references_from_any_run_keyword(
386
390
kw_token : Token ,
387
391
arguments : List [Token ],
388
392
) -> AsyncGenerator [Location , None ]:
389
-
390
393
if kw_token is None or not is_not_variable_token (kw_token ):
391
394
return
392
395
@@ -402,11 +405,11 @@ async def get_keyword_references_from_any_run_keyword(
402
405
yield e
403
406
elif kw .is_run_keyword_with_condition () and len (arguments ) > 1 and is_not_variable_token (arguments [1 ]):
404
407
async for e in self .get_keyword_references_from_tokens (
405
- namespace , kw_doc , node , arguments [1 ], arguments [2 :]
408
+ namespace , kw_doc , node , arguments [1 ], arguments [2 :], True
406
409
):
407
410
yield e
408
411
elif kw .is_run_keywords ():
409
-
412
+ has_separator = False
410
413
while arguments :
411
414
412
415
t = arguments [0 ]
@@ -419,9 +422,13 @@ async def get_keyword_references_from_any_run_keyword(
419
422
if separator_token is not None :
420
423
args = arguments [: arguments .index (separator_token )]
421
424
arguments = arguments [arguments .index (separator_token ) + 1 :]
425
+ has_separator = True
426
+ else :
427
+ if has_separator :
428
+ args = arguments
422
429
423
430
if is_not_variable_token (t ):
424
- async for e in self .get_keyword_references_from_tokens (namespace , kw_doc , node , t , args ):
431
+ async for e in self .get_keyword_references_from_tokens (namespace , kw_doc , node , t , args , True ):
425
432
yield e
426
433
elif kw .is_run_keyword_if () and len (arguments ) > 1 :
427
434
arguments = arguments [1 :]
@@ -442,7 +449,7 @@ async def get_keyword_references_from_any_run_keyword(
442
449
arguments = arguments [1 :]
443
450
444
451
if is_not_variable_token (t ):
445
- async for e in self .get_keyword_references_from_tokens (namespace , kw_doc , node , t , args ):
452
+ async for e in self .get_keyword_references_from_tokens (namespace , kw_doc , node , t , args , True ):
446
453
yield e
447
454
448
455
async def _find_keyword_references (self , document : TextDocument , kw_doc : KeywordDoc ) -> List [Location ]:
0 commit comments