Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works
Code Observatory / Source
Match a name
Plain name matching in SQL. Scope applies only when repository ids are passed.
PINNED SOURCE Copied from the repository at this commit. Source, not an execution.
PHAROS at 975a38dMIT license
find_symbolbackend/app/codeintel/symbols.py, lines 13–36Open source
def find_symbol(db: Session, name: str, *, repository_ids: list[uuid.UUID] | None = None, limit: int = 10) -> list[DocumentChunk]: """Chunks whose qualified name equals ``name`` or ends with ``.name``. Exact qualified matches sort first, then shorter names (``Cart.total`` before ``shop.cart.Cart.total`` when searching ``total``). """ name = name.strip() if not name or len(name) > 512: return [] escaped = name.replace("\\", "\\\\").replace("%", r"\%").replace("_", r"\_") stmt = select(DocumentChunk).where( DocumentChunk.repository_id.isnot(None), DocumentChunk.ast_node_type.notin_(["block"]), or_( DocumentChunk.symbol_name == name, DocumentChunk.symbol_name.like(f"%.{escaped}", escape="\\"), ), ) if repository_ids: stmt = stmt.where(DocumentChunk.repository_id.in_(repository_ids)) rows = db.execute(stmt.limit(200)).scalars().all() rows.sort(key=lambda c: (c.symbol_name != name, len(c.symbol_name or ""), c.symbol_name or "")) return rows[:limit]Where this comes from
- Commit
975a38d5d17839c26ee219295a5be6ac66b6d910- File
backend/app/codeintel/symbols.py- Lines
- 13–36
- Git blob
abdbb1001335e092a3fd51dcc000a89cac57e3a4- License
- MIT, © 2024–2026 Pharos Contributors. Notice
Read it on GitHub at this commit
Check it yourself
From a clone of the repository, the first command prints the blob above and the second prints these lines.
git rev-parse 975a38d:backend/app/codeintel/symbols.py
git show 975a38d:backend/app/codeintel/symbols.py | sed -n '13,36p'