mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-29 01:41:42 +00:00
fix(go): address third-round review LOW findings
- Remove dead `if (raw.startsWith('chan ')) continue;` and add
comment explaining chan prefix stripping behavior
- Add 'comparable' to GO_BUILTIN_TYPES (21 predeclared types now)
- Add source comment for blank import V1 drop decision
- Neutralize residual "Go" example references in shared
imported-return-types.ts comments (DoD §2.2)
This commit is contained in:
parent
30982c6d38
commit
ec65a3cfbd
3 changed files with 9 additions and 3 deletions
|
|
@ -12,6 +12,7 @@ import { getTreeSitterBufferSize } from '../../constants.js';
|
|||
const GO_BUILTIN_TYPES = new Set([
|
||||
'bool',
|
||||
'byte',
|
||||
'comparable',
|
||||
'complex128',
|
||||
'complex64',
|
||||
'error',
|
||||
|
|
@ -180,9 +181,11 @@ export function emitGoScopeCaptures(
|
|||
let raw = typeCap.text.trim();
|
||||
while (raw.startsWith('*')) raw = raw.slice(1).trim();
|
||||
if (raw.startsWith('[]')) raw = raw.slice(2).trim();
|
||||
// Strip chan prefix so element type gets qualified:
|
||||
// chan Event → pkg.Event (correct for cross-receiver dispatch)
|
||||
// chan int → excluded by GO_BUILTIN_TYPES below (no phantom pkg.int)
|
||||
if (raw.startsWith('chan ')) raw = raw.slice(5).trim();
|
||||
if (raw.includes('.') || raw.startsWith('func(') || raw.startsWith('map[')) continue;
|
||||
if (raw.startsWith('chan ')) continue;
|
||||
if (GO_BUILTIN_TYPES.has(raw)) continue;
|
||||
const idx = raw.indexOf('[');
|
||||
if (idx !== -1) raw = raw.slice(0, idx);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ export function splitGoImportStatement(node: SyntaxNode): CaptureMatch[] {
|
|||
const kind =
|
||||
alias === '.' ? 'dot' : alias === '_' ? 'blank' : alias === undefined ? 'namespace' : 'alias';
|
||||
|
||||
// Blank imports (import _ "pkg") are dropped in V1 — they represent
|
||||
// side-effect registrations (e.g. database drivers), but emitting
|
||||
// side-effect edges is deferred. See test: go-imports.test.ts.
|
||||
if (kind === 'blank') return [];
|
||||
|
||||
const aliased = alias !== undefined && alias !== '.' && alias !== '_';
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ export function propagateImportedReturnTypes(
|
|||
}
|
||||
|
||||
// Namespace-import mirroring: for languages with namespace-style
|
||||
// imports (Go `import "pkg"`), mirror exported typeBindings from all
|
||||
// imports (e.g. `import "pkg"`), mirror exported typeBindings from all
|
||||
// target files' module scopes into the importer's module scope. This
|
||||
// covers the cross-package case where `x := pkg.Func()` creates a
|
||||
// function-scope typeBinding `x → Func`, and the module-scope chain-
|
||||
|
|
@ -212,7 +212,7 @@ export function propagateImportedReturnTypes(
|
|||
if (moduleEdges === undefined) continue;
|
||||
|
||||
// Collect namespace target files per localName (one namespace may
|
||||
// expand to multiple files — e.g. Go multi-file packages).
|
||||
// expand to multiple files — e.g. multi-file namespace-import packages).
|
||||
const nsTargets = new Map<string, string[]>();
|
||||
for (const edge of moduleEdges) {
|
||||
if (edge.kind !== 'namespace' || edge.targetFile === null) continue;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue