Skip to content

fix: SCIP index no longer generates non-existent occurrence ranges - #296

Merged
chrapkowski-sg merged 3 commits into
mainfrom
fix-scip-index-no-longer
Sep 17, 2026
Merged

chrapkowski-sg merged 3 commits into
mainfrom
fix-scip-index-no-longer

Conversation

@chrapkowski-sg

@chrapkowski-sg chrapkowski-sg commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Fix SCIP occurrence ranges for generated Go files containing //line directives, such as files produced by goyacc.

FileSet.Position honours these directives. Column-less directives report an unknown Go column as 0, which became -1 after conversion to SCIP’s zero-based coordinates. Adjusted line numbers could also point into the logical generator source rather than the emitted .go document.

This changes occurrence range calculation to use unadjusted physical positions via PositionFor(pos, false). Package declarations, imports, identifiers, selectors, and enclosing ranges now consistently point into the physical Go document represented by the SCIP index.

Adds a snapshot test covering package, import, definition, reference, and enclosing ranges after a //line directive.

@chrapkowski-sg

Copy link
Copy Markdown
Contributor Author

This change is part of the following stack:

Change managed by git-spice.

@chrapkowski-sg
chrapkowski-sg force-pushed the fix-scip-index-no-longer branch from ec5be25 to a34c1a3 Compare September 17, 2026 13:40
@chrapkowski-sg
chrapkowski-sg marked this pull request as ready for review September 17, 2026 14:05

@keegancsmith keegancsmith left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this repo has a reasonable linter already setup so probably just ignore this general comment. But we could ban the use of Position? But yeah, LGTM! Love snapshot tests :)

Comment thread internal/index/scip.go
for _, f := range pkg.Syntax {
doc := pathToDocuments[pkg.Fset.File(f.Package).Name()]
position := pkg.Fset.Position(f.Name.NamePos)
position := pkg.Fset.PositionFor(f.Name.NamePos, false)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just checking. so these switches to PositionFor false are the most important right, since it makes the //line comments ignored.

@chrapkowski-sg
chrapkowski-sg removed the request for review from emidoots September 17, 2026 16:46
@chrapkowski-sg
chrapkowski-sg merged commit 343fa9c into main Sep 17, 2026
14 checks passed
@chrapkowski-sg
chrapkowski-sg deleted the fix-scip-index-no-longer branch September 17, 2026 17:04
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.

2 participants