Skip to content

analyzers: add tree-sitter based Go analyzer - #140

Merged
anhnh2002 merged 2 commits into
mainfrom
feat/go-support
Oct 22, 2026
Merged

anhnh2002 merged 2 commits into
mainfrom
feat/go-support

Conversation

@anhnh2002

Copy link
Copy Markdown
Collaborator

Adds Go to the dependency analyzer, following the Rust analyzer (#0dbacb6).

Components: functions, methods keyed by receiver type (Buffer.Push, pointer or value receiver, from any file of the package), structs, interfaces (and their methods), other named types. Ids are path/file.go::Name.

Edges: calls, struct literals, field types, embedded types, types in parameters/results/locals/type assertions/conversions, and a type → interface link when it has the interface's methods (same package).

Resolution: a Go name resolves only inside the package (folder) it names. Repo packages are found through go.mod's module path (and local replace lines); standard-library and outside-module calls are dropped rather than bound by name to an unrelated component (same rule as Dart).

Skipped: _test.go files and vendor/.

The grammar comes from tree-sitter-language-pack, so there is no new dependency. Wired through the call-graph dispatch, supported-language lists, extension maps, CLI validators and MCP change detection; guides/development.md, README and CHANGELOG updated.

Tests: tests/test_go_analyzer.py (15 tests). Full suite 331 passed; ruff check and ruff format --check clean. On tidwall/gjson: 120 components, 235 edges, every call in gjson.go resolved. On go-chi/chi, calls from middleware/ into the root package resolve through the module path.

Known limits: method calls on a value of unknown type match only a unique method name among visible packages; methods promoted through an embedded type from another package, type aliases, package-level vars/consts and dot imports are not followed.

Functions, methods, structs, interfaces (with their method signatures),
and other defined types (type Kind int) become components; call,
field-type, embedding, composite-literal, signature/local-var type, and
interface-implementation edges connect them. Methods are keyed by their
receiver type (Buffer.Push, pointer or value receiver alike) across all
files of the package. _test.go files and vendor/ are skipped.

A Go package is a directory, so names not defined in the file are
emitted as package references ("sub/*.go::Name") and resolved by
CallGraphAnalyzer inside that package, the way Dart resolution is
scoped. Imports of the repo's own packages map to directories through
the module path in go.mod (and local replace directives); standard
library and third-party calls are dropped. Types are linked to the
interfaces of their own package whose methods they declare.

Wires .go through the call-graph dispatch, supported-language lists,
extension maps, CLI validators, and MCP change detection. The grammar
comes from tree-sitter-language-pack, so no new dependency.
@anhnh2002
anhnh2002 merged commit d8a80eb into main Oct 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant