Skip to content

Commit

Permalink
Improve handling of anonymous symbol
Browse files Browse the repository at this point in the history
Signed-off-by: Keshav Priyadarshi <[email protected]>
  • Loading branch information
keshav-space committed Mar 15, 2024
1 parent fec25d9 commit 82723d4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/source_inspector/symbols_ctags.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def collect_symbols(location):
tag = json.loads(line)

# Ignore the anonymous tags.
if (name := tag.get("name")) and "__anon" in name:
if (name := tag.get("name")) and is_anon_string(name):
continue

if (scope := tag.get("scope")) and "__anon" in scope:
Expand All @@ -105,6 +105,26 @@ def collect_symbols(location):
yield {k: v for k, v in tag.items() if k in supported_fields}


def is_anon_string(symbol):
"""
Check if a symbol is an anonymous string.
An anonymous symbol starts with `__anon` followed by a hexadecimal string.
Examples:
>>> is_anon_string("__anon722f7bb60308")
True
>>> is_anon_string("__anon_user_id")
False
"""
if symbol.startswith("__anon"):
hex_part = symbol[6:]
for c in hex_part:
if c not in "0123456789abcdef":
return False
return True
return False


_IS_CTAGS_INSTALLED = None


Expand Down

0 comments on commit 82723d4

Please sign in to comment.