Skip to content

Make analysis server/IDEs show the distinction between fields and getters accurately and consistently #55956

@DanTup

Description

@DanTup

In Dart-Code/Dart-Code#5011 it was highlighted that in some places in VS Code (via LSP) we are inconsistent about when we map things to a "Property" kind vs a "Field" kind. In some places (for example code completion) we use "Field" where the static type has an implicit getter that just points at a field, but in others (like semantic tokens) we do not.

We feel the right thing to do here is to follow the language accurately, so when something is a reference to a getter, we should always show it as such (a "Property" in LSP) even if in the static type it's just a field. Showing something as a Field is inconsistent with the spec and could lead to incorrect assumptions (since it could actually be an overridden getter at runtime).

For LSP, this means we should only map to the "Field" kinds for actual references to fields (like constructor initializers, field formals, and the field declaration in something like document outline) and other places (semantic tokens, hovers, code completion) should use "Property".

(@jwren I suspect all changes here are either LSP-specific, or in base server functionality that will be updated in order to fix this for LSP, but FYI just in case there might be things in the IntelliJ plugin that might need reviewing).

(fyi @bwilkerson @stereotype441)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-lspIssues with analysis server's support of Language Server Protocoldevexp-serverIssues related to some aspect of the analysis servertype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions