@@ -134,15 +134,22 @@ async def _find_references(
134
134
ignore_patterns = config .exclude_patterns or [], # type: ignore
135
135
absolute = True ,
136
136
):
137
- doc = await self .parent .robot_workspace .get_or_open_document (f , "robotframework" )
137
+ try :
138
+ doc = await self .parent .robot_workspace .get_or_open_document (f , "robotframework" )
139
+ except (SystemExit , KeyboardInterrupt , asyncio .CancelledError ):
140
+ raise
141
+ except BaseException as ex :
142
+ self ._logger .exception (ex )
143
+ else :
144
+ futures .append (run_coroutine_in_thread (func , doc , * args , ** kwargs ))
138
145
139
- futures .append (run_coroutine_in_thread (func , doc , * args , ** kwargs ))
140
146
for e in await asyncio .gather (* futures , return_exceptions = True ):
141
147
if isinstance (e , BaseException ):
142
148
if not isinstance (result , asyncio .CancelledError ):
143
149
self ._logger .exception (e )
144
150
continue
145
151
result .extend (e )
152
+
146
153
return result
147
154
148
155
async def _references_default (
@@ -501,18 +508,25 @@ async def find_keyword_references_in_file(
501
508
lib_doc : Optional [LibraryDoc ] = None ,
502
509
) -> List [Location ]:
503
510
504
- namespace = await self .parent .documents_cache .get_namespace (doc )
511
+ try :
512
+ namespace = await self .parent .documents_cache .get_namespace (doc )
505
513
506
- if (
507
- lib_doc is not None
508
- and lib_doc .source is not None
509
- and lib_doc .source != str (doc .uri .to_path ())
510
- and lib_doc not in (e .library_doc for e in (await namespace .get_libraries ()).values ())
511
- and lib_doc not in (e .library_doc for e in (await namespace .get_resources ()).values ())
512
- ):
513
- return []
514
+ if (
515
+ lib_doc is not None
516
+ and lib_doc .source is not None
517
+ and lib_doc .source != str (doc .uri .to_path ())
518
+ and lib_doc not in (e .library_doc for e in (await namespace .get_libraries ()).values ())
519
+ and lib_doc not in (e .library_doc for e in (await namespace .get_resources ()).values ())
520
+ ):
521
+ return []
522
+
523
+ return await self ._find_keyword_references_in_namespace (namespace , kw_doc )
524
+ except (SystemExit , KeyboardInterrupt , asyncio .CancelledError ):
525
+ raise
526
+ except BaseException as e :
527
+ self ._logger .exception (e )
514
528
515
- return await self . _find_keyword_references_in_namespace ( namespace , kw_doc )
529
+ return []
516
530
517
531
async def _find_keyword_references_in_namespace (self , namespace : Namespace , kw_doc : KeywordDoc ) -> List [Location ]:
518
532
from robot .parsing .lexer .tokens import Token as RobotToken
0 commit comments