Skip to content

Add enclosing ranges for Go declarations - #298

Merged
jupblb merged 2 commits into
scip-code:mainfrom
jordigilh:feat/definition-enclosing-ranges
Sep 26, 2026
Merged

jupblb merged 2 commits into
scip-code:mainfrom
jordigilh:feat/definition-enclosing-ranges

Conversation

@jordigilh

Copy link
Copy Markdown
Contributor

Closes #297.

Emit typed enclosing ranges for type, var/const, and struct-field definitions, including attached docs, and declare UTF-8 byte positions. Existing function ranges and primary occurrence sites remain unchanged.

Validation: go test ./...; on the frozen Go fixture, valid definition enclosures increased 27/150 → 58/150 with all 471 primary sites unchanged. A separate Code IR shadow recheck joined 117/117 selected-local candidates.

Comment thread internal/visitors/visitor_file.go
Comment thread internal/visitors/visitor_file.go Outdated
Comment thread internal/visitors/visitor_file_test.go Outdated
@jordigilh

Copy link
Copy Markdown
Contributor Author

After addressing the comment on the Interface I did a follow up analysis on other gaps and I identified 3 more areas that could be covered in this PR if you're ok with it:

  • Generic type parameter definitions, such as T in type Box[T any], aren’t given their own enclosing ranges.
  • Block-local declarations (type, const, and var), and fields in anonymous struct types inside function signatures or bodies, aren’t collected; the current prepass scans file-level declarations.
  • For grouped declarations, individual specs get ranges, but a doc comment attached to the group’s GenDecl is omitted when there are multiple specs. Should that shared comment be included in each spec’s range?

What do you think? Should I go ahead and extend the PR scope to cover for these use cases?

@jupblb jupblb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the contribution! LGTM :)

What do you think? Should I go ahead and extend the PR scope to cover for these use cases?

These are all good observations but I'd prefer these changes are made in another PR, if that's not too much to ask.

@jupblb
jupblb merged commit 28f28d8 into scip-code:main Sep 26, 2026
14 checks passed
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.

Emit enclosing ranges for Go type, value, and struct-field definitions

2 participants