Skip to content

fix(extraction): a Go method carries the exportedness of its name - #1734

Open
danusha2345 wants to merge 1 commit into
colbymchenry:mainfrom
danusha2345:fix/go-method-exported
Open

fix(extraction): a Go method carries the exportedness of its name#1734
danusha2345 wants to merge 1 commit into
colbymchenry:mainfrom
danusha2345:fix/go-method-exported

Conversation

@danusha2345

Copy link
Copy Markdown
Contributor

Standalone off main (b9ca4b7), one commit, both extraction arms. The extractor defect noted in #1731.

What

extractMethod never set isExported, so every Go method was indexed as unexported whatever the case of its name — 148 of 148 on a 42-file tree, func (w *rotatingLogWriter) Close() included — while plain functions carried the flag. codegraph-kernel/src/go.rs mirrored the omission literally (// extractMethod passes no isExported).

A method that is a top-level declaration (methodsAreTopLevel — Go is the only such extractor) now receives the extractor's isExported exactly as a function does, and go.rs sets is_exported from the same name-case rule in extract_method. Class members in other languages keep the flag unset on purpose: their reachability is the class's, and the JS/TS isExported walks the parent chain, so applying it to methods would re-mark every member of an exported class and diverge the tsjs kernel walker.

Measured

Same Go/Kotlin/JS tree, kernel rebuilt from this checkout and confirmed loaded with CODEGRAPH_KERNEL_DEBUG=1:

Go methods base this
exported 0 41
unexported 148 107

Close / String → exported, close → not. Functions unchanged (135 / 175). The wasm arm (CODEGRAPH_KERNEL=0) gives the same flags.

Tests

extraction.test.ts: a four-symbol Go file (Close, flush, Open, helper) asserting the flag on both methods and both functions; passes on the wasm arm and with the kernel loaded. kernel-scaffold, kernel-deep-nesting, kernel-grammar-parity: 31 passed with the rebuilt kernel.

Relationship to #1732: that PR judges Go visibility by the name's case precisely because this flag was unusable; with this in, the flag and the case agree, and #1732's rule can later read the flag.

🤖 Generated with Claude Code

extractMethod never set isExported, so every Go method was indexed as
unexported — 148 of 148 on a 42-file tree, `func (w *rotatingLogWriter)
Close()` included — while plain functions carried the flag from the name's
case. The kernel's go.rs mirrored the omission ("extractMethod passes no
isExported").

A method that is a top-level declaration (methodsAreTopLevel — Go is the
only such extractor) now gets the extractor's isExported like a function
does; go.rs sets is_exported from the same name-case rule in extract_method.
Class members elsewhere keep the flag unset on purpose: their reachability
is the class's, and the JS/TS isExported walks the parent chain, so applying
it to methods would re-mark every member of an exported class and diverge
the tsjs kernel walker.

Same tree, kernel arm: methods 41 exported / 107 unexported (was 0 / 148);
wasm arm identical. kernel-scaffold, kernel-deep-nesting and
kernel-grammar-parity pass with the rebuilt kernel loaded.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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