@@ -58,8 +58,8 @@ def __init__(self, namespace: "Namespace", library_doc: LibraryDoc) -> None:
5858 ] = {}
5959
6060 self ._all_keywords : Optional [List [LibraryEntry ]] = None
61- self ._resource_keywords : Optional [List [ResourceEntry ]] = None
62- self ._library_keywords : Optional [List [LibraryEntry ]] = None
61+ self ._resource_imports : Optional [List [ResourceEntry ]] = None
62+ self ._library_imports : Optional [List [LibraryEntry ]] = None
6363
6464 def reset_diagnostics (self ) -> None :
6565 self .diagnostics = []
@@ -312,23 +312,23 @@ def _is_better_match(
312312 other : Tuple [Optional [LibraryEntry ], KeywordDoc ],
313313 ) -> bool :
314314 return (
315- other [1 ].matcher .embedded_arguments .match (candidate [1 ].name ) is not None
315+ other [1 ].matcher .embedded_arguments is not None
316+ and candidate [1 ].matcher .embedded_arguments is not None
317+ and other [1 ].matcher .embedded_arguments .match (candidate [1 ].name ) is not None
316318 and candidate [1 ].matcher .embedded_arguments .match (other [1 ].name ) is None
317319 )
318320
319321 def _get_keyword_from_resource_files (self , name : str ) -> Optional [KeywordDoc ]:
320- if self ._resource_keywords is None :
321- self ._resource_keywords = list (chain (self .namespace ._resources .values ()))
322+ if self ._resource_imports is None :
323+ self ._resource_imports = list (chain (self .namespace ._resources .values ()))
322324
323325 if get_robot_version () >= (6 , 0 ):
324- found : List [Tuple [Optional [LibraryEntry ], KeywordDoc ]] = []
325- for v in self ._resource_keywords :
326- r = v .library_doc .keywords .get_all (name )
327- if r :
328- found .extend ([(v , k ) for k in r ])
326+ found : List [Tuple [Optional [LibraryEntry ], KeywordDoc ]] = [
327+ (v , k ) for v in self ._resource_imports for k in v .library_doc .keywords .iter_all (name )
328+ ]
329329 else :
330330 found = []
331- for k in self ._resource_keywords :
331+ for k in self ._resource_imports :
332332 s = k .library_doc .keywords .get (name , None )
333333 if s is not None :
334334 found .append ((k , s ))
@@ -373,19 +373,18 @@ def _get_keyword_based_on_search_order(
373373 return entries
374374
375375 def _get_keyword_from_libraries (self , name : str ) -> Optional [KeywordDoc ]:
376- if self ._library_keywords is None :
377- self ._library_keywords = list (chain (self .namespace ._libraries .values ()))
376+ if self ._library_imports is None :
377+ self ._library_imports = list (chain (self .namespace ._libraries .values ()))
378378
379379 if get_robot_version () >= (6 , 0 ):
380- found : List [Tuple [Optional [LibraryEntry ], KeywordDoc ]] = []
381- for v in self ._library_keywords :
382- r = v .library_doc .keywords .get_all (name )
383- if r :
384- found .extend ([(v , k ) for k in r ])
380+ found : List [Tuple [Optional [LibraryEntry ], KeywordDoc ]] = [
381+ (v , k ) for v in self ._library_imports for k in v .library_doc .keywords .iter_all (name )
382+ ]
383+
385384 else :
386385 found = []
387386
388- for k in self ._library_keywords :
387+ for k in self ._library_imports :
389388 s = k .library_doc .keywords .get (name , None )
390389 if s is not None :
391390 found .append ((k , s ))
0 commit comments