Skip to content

Commit

Permalink
perf(analyzer): optimized analysing keyword calls
Browse files Browse the repository at this point in the history
  • Loading branch information
d-biehl committed Oct 23, 2024
1 parent 96fbe90 commit b1f0f28
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def __init__(self, namespace: "Namespace", library_doc: LibraryDoc) -> None:
self.self_library_doc = library_doc

self.diagnostics: List[DiagnosticsEntry] = []
self.result_bdd_prefix: Optional[str] = None

self.multiple_keywords_result: Optional[List[KeywordDoc]] = None
self._cache: Dict[
Tuple[Optional[str], bool],
Expand All @@ -61,6 +63,7 @@ def __init__(self, namespace: "Namespace", library_doc: LibraryDoc) -> None:
def reset_diagnostics(self) -> None:
self.diagnostics = []
self.multiple_keywords_result = None
self.result_bdd_prefix = None

def find_keyword(
self,
Expand Down Expand Up @@ -470,7 +473,11 @@ def bdd_prefix_regexp(self) -> "re.Pattern[str]":
def _get_bdd_style_keyword(self, name: str) -> Optional[KeywordDoc]:
match = self.bdd_prefix_regexp.match(name)
if match:
return self._find_keyword(
result = self._find_keyword(
name[match.end() :], handle_bdd_style=False if get_robot_version() >= (7, 0) else True
)
if result:
self.result_bdd_prefix = str(match)

return result
return None
Original file line number Diff line number Diff line change
Expand Up @@ -552,13 +552,11 @@ def _analyze_keyword_call(
if not allow_variables and not is_not_variable_token(keyword_token):
return None

result = self._finder.find_keyword(keyword, raise_keyword_error=False, handle_bdd_style=False)
result = self._finder.find_keyword(keyword, raise_keyword_error=False)

if result is None:
if result is not None and self._finder.result_bdd_prefix:
keyword_token = ModelHelper.strip_bdd_prefix(self._namespace, keyword_token)

result = self._finder.find_keyword(keyword, raise_keyword_error=False)

kw_range = range_from_token(keyword_token)

if keyword:
Expand Down

0 comments on commit b1f0f28

Please sign in to comment.