Skip to content

Commit 7456957

Browse files
authored
Add SymbolInformation for local symbols per SCIP spec (#167)
Add SymbolInformation for local symbols per SCIP spec According to the SCIP specification, Document.symbols should contain all symbols defined within the document, including local symbols (local variables, parameters, etc.). Local symbols use the format 'local <id>' and must be included in Document.symbols for proper SCIP compliance. This change adds SymbolInformation entries for all local symbols to each document, fixing scip lint errors about missing symbol definitions for local 0, local 1, etc.
1 parent add7222 commit 7456957

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

AGENTS.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# scip-go Development Guide
2+
3+
## Commands
4+
5+
- **Build**: `go build ./cmd/scip-go`
6+
- **Test all**: `go test ./...`
7+
- **Test single package**: `go test ./internal/index`
8+
- **Update snapshots**: `go test ./internal/index -update-snapshots`
9+
- **Install**: `go install ./cmd/scip-go`
10+
- **Version check**: `go version` (uses Go 1.24.3)
11+
12+
## Testing
13+
14+
- **Snapshot testing**: Primary testing method using
15+
`internal/testdata/snapshots` directory with `internal/index/scip_test.go` as
16+
the test runner
17+
- **Test data**: Located in `internal/testdata/` with test cases as
18+
subdirectories
19+
- **Update snapshots**: Run with `-update-snapshots` flag to regenerate expected
20+
outputs
21+
- **Filter tests**: Use `-filter <name>` to run specific test cases
22+
23+
## Architecture
24+
25+
SCIP (Source Code Intelligence Protocol) indexer for Go. Main entry point is
26+
`cmd/scip-go/main.go`. Key packages: `internal/index` (core indexing),
27+
`internal/loader` (package loading), `internal/visitors` (AST traversal),
28+
`internal/document` (SCIP document generation).
29+
30+
## Code Style
31+
32+
- Package naming: lowercase, single word preferred (e.g., `index`, `loader`,
33+
`symbols`)
34+
- Imports: grouped by std library, third-party, then internal packages with
35+
blank lines
36+
- Test files: use `package_test` convention for black-box testing
37+
- Embed files: use `//go:embed` for version.txt and similar resources
38+
- Error handling: return explicit errors, no panics in library code
39+
- Logging: use `charmbracelet/log` for structured logging

internal/visitors/visitor_file.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ import (
1818
"golang.org/x/tools/go/packages"
1919
)
2020

21-
const symbolDefinition = int32(scip.SymbolRole_Definition)
22-
const symbolReference = int32(scip.SymbolRole_ReadAccess)
21+
const (
22+
symbolDefinition = int32(scip.SymbolRole_Definition)
23+
symbolReference = int32(scip.SymbolRole_ReadAccess)
24+
)
2325

2426
func NewFileVisitor(
2527
doc *document.Document,
@@ -336,6 +338,12 @@ func (v *fileVisitor) ToScipDocument() *scip.Document {
336338
}
337339

338340
documentSymbols := v.pkgSymbols.SymbolsForFile(documentFile)
341+
for _, localSymbol := range v.locals {
342+
documentSymbols = append(documentSymbols, &scip.SymbolInformation{
343+
Symbol: localSymbol,
344+
})
345+
}
346+
339347
return &scip.Document{
340348
Language: "go",
341349
RelativePath: v.doc.RelativePath,

0 commit comments

Comments
 (0)