Skip to content

Always show return type/signature for all items in code completion #2462

Closed

Description

@RaviKavaiya

Is it possible to show return type of a method in intellisense (or a complete method signature)?

Sometimes, it is much useful when we have a large number of methods available. And to pick one quickly, this will help much.

For example, in Android Studio, it shows like this:
Screenshot 2020-05-16 at 7 57 32 PM

Activity

  1. DanTup commented on May 18, 2020

    @DanTup
    Member

    We do show the return type in the same place here:

    Screenshot 2020-05-18 at 10 09 24

    However VS Code only shows it for the highlighted item. There's an open issue about improving this here:

    microsoft/vscode#39441

    If that is implemented, we should be able to improve this here too.

  2. added this to the On Deck milestone on May 18, 2020
  3. added
    in editorRelates to code editing or language features
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on May 18, 2020
  4. modified the milestones: On Deck, Backlog on Jul 2, 2020
  5. DanTup commented on Aug 26, 2021

    @DanTup
    Member

    Looks like the LSP part of this work will be in v3.17 of the spec.

    microsoft/language-server-protocol#1307

  6. modified the milestones: Backlog, On Deck on Aug 26, 2021
  7. modified the milestones: On Deck, v3.48.0 on Jul 26, 2022
  8. removed this from the v3.48.0 milestone on Aug 25, 2022
  9. 30 remaining items

  10. added this to the v3.72.0 milestone on Jul 27, 2023
  11. DanTup commented on Aug 3, 2023

    @DanTup
    Member

    For now I'm going ahead with example 5 from above, but we can tweak if it doesn't feel right when people start using it.

    One thing I changed slightly though is that we'll show the import-uri on the right side of the item is not already imported. The reason for this is that if you don't have the details panel visible, you'd often see duplicated items (where they're available from multiple libraries and none are imported) and it wouldn't be obvious why. With the old functionality it should show on the right side of the completion list only for the selected item, but in the new world we can't show things only for the selected item so they'll show all the time.

    So with the panel collapsed it'll look something like this:

    image

    And with it visible like this:

    image

    Unfortunately we can't tell if the panel is open, so we can't hide the URIs from the right side of the completion list in that case, so there's a little duplication, but I feel like that's the best compromise.

    I'm interested in feedback though (I'll post back after the change lands, it's not complete yet).

  12. DanTup commented on Aug 31, 2023

    @DanTup
    Member

    This has landed in the latest SDK (it may take a few days to get to Flutter master). Since it ships in the SDK it'll show up in a future SDK release (not a VS Code extension release). If you have any feedback/issues about the changes, please open new issues with details - thanks!

  13. Number-3434 commented on Feb 13, 2024

    @Number-3434

    Could there be an option to enable option 2?

    I really like that you can see all the parameters there.

  14. DanTup commented on Feb 15, 2024

    @DanTup
    Member

    @Number-3434 generally I think we should avoid too many options because it makes testing and maintaining more complicated, particularly where the combinations could multiply. Here we're already handling the original LSP format and this new format, so another option would double this to possible outcomes for each completion item. I think we should be sure there's sufficient demand to warrant the option (or just changing the default). I'd suggest filing an issue at https://github.com/dart-lang/sdk to collect comments and 👍 's.

    That said, it's not quite the same - but in case you didn't have the extra panel expanded, the parameters are shown in the info on the right for the selected item:

    image

    And if you have signature help enabled (the default), it'll pop open if you select an item and show the parameters there too:

    image

    These might help if you already have a general idea of what you're looking for.

  15. Number-3434 commented on Feb 15, 2024

    @Number-3434

    Okay, I'll leave it for now.

    It just felt a bit weird that it shows abbreviated parameters, but doesn't currently show the full parameters anywhere.

  16. DanTup commented on Feb 15, 2024

    @DanTup
    Member

    It just felt a bit weird that it shows abbreviated parameters, but doesn't currently show the full parameters anywhere.

    Not sure I agree that it doesn't show them anywhere, they're shown in the places I noted above :)

    Unfortunately VS Code changed how it shows the details slightly with this new work - it used to be that it showed the first line of the details on the right side of the selected item like this:

    image

    However when adopting this new UI, they removed that so that it only appears in the panel on the right (not inline when the item is selected). We're still putting the full signature into the details, but it'll only be visible in the panel on the right (whereas before it showed in two places).

  17. Number-3434 commented on Feb 15, 2024

    @Number-3434

    Sorry, I meant specifically the inline text after the suggestion in the suggest widget.

    It makes it much quicker to browse, as you can glance at the values, as opposed to having to go through every suggestion individually.

    Also, personally, I really like that it shows them even if details are on.

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 enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions