Add helpers
This commit is contained in:
@@ -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 fully‑qualified 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
|
||||
# -----------------------------
|
||||
|
||||
Reference in New Issue
Block a user