Commit Graph

1 Commits

Author SHA1 Message Date
Andrey Kumanyaev 8ee3ca43aa parser: migrate from smacker/go-tree-sitter to tree-sitter/go-tree-sitter
The smacker fork has been stale since 2024 and pinned us to an old ABI.
  Move every adapter to the upstream bindings (v0.25.0) so we can track
  new grammar releases.

  * internal/parser/tsitter/ — thin compat shim. Re-exports the upstream
    API under smacker-style names (Type/Content/StartPoint/NamedChild(int))
    so the ~28 language adapters only needed an import-path swap. Adds
    Node.Equal()/Node.Id() for identity, since the new bindings hand back
    a fresh *Node on every traversal — pointer comparisons no longer mean
    anything.
  * internal/parser/treesitter.go — RunQuery / RunPrepared / EachMatch
    rewritten on top of the new iterator-based QueryCursor.Matches; pool
    *ts.QueryCursor directly (the new API has no per-call state leak).
  * Per-grammar shim sub-packages under internal/parser/tsitter/<lang>/
    wrap each upstream binding's Language() into a smacker-shaped
    GetLanguage() *tsitter.Language. Most pull from
    github.com/tree-sitter/tree-sitter-<lang>; a handful use third-party
    forks (camdencheek dockerfile, elixir-lang, fwcd kotlin, DerekStride
    sql, alex-pinkus swift) where the tree-sitter org has no grammar.
  * Locally vendor grammars whose upstream Go bindings are unavailable or
    broken: markdown (no Go binding), protobuf (no Go binding), dockerfile
    (parent module path conflicts with submodule path), swift + sql
    (gitignore the generated parser.c). Each ships parser.c + scanner.c +
    tree_sitter/{parser,alloc,array}.h compiled directly through CGO.
  * Lua extractor rewritten for tree-sitter-grammars/tree-sitter-lua's
    current node vocabulary: function_statement → function_declaration
    with field-based name access, variables now under
    variable_declaration → assignment_statement → variable_list, method
    calls via method_index_expression.
  * Kotlin pinned to fwcd/tree-sitter-kotlin: the
    tree-sitter-grammars/tree-sitter-kotlin v1.x grammar drops the
    type_identifier alias and would force a rewrite of the extractor.
  * PHP Laravel middleware extractor: replace pointer-keyed processed map
    and pointer comparison on parent.ChildByFieldName("object") with
    Node.Id() / Node.Equal() — both broke once *Node became
    per-traversal.

  go.mod loses smacker entirely and gains the upstream + grammar modules.
2026-04-25 00:24:53 +02:00