Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from sqlalchemy.dialects.postgresql import ARRAY
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship

INDEX_SEMANTICS_VERSION = 3
INDEX_SEMANTICS_VERSION = 4
"""Version of the indexing semantics the current code produces.

2: semantic search default-on -- every already-indexed branch must re-index once so
Expand All @@ -37,6 +37,10 @@
``reference_edges`` backfills; without a bump a branch at HEAD would skip forever
and never get edges.

4: reference edges for JS/TS/TSX/Go/Java/Rust -- every already-indexed branch
must re-index once so multi-language ``reference_edges`` backfill; without a
bump a branch at HEAD would skip forever and never get non-Python edges.

Bump this whenever the *meaning* of what gets written changes: any change to
``indexer/symbols.py``, to ``indexer/parse.py``'s chunking, or to
``indexer/languages.py``'s extraction contract. A bump forces every repo to
Expand Down
33 changes: 30 additions & 3 deletions indexer/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
never disagree on language names. Language values MUST be valid
``tree_sitter_language_pack`` parser names. ``EDGE_NODE_KINDS`` maps, per
language, tree-sitter node ``.type`` -> reference-edge kind (``call``/``import``);
a language absent from the map yields zero edges (Python only for #84; #85
adds the rest).
a language absent from the map yields zero edges.
"""

from __future__ import annotations
Expand Down Expand Up @@ -79,13 +78,41 @@
# Per language: tree-sitter node ``.type`` -> reference-edge kind stored in
# ``reference_edges``. Every value MUST be within the DB CHECK set
# (``ReferenceEdge.__table__``'s ``ck_reference_edges_edge_kind``), enforced by
# a unit test. Python only for #84 -- #85 adds the other six languages.
# a unit test.
EDGE_NODE_KINDS: dict[str, dict[str, str]] = {
"python": {
"call": "call",
"import_statement": "import",
"import_from_statement": "import",
},
"javascript": {
"call_expression": "call", # f(x), a.b.f(), obj?.m()
"new_expression": "call", # new Foo() -> constructor reference
"import_statement": "import", # ES imports (all specifier shapes)
},
"typescript": {
"call_expression": "call", # incl. f<T>(x)
"new_expression": "call",
"import_statement": "import", # incl. import type / import x = require(...)
},
"tsx": {
"call_expression": "call",
"new_expression": "call",
"import_statement": "import",
},
"go": {
"call_expression": "call", # f(), pkg.F(), obj.Method(); go/defer wrap this
"import_spec": "import", # per-spec node -> per-import anchors, single & grouped
},
"java": {
"method_invocation": "call", # f(), obj.m(), C.stat(), this.n(), super.s(), obj.<T>m()
"object_creation_expression": "call", # new Foo(), new a.b.Foo(), new Foo<T>()
"import_declaration": "import", # import a.b.C; static; a.b.*
},
"rust": {
"call_expression": "call", # f(), a::b::g(), Foo::new(), x.method()
"use_declaration": "import", # use trees: scoped, grouped, nested, self, wildcard, as
},
}


Expand Down
Loading
Loading