Skip to content

Missing contextual information when hovering over extension type declarations #5005

Closed

Description

@incendial

Consider the following example:

extension type ET(Future<void> value) implements Future<void> {}

class SomeClass implements String {
  const SomeClass();
}

enum SomeEnum { first }

both enum and class have contextual info when hovering over their name (e.g. that it's a class and implements String):
Screenshot 2024-02-24 at 11 55 06

for extension types this tooltip has only the name:
Screenshot 2024-02-24 at 11 55 36

Please complete the following information:

Dart Code extension: 3.82.0

App: Visual Studio Code
App Host: desktop
Version: mac 1.86.2

Workspace type: Dart (LSP)

Dart (3.3.0): /Users/incendial/Desktop/flutter/bin/cache/dart-sdk
Flutter (3.19.1): /Users/incendial/Desktop/flutter (No device)

Activity

  1. incendial commented on Feb 24, 2024

    @incendial
    Author

    Also noticed that for cmd + hover extension types have a bit confusing constructor (without the extension type name)
    Screenshot 2024-02-24 at 11 58 07

    It gets a bit worse for named constructors
    Screenshot 2024-02-24 at 11 59 31

    When classes, for example, have the name
    Screenshot 2024-02-24 at 11 59 47

    Is it by design or you'd want this to be fixed?

  2. incendial commented on Feb 24, 2024

    @incendial
    Author

    The example above is not for declaration, but for instantiation:

    void fn() {
      ET.named();
      SomeClass();
    }
  3. incendial commented on Feb 24, 2024

    @incendial
    Author

    And if the extension type is const, this info is not displayed (but for a class it's there):

    extension type const ET.named(Future<void> value) implements Future<void> {}
    Screenshot 2024-02-24 at 12 02 05
  4. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    relies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available
    on Feb 26, 2024
  5. added this to the v3.84.0 milestone on Feb 26, 2024
  6. DanTup commented on Feb 28, 2024

    @DanTup
    Member

    Fixed by dart-lang/sdk@8a62f4a, but ships in an SDK release.

  7. DanTup commented on Feb 28, 2024

    @DanTup
    Member

    Oops, I missed some of the extra things noted above, I need to check if the fix covered them too.

  8. reopened this on Feb 28, 2024
  9. DanTup commented on Feb 28, 2024

    @DanTup
    Member

    @incendial do you have a complete code sample to trigger the bad preview on the named constructor of an extension type?

    I can reproduce the issue for unnamed constructors:

    image

    And I understand the cause of this (which seems specific to the default constructor), however I can't reproduce for named constructors:

    image

  10. incendial commented on Feb 28, 2024

    @incendial
    Author
    extension type ET.named(Future<void> value) implements Future<void> {}
    
    void fn() {
      ET.named();
    }
    Screenshot 2024-02-28 at 17 29 42
  11. DanTup commented on Feb 28, 2024

    @DanTup
    Member

    Perfect - thanks! I didn't realise we could put the name there like that 😄

  12. incendial commented on Feb 28, 2024

    @incendial
    Author

    It can also be const

    extension type const ET.named(Future<void> value) implements Future<void> {}
  13. DanTup commented on Feb 28, 2024

    @DanTup
    Member

    With my new fix, that shows up too:

    image

    The issue is basically the "primary constructor" of an extension type, which has a small "codeRange". My change expands this to be the whole declaration (so it works the same as for an implied unnamed constructor on a class).

  14. modified the milestones: v3.84.0, v3.86.0 on Mar 1, 2024
  15. modified the milestones: v3.86.0, v3.88.0 on Apr 2, 2024
  16. DanTup commented on Apr 18, 2024

    @DanTup
    Member

    Fixe dby dart-lang/sdk@c22f054. The change is in the Dart SDK so will ship in a future SDK release (rather than a Dart-Code release).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris bugrelies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions