Add helpers

This commit is contained in:
2025-11-14 22:11:59 +00:00
parent 0d3534ac10
commit 9d73eb3679
2 changed files with 33 additions and 1 deletions
+9
View File
@@ -3000,6 +3000,15 @@ def search_symbol(symbol: str, root_dir: Path, top_k: int = 20) -> List[Dict[str
logger.warning(f"ripgrep failed: {e}")
return matches
def _extract_imports(source: str) -> list[str]:
"""Return a list of fullyqualified imports found in `source`."""
return [m.group(1).strip() for m in re.finditer(r'^\s*use\s+([^;]+);', source, re.MULTILINE)]
def _extract_calls(source: str) -> list[str]:
"""Return a list of called function names (bare name only)."""
return [m.group(1).split("::")[-1] for m in re.finditer(r'([A-Za-z_][A-Za-z0-9_:]*)\s*\(', source, re.MULTILINE)]
# -----------------------------
# Additional tool: read file lines with context
# -----------------------------