@@ -58,8 +58,8 @@ def __init__(self, namespace: "Namespace", library_doc: LibraryDoc) -> None:
58
58
] = {}
59
59
60
60
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
63
63
64
64
def reset_diagnostics (self ) -> None :
65
65
self .diagnostics = []
@@ -312,23 +312,23 @@ def _is_better_match(
312
312
other : Tuple [Optional [LibraryEntry ], KeywordDoc ],
313
313
) -> bool :
314
314
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
316
318
and candidate [1 ].matcher .embedded_arguments .match (other [1 ].name ) is None
317
319
)
318
320
319
321
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 ()))
322
324
323
325
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
+ ]
329
329
else :
330
330
found = []
331
- for k in self ._resource_keywords :
331
+ for k in self ._resource_imports :
332
332
s = k .library_doc .keywords .get (name , None )
333
333
if s is not None :
334
334
found .append ((k , s ))
@@ -373,19 +373,18 @@ def _get_keyword_based_on_search_order(
373
373
return entries
374
374
375
375
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 ()))
378
378
379
379
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
+
385
384
else :
386
385
found = []
387
386
388
- for k in self ._library_keywords :
387
+ for k in self ._library_imports :
389
388
s = k .library_doc .keywords .get (name , None )
390
389
if s is not None :
391
390
found .append ((k , s ))
0 commit comments