Skip to content

Include "required" parameters in LSP's completeFunctionCalls completions #1960

Closed

Description

@atreeon
class Blah {
  final stob;
  Blah({@required this.stob});
}

When I type 'Bl' intellisense suggests 'Blah(...)'. When selecting this item it writes Blah() in my code file. Would it be a nice feature to supply my property names where the constructor uses named parameters? So I think it would be nice if it wrote the following in my code file.

Blah(
  stob:
)

For me it would be especially useful where the parameter is decorated with the @required metadata because then the named parameter must be defined. It would just save some keystrokes I guess but it would be nice.
Many thanks :-)

Activity

  1. DanTup commented on Sep 3, 2019

    @DanTup
    Member

    This would be nice, however I think it would be a bit awkward to use unless we also put tab stops next to each one:

    Blah(
      arg1: {$1},
      arg2: {$2},
      arg13 {$3},
    );${0}

    However, VS Code doesn't handle this well because you get stuck in snippet-mode when you're in each of the tab stops, and in Flutter it's very common to want to write multiline functions as arguments (see microsoft/vscode#43270). For ex, imagine you wanted to write:

    arg2: () {
      // Handle key press
    }

    When you press <tab> to indent that code, it would jump to the next tabstop (arg3) which would be frustrating.

    We do do something similar for non-named arguments already, but that has the issue described above (see #1173 (comment)) so I'd like to get rid of it when I can (which is probably when commit characters work better).

  2. added this to the Backlog milestone on Sep 3, 2019
  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 Sep 3, 2019
  4. DanTup commented on Sep 3, 2019

    @DanTup
    Member

    (I think it's a valid request to do better here though, so I'll keep this open in case a way to do it well comes up.. it'll likely need some analysis server work to get us the right info, but that might be simpler if we move to LSP).

  5. atreeon commented on Sep 3, 2019

    @atreeon
    Author

    ok great, thank you. I shall keep watching :-)

  6. jacoplane commented on Oct 10, 2019

    @jacoplane

    Alternatively a quickfix for "Add all required arguments". Right now there are quickfixes for every individual required arguments, but that's kind of annoying for functions that have a lot of arguments.
    image

  7. DanTup commented on Oct 14, 2019

    @DanTup
    Member

    @jacoplane that sounds like a reasonable request too. The quick fixes come from the analyzer SDK, so this it would need to be implemented there - would you mind filing an issue at https://github.com/dart-lang/sdk requesting that and post a link back here for people to 👍 ? Thanks!

  8. jacoplane commented on Oct 14, 2019

    @jacoplane

    @DanTup I've opened an issue there: dart-lang/sdk#38876

  9. DanTup commented on Nov 12, 2020

    @DanTup
    Member

    This is mostly the same as #2823 which is now implemented. When using the LSP preview (and an upcoming SDK release - since that change only landed yesterday), the dart.completeFunctionCalls setting will insert parens and positional args.

    However, it doesn't do required parameters, so I'll re-purpose this to support them (note: it's possible we'll only support real required params using the new required keyword rather than the @required annotation).

  10. added
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    and removed on Nov 12, 2020
  11. modified the milestones: Backlog, v3.17.0 on Nov 12, 2020
  12. changed the title [-]When intellisense suggests the creation of a new class or a function call can it provide the named parameters?[/-] [+]Include "required" parameters in LSP's completeFunctionCalls completions[/+] on Nov 12, 2020
  13. modified the milestones: v3.17.0, v3.18.0 on Nov 30, 2020
  14. DanTup commented on Dec 8, 2020

    @DanTup
    Member
  15. DanTup commented on Dec 9, 2020

    @DanTup
    Member
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