Skip to content

Commit

Permalink
Fix: Correct error in jmespath expression resulting in erroneous line…
Browse files Browse the repository at this point in the history
… number entries.

Signed-off-by: Caroline Russell <[email protected]>
  • Loading branch information
cerrussell committed Feb 23, 2024
1 parent 0861e5a commit c821df0
Show file tree
Hide file tree
Showing 2 changed files with 291 additions and 290 deletions.
7 changes: 3 additions & 4 deletions atom_tools/lib/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,26 +237,25 @@ def query_calls(self, full_name: str, resolved_methods: List[str]) -> List:
Returns:
list[dict]: List of invoked calls and argument to calls.
"""
result = self._query_calls_helper(full_name, '].*[][][]')
result = self._query_calls_helper(full_name)
calls = []
for call in result:
m = call.get('resolvedMethod', '')
if m and m in resolved_methods:
calls.append(call)
return calls

def _query_calls_helper(self, full_name: str, call_type_str: str) -> List[Dict]:
def _query_calls_helper(self, full_name: str) -> List[Dict]:
"""
A function to help query calls.
Args:
full_name (str): The name of the function to query calls for.
call_type_str (str): The string to append to the calls pattern.
Returns:
list: The result of searching for the calls pattern in the usages.
"""
pattern = f'objectSlices[].usages[?fullName=={json.dumps(full_name)}{call_type_str}'
pattern = f'objectSlices[?fullName==`{json.dumps(full_name)}`].usages[].*[][]'
compiled_pattern = jmespath.compile(pattern)
return compiled_pattern.search(self.usages.content)

Expand Down
Loading

0 comments on commit c821df0

Please sign in to comment.