Back to the room

Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works

Code Observatory / module

symbols

codeintel.symbols

PINNED SOURCE Source and edges from the index at this commit. An execution appears only where one was recorded.

PHAROS at 975a38dMIT license

Around this symbol

Search all symbols

Loading

Contains (5)
SymbolFileResolved by
chunk_refsymbols.pysame file
find_symbolsymbols.pysame file
hoversymbols.pysame file
repository_summarysymbols.pysame file
symbol_graphsymbols.pysame file
Imports (1)
SymbolFileResolved by
sourcesource.pythrough an import
Imported by (2)
SymbolFileResolved by
routerrouter.pythrough an import
native_servernative_server.pythrough an import
codeintel.symbolsbackend/app/codeintel/symbols.py, lines 1–40Open source
"""Definition lookup and call-graph navigation by symbol name."""from __future__ import annotationsimport uuidfrom sqlalchemy import or_, selectfrom sqlalchemy.orm import Sessionfrom ..database.models import CodeEdge, DocumentChunk, Repositorydef 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]def symbol_graph(db: Session, chunk_id: uuid.UUID, *, limit: int = 50) -> dict[str, list[dict]]:    """Resolved callers, callees, containment and imports around one chunk."""

Shows the first 40 of 158 lines. The rest is on GitHub at this commit.

What the index recorded

Signature
module backend.app.codeintel.symbols
File
backend/app/codeintel/symbols.py
Lines
1–158
Parser
python-ast
Git blob
abdbb1001335e092a3fd51dcc000a89cac57e3a4
Outside this subset
3 more edges reach code outside the graph shown here

Read it on GitHub at this commit