Skip to content

feat(extraction): add VB.NET language support - #1

Open
stevenn wants to merge 1 commit into
mainfrom
feat/vbnet-support
Open

stevenn wants to merge 1 commit into
mainfrom
feat/vbnet-support

Conversation

@stevenn

@stevenn stevenn commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Adds VB.NET (.vb) indexing to codegraph — classes, modules, structures, interfaces, enums, Subs/Functions, properties, constants, and Imports, with call, instantiation, and inheritance edges that resolve across files.

Grammar

Vendors a locally-patched build of CodeAnt-AI/tree-sitter-vb-dotnet (MIT). The upstream 0.1.x grammar produced ERROR trees on ordinary VB; the patches close generic (Of T) declarations, separate-line Inherits/Implements, member-level Implements/Handles, New Foo(args), the As New shorthand, nested types, #Region, Enum As <type>, For Each typed loop vars, Dim array declarators, attributes, ?. null-conditional access, and implicit line continuation inside () / after binary operators. Full patch set, rebuild steps, and a real-world status writeup live in docs/grammars/vbnet/.

Extractor (src/extraction/languages/vbnet.ts)

  • resolveBody hook so call/reference extraction reaches inline method bodies (VB declarations have no body field); extractStruct now consults it too, so structures extract.
  • visitNode hook emitting extends/implements edges from the line-statement Inherits/Implements clauses the core's field-based extractor can't see.
  • With-receiver inference: leading-dot calls (With obj … .Member) are qualified with the inferred receiver type via a new general resolveCallName extractor hook, or dropped when the type is unknown — never a bare, mis-resolving ref.

Resolver

A callable-aware VB-intrinsics filter (UBound, Len, CInt, …) drops stray edges where an intrinsic name-matches a non-callable user symbol, while leaving genuine user methods resolvable. Const fields are classified as constant kind.

Validation

Indexed a real 1,146-file VB.NET codebase: ~53k call edges (~40k cross-file), 555 inheritance edges, no node explosion, ~14s to index. A with/without A/B on a cross-assembly trace had codegraph answer in 1 command / 0 file reads vs the baseline's 11 greps. New parameterized extraction tests cover detection, structure, inheritance, intrinsics filtering, continuation, and With-receiver inference; full suite green (1,588 passing).

Status & known gaps

Support is experimental — the vendored grammar is young, so method-body control flow can parse incompletely on some files (the class/method structure and most call edges still extract). Remaining gaps (documented in docs/grammars/vbnet/README.md): leading-dot method chains and assignment/return continuations are unparsed (~34% of files parse fully clean, though extraction holds up well past that via local error recovery); multi-namespace Imports A, B keeps only the first; no VB framework resolvers yet.

🤖 Generated with Claude Code

Index VB.NET (.vb) — classes, modules, structures, interfaces, enums,
Subs/Functions, properties, constants, and Imports — with call,
instantiation, and inheritance (Inherits/Implements) edges that resolve
across files.

Grammar: vendors a locally-patched build of CodeAnt-AI/tree-sitter-vb-dotnet
(MIT). The upstream 0.1.x grammar couldn't parse generic (Of T) declarations,
separate-line Inherits/Implements, member-level Implements/Handles, New
Foo(args), the As New shorthand, nested types, #Region, Enum As <type>,
For Each typed loop vars, Dim array declarators, attributes, ?. null-
conditional access, or implicit line continuation inside () / after binary
operators. All patches + rebuild steps are in docs/grammars/vbnet/.

Extractor (src/extraction/languages/vbnet.ts) maps the grammar to the
LanguageExtractor config and adds:
- resolveBody hook so call/reference extraction reaches inline method bodies
  (VB declarations have no body field); extractStruct now consults resolveBody
  too, so structures (which also lack one) extract.
- visitNode hook emitting extends/implements edges from the line-statement
  Inherits/Implements clauses the core's field-based extractor can't see.
- With-receiver inference: leading-dot calls (With obj … .Member) are qualified
  with the inferred receiver type via a new general resolveCallName extractor
  hook, or dropped when the type is unknown — never a bare, mis-resolving ref.

Resolver: a callable-aware VB-intrinsics filter (UBound, Len, CInt, …) drops
stray edges where an intrinsic name-matches a non-callable user symbol, while
leaving genuine user methods resolvable. Const fields are classified as
constant kind.

Validated on a 1,146-file VB.NET codebase: 53k call edges (40k cross-file),
no node explosion, ~14s to index. Adds parameterized extraction tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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