Skip to content

Resolve enum values in option values in the LSP - #4809

Open
douzebis wants to merge 1 commit into
bufbuild:mainfrom
douzebis:lsp-option-enum-values
Open

douzebis wants to merge 1 commit into
bufbuild:mainfrom
douzebis:lsp-option-enum-values

Conversation

@douzebis

Copy link
Copy Markdown

Fixes #4808.

Go-to-definition found nothing for an enum value written as an option's
value, such as option (my.level) = LEVEL_HIGH; or {level: LEVEL_HIGH}
in a message literal, while it works for the option's name and the
literal's keys.

  • In messageToSymbolsHelper, an element whose value is an enum value
    gets a reference symbol to that value's declaration, as a type name
    does.
  • Enum values are indexed among the symbols a reference resolves to: their
    names are static symbols, which that index left out.

Tests:

  • TestDefinitionOptionEnumValue: go-to-definition on an enum value as
    an option's value and inside a message literal, and, as a control, on
    the option's name. Both enum-value cases fail without the change and
    pass with it.
  • go test ./private/buf/buflsp/ passes.

Not changed: references and rename of enum values. They handle
referenceable symbols only, and enum values stay static, so
references from an enum value's declaration still don't find its uses
in options. Making enum values referenceable would change their
highlighting and rename everywhere; happy to follow up if you want that.

A CHANGELOG entry is included under Unreleased.

Go-to-definition found nothing for an enum value written as an option's
value, such as option (my.level) = LEVEL_HIGH; or {level: LEVEL_HIGH} in
a message literal: an option's keys get symbols, its values don't. Give
an enum value a reference symbol to its declaration, and index enum
values among the symbols a reference resolves to, as their names are
static symbols.

References and rename of enum values are unchanged: enum values are
static symbols, which they don't handle.

This branch has not been deployed

No deployments
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.

LSP: go-to-definition doesn't work for enum values in option values

1 participant