@@ -134,15 +134,22 @@ async def _find_references(
134134 ignore_patterns = config .exclude_patterns or [], # type: ignore
135135 absolute = True ,
136136 ):
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 ))
138145
139- futures .append (run_coroutine_in_thread (func , doc , * args , ** kwargs ))
140146 for e in await asyncio .gather (* futures , return_exceptions = True ):
141147 if isinstance (e , BaseException ):
142148 if not isinstance (result , asyncio .CancelledError ):
143149 self ._logger .exception (e )
144150 continue
145151 result .extend (e )
152+
146153 return result
147154
148155 async def _references_default (
@@ -501,18 +508,25 @@ async def find_keyword_references_in_file(
501508 lib_doc : Optional [LibraryDoc ] = None ,
502509 ) -> List [Location ]:
503510
504- namespace = await self .parent .documents_cache .get_namespace (doc )
511+ try :
512+ namespace = await self .parent .documents_cache .get_namespace (doc )
505513
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 )
514528
515- return await self . _find_keyword_references_in_namespace ( namespace , kw_doc )
529+ return []
516530
517531 async def _find_keyword_references_in_namespace (self , namespace : Namespace , kw_doc : KeywordDoc ) -> List [Location ]:
518532 from robot .parsing .lexer .tokens import Token as RobotToken
0 commit comments